![](img/pic.png)
![](img/pic2.png)
+With MPD
+![](img/pic3.png)
+
Statusbar program for ~~dwm and xmonad~~ any WM that I've written in my very first day as dwm user.
Please note that the program won't detect fans connected via molex connetor(s) or external fan controller. Also I have not tested it with fan splitter(s) either.
make install
```
+To see the current playing song add **--with-mpd** to configure.
+
Put the following in your **xinitrc** or the script used to start dwm.
```bash
make install
```
+To see the current playing song add **--with-mpd** to configure.
+
Put the following in your **xinitrc** or the script used to start xmonad.
```bash
* alsa-utils
* alsa-lib
+requirements to see the current playing song:
+
+* libmpdclient
+* mpd (with properly configured config)
+
requirements for xmonad or other non-dwm WM:
* dzen2
# The linker flags tests in m4 dir
TEST_X11
TEST_ALSA
+ TEST_MPD
TEST_TYPEZ
AC_CONFIG_FILES([
-Wformat=0 -Wmissing-prototypes -Wno-unused-result \
-Wno-unused-function -pedantic -Wno-missing-field-initializers
- '${prog_name}'_LDADD = $(X_LIBS) $(ALSA_LIBS)
+ '${prog_name}'_LDADD = $(X_LIBS) $(ALSA_LIBS) $(MPD_LIBS)
'${prog_name}'_SOURCES = '${src_files[@]}'
')
])
+dnl TEST_MPD() function in configure.ac
+dnl
+dnl Substitute the linker flags -lmpdclient to the
+dnl the variable 'MPD_LIBS' if the user enabled
+dnl the --with-mpd switch
+AC_DEFUN([TEST_MPD],[
+ MPD_LIBS=""
+
+ AC_ARG_WITH([mpd],
+ AS_HELP_STRING([--with-mpd],
+ [mpd linker flag to show the current playing song]),
+ [],
+ [with_mpd=no]
+ )
+
+ AS_IF([test "x$with_mpd" = "xyes"], [
+ AC_CHECK_HEADERS([mpd/client.h], [
+ MPD_LIBS="-lmpdclient"
+ ],[
+ ERR([Install libmpdclient in order to compile the program.])
+ ])
+ ]
+ )
+
+ AC_SUBST(MPD_LIBS)
+
+])
+
+
dnl Internal function to perform
dnl explicit data check type
AC_DEFUN([CHECK_TYPEZ],[
#define NAME_VAL "\x0a%s \x0b%s" /* STR1 STR2 */
#define TEMP "\x09%sC\x0b%c " /* 32C, */
#define FMT_KERN "\x09%s%c " /* Kernel Version, */
+#define FMT_SONG "\x0b%s " /* Song */
#define CPU_STR "CPU"
#define RAM_STR "RAM"
#define NAME_VAL BLUE"%s "PINK"%s" /* STR1 STR2 */
#define TEMP YELLOW"%s^i("ICONS_DIR"/temp.xbm)"PINK"%c " /* 32C, */
#define FMT_KERN YELLOW"%s%c " /* Kernel Version, */
+#define FMT_SONG PINK"%s " /* Song */
#define CPU_STR XBM_ICON("cpu.xbm")
#define RAM_STR XBM_ICON("mem.xbm")
#include <X11/Xlib.h>
#endif
+#if defined (HAVE_MPD_CLIENT_H)
+#include <mpd/client.h>
+#endif
+
#include <alsa/asoundlib.h>
#include "constants1.h"
}
}
#endif
+
+
+#if defined (HAVE_MPD_CLIENT_H)
+void
+get_song(char *str1) {
+ struct mpd_connection *conn;
+ struct mpd_song *song;
+
+ if (NULL == (conn = mpd_connection_new(NULL, 0, 0))) {
+ return;
+ }
+ if (!(mpd_send_command(conn, "currentsong", NULL)) ||
+ mpd_connection_get_error(conn)) {
+ return;
+ }
+ if (NULL == (song = mpd_recv_song(conn))) {
+ if (NULL != conn) {
+ mpd_connection_free(conn);
+ }
+ return;
+ }
+ mpd_connection_free(conn);
+
+ FILL_STR_ARR(1, str1, mpd_song_get_uri(song));
+}
+#endif
void set_status(const char *);
#endif
+#if defined (HAVE_MPD_CLIENT_H)
+void get_song(char *);
+#endif
+
#endif /* FUNCTIONS_H_ */
struct timespec tc = {0};
tc.tv_nsec = sysconf(_SC_CLK_TCK) * 1000000L;
- char packs[VLA], mobo[VLA], cpu[VLA], ram[VLA], ssd[VLA];
+ char packs[VLA], mobo[VLA], cpu[VLA], ram[VLA], ssd[VLA], song[VLA];
char kern[VLA], volume[VLA], Time[VLA], combine[WHOLE_MAIN_ARR_LEN];
char voltage[VLA], cpu_temp[VLA], mobo_temp[VLA], fans[VLA];
get_cpu(cpu, cpu_temp);
-
if (-1 == (nanosleep(&tc, NULL))) {
printf("%s\n", "Error: nanosleep() failed");
return EXIT_FAILURE;
}
+#if defined (HAVE_MPD_CLIENT_H)
+ get_song(song);
+#endif
+
get_cpu(cpu, cpu_temp);
get_ram(ram);
get_ssd(ssd);
snprintf(combine, WHOLE_MAIN_ARR_LEN,
/* formatting specifiers */
+ FMT_SONG
FMT_CPU FMT_RAM FMT_SSD FMT_PKGS FMT_KERN
FMT_VOLT FMT_FANS FMT_MOBO FMT_VOL FMT_TIME,
/* the data */
+ song,
CPU_STR, cpu, cpu_temp, COMMA,
RAM_STR, ram, COMMA,
SSD_STR, ssd, COMMA,