diff -Naur dwmbase/config.def.h dwmfork/config.def.h --- dwmbase/config.def.h 2015-11-08 23:39:37.000000000 +0100 +++ dwmfork/config.def.h 2018-02-17 17:09:23.619932659 +0100 @@ -1,5 +1,5 @@ /* See LICENSE file for copyright and license details. */ - +#include //needed for X media keys binds, remove if unnecessary /* appearance */ static const char *fonts[] = { "monospace:size=10" @@ -11,6 +11,8 @@ static const char selbordercolor[] = "#005577"; static const char selbgcolor[] = "#005577"; static const char selfgcolor[] = "#eeeeee"; +static const char *alsa_card = "default"; +static const char *alsa_selem_name = "Master"; static const unsigned int borderpx = 1; /* border pixel of windows */ static const unsigned int snap = 32; /* snap pixel */ static const int showbar = 1; /* 0 means no bar */ @@ -59,6 +61,9 @@ static Key keys[] = { /* modifier key function argument */ + { 0, XF86XK_AudioRaiseVolume, alsaset, {.i = +2 } }, + { 0, XF86XK_AudioLowerVolume, alsaset, {.i = -2 } }, + { 0, XF86XK_AudioMute, alsaset, {.i = 0 } }, { MODKEY, XK_p, spawn, {.v = dmenucmd } }, { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } }, { MODKEY, XK_b, togglebar, {0} }, diff -Naur dwmbase/config.mk dwmfork/config.mk --- dwmbase/config.mk 2015-11-08 23:39:37.000000000 +0100 +++ dwmfork/config.mk 2018-02-17 17:07:08.539943798 +0100 @@ -22,7 +22,7 @@ # includes and libs INCS = -I${X11INC} -I${FREETYPEINC} -LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} +LIBS = -L${X11LIB} -lasound -lX11 ${XINERAMALIBS} ${FREETYPELIBS} # flags CPPFLAGS = -D_BSD_SOURCE -D_POSIX_C_SOURCE=2 -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} diff -Naur dwmbase/dwm.c dwmfork/dwm.c --- dwmbase/dwm.c 2015-11-08 23:39:37.000000000 +0100 +++ dwmfork/dwm.c 2018-02-17 17:06:05.973282291 +0100 @@ -40,6 +40,7 @@ #include #endif /* XINERAMA */ #include +#include #include "drw.h" #include "util.h" @@ -142,6 +143,7 @@ } Rule; /* function declarations */ +static void alsaset(const Arg *arg); static void applyrules(Client *c); static int applysizehints(Client *c, int *x, int *y, int *w, int *h, int interact); static void arrange(Monitor *m); @@ -275,6 +277,44 @@ /* function implementations */ void +alsaset(const Arg *arg) +{ + long min, max; + snd_mixer_t *handle; + snd_mixer_selem_id_t *sid; + snd_mixer_open(&handle, 0); + snd_mixer_attach(handle, alsa_card); + snd_mixer_selem_register(handle, NULL, NULL); + snd_mixer_load(handle); + snd_mixer_selem_id_alloca(&sid); + snd_mixer_selem_id_set_index(sid, 0); + snd_mixer_selem_id_set_name(sid, alsa_selem_name); + snd_mixer_elem_t* elem = snd_mixer_find_selem(handle, sid); + if(arg->i==0) + { + if (snd_mixer_selem_has_playback_switch(elem)) + { + int returned; + snd_mixer_selem_get_playback_switch(elem,SND_MIXER_SCHN_UNKNOWN,&returned); + if(returned) + snd_mixer_selem_set_playback_switch_all(elem, 0); + else + snd_mixer_selem_set_playback_switch_all(elem, 1); + } + } + else + { + long volume; + snd_mixer_selem_get_playback_volume(elem,SND_MIXER_SCHN_UNKNOWN,&volume); + if((volume+arg->i<100&&arg->i>0)||(volume+arg->i>0&&arg->i<0)) + volume+=arg->i; + snd_mixer_selem_get_playback_volume_range(elem, &min, &max); + snd_mixer_selem_set_playback_volume_all(elem, volume); + } + snd_mixer_close(handle); +} + +void applyrules(Client *c) { const char *class, *instance;