Skip to content
This repository has been archived by the owner on Jan 5, 2018. It is now read-only.

Commit

Permalink
removed Audacious support
Browse files Browse the repository at this point in the history
  • Loading branch information
Hjdskes committed Apr 24, 2014
1 parent 85c4379 commit a6d7039
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 37 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ CC = gcc
PREFIX ?= /usr/local
BINPREFIX = ${PREFIX}/bin

LIBS = -lasound -lX11 `pkg-config --cflags --libs glib-2.0 dbus-glib-1 audclient`
LIBS = -lasound -lX11
CFLAGS += -std=c99 -pedantic -Wall -Wextra

debug: CFLAGS += -O0 -g
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Installation
In order to succesfully compile this, you need to have the following dependencies installed:
* `libx11`
* `alsa-lib`
* `audacious`

To built and install, simply run

Expand Down
47 changes: 14 additions & 33 deletions dwmst.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#include <sys/socket.h>
#include <alsa/asoundlib.h>
#include <linux/wireless.h>
#include <audacious/dbus.h>
#include <audacious/audctrl.h>

#include "dwmst.h"

Expand Down Expand Up @@ -51,19 +49,6 @@ is_up (char *device) {
return 0;
}

char *
get_aud(DBusGProxy *session) {
char *music = NULL;
int pos;

pos = audacious_remote_get_playlist_pos(session);
music = audacious_remote_get_playlist_title(session, pos);
if(music != NULL)
return smprintf(AUD_STR, music);
else
return NULL;
}

char *
get_skype(void) {
if(access(SKYPE_LOCK, F_OK) == 0)
Expand Down Expand Up @@ -189,49 +174,45 @@ int
main(void) {
struct iwreq wreq;
snd_mixer_t *handle;
DBusGProxy *session = NULL;
DBusGConnection *conn = NULL;
int sockfd, netloops = 60, musicloops = 60;
char *status, *aud, *skype, *net, *vol, *batt, *clk;
int sockfd, loops = 60;
char *status, *skype, *net, *vol, *batt, *clk;

if(!(dpy = XOpenDisplay(NULL))) {
fprintf(stderr, "dwmst: cannot open display.\n");
return 1;
}

conn = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);
session = dbus_g_proxy_new_for_name(conn, AUDACIOUS_DBUS_SERVICE, AUDACIOUS_DBUS_PATH, AUDACIOUS_DBUS_INTERFACE);

memset(&wreq, 0, sizeof(struct iwreq));
snprintf(wreq.ifr_name, sizeof(WIRELESS_DEVICE), WIRELESS_DEVICE);
sockfd = socket (AF_INET, SOCK_DGRAM, 0);
sockfd = socket(AF_INET, SOCK_DGRAM, 0);

snd_mixer_open(&handle, 0);
snd_mixer_attach(handle, "default");
snd_mixer_selem_register(handle, NULL, NULL);
snd_mixer_load(handle);

for(;;sleep(INTERVAL)) {
if(++musicloops > 60 && session != NULL)
aud = get_aud(session);
if(++loops > 60) {
loops = 0;
if(sockfd > 0)
net = get_net(wreq, sockfd);
clk = get_time();
}
skype = get_skype();
if(++netloops > 60 && sockfd > 0)
net = get_net(wreq, sockfd);
vol = get_vol(handle);
batt = get_batt();
clk = get_time();
status = smprintf("%s %s %s %s %s %s", aud, skype, net, vol, batt, clk);
status = smprintf("%s %s %s %s %s", skype, net, vol, batt, clk);
setstatus(status);
if(++musicloops > 60 && session != NULL)
free(aud);
free(skype);
if(++netloops > 60 && sockfd > 0)
free(net);
free(vol);
free(batt);
free(status);
}


if(sockfd > 0)
free(net);
free(clk);
XCloseDisplay(dpy);
close(sockfd);
snd_mixer_close(handle);
Expand Down
4 changes: 2 additions & 2 deletions dwmst.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#define BATT_VOLT "/sys/class/power_supply/BAT1/voltage_now"
#define BATT_CNOW "/sys/class/power_supply/BAT1/power_now"

#define AUD_STR "%s"
#define NO_AUD_STR ""
#define MPD_STR "%s"
#define NO_MPD_STR ""

#define SKYPE_STR "Skype"
#define NO_SKYPE_STR ""
Expand Down

0 comments on commit a6d7039

Please sign in to comment.