Enable volume control with volume keys

This commit is contained in:
2024-06-04 22:27:56 +01:00
parent 2f45731138
commit 2c3fdb48d9
3 changed files with 22 additions and 1 deletions

View File

@@ -369,7 +369,6 @@ open_link() {
echo "Updating Debian..." echo "Updating Debian..."
sudo apt install nala -y sudo apt install nala -y
sudo nala update
sudo nala upgrade sudo nala upgrade
echo echo
echo "##########################" echo "##########################"

View File

@@ -1,6 +1,7 @@
/* See LICENSE file for copyright and license details. */ /* See LICENSE file for copyright and license details. */
#include "exitdwm.c" #include "exitdwm.c"
#include <X11/XF86keysym.h> /* Allow using F# keys for keybinds */
/* appearance */ /* appearance */
static const unsigned int borderpx = 4; /* border pixel of windows */ static const unsigned int borderpx = 4; /* border pixel of windows */
@@ -58,6 +59,11 @@ static const Layout layouts[] = {
/* helper for spawning shell commands in the pre dwm-5.0 fashion */ /* helper for spawning shell commands in the pre dwm-5.0 fashion */
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
/* volume commands */
static const char *upvol[] = { "/usr/bin/wpctl", "set-volume", "@DEFAULT_AUDIO_SINK@", "5%+", NULL };
static const char *downvol[] = { "/usr/bin/wpctl", "set-volume", "@DEFAULT_AUDIO_SINK@", "5%-", NULL };
static const char *mutevol[] = { "/usr/bin/wpctl", "set-mute", "@DEFAULT_AUDIO_SINK@", "toggle", NULL };
/* commands */ /* commands */
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, NULL }; static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, NULL };
@@ -65,6 +71,11 @@ static const char *termcmd[] = { "st", NULL };
static const char *slockcmd[] = { "slock", NULL }; static const char *slockcmd[] = { "slock", NULL };
static const Key keys[] = { static const Key keys[] = {
/* Volume keys support */
{ 0, XF86XK_AudioLowerVolume, spawn, {.v = downvol } },
{ 0, XF86XK_AudioMute, spawn, {.v = mutevol } },
{ 0, XF86XK_AudioRaiseVolume, spawn, {.v = upvol } },
/* modifier key function argument */ /* modifier key function argument */
{ MODKEY, XK_p, spawn, {.v = dmenucmd } }, { MODKEY, XK_p, spawn, {.v = dmenucmd } },
{ MODKEY, XK_Return, spawn, {.v = termcmd } }, { MODKEY, XK_Return, spawn, {.v = termcmd } },

View File

@@ -1,6 +1,7 @@
/* See LICENSE file for copyright and license details. */ /* See LICENSE file for copyright and license details. */
#include "exitdwm.c" #include "exitdwm.c"
#include <X11/XF86keysym.h> /* Allow using F# keys for keybinds */
/* appearance */ /* appearance */
static const unsigned int borderpx = 4; /* border pixel of windows */ static const unsigned int borderpx = 4; /* border pixel of windows */
@@ -58,6 +59,11 @@ static const Layout layouts[] = {
/* helper for spawning shell commands in the pre dwm-5.0 fashion */ /* helper for spawning shell commands in the pre dwm-5.0 fashion */
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
/* volume commands */
static const char *upvol[] = { "/usr/bin/wpctl", "set-volume", "@DEFAULT_AUDIO_SINK@", "5%+", NULL };
static const char *downvol[] = { "/usr/bin/wpctl", "set-volume", "@DEFAULT_AUDIO_SINK@", "5%-", NULL };
static const char *mutevol[] = { "/usr/bin/wpctl", "set-mute", "@DEFAULT_AUDIO_SINK@", "toggle", NULL };
/* commands */ /* commands */
static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() */
static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, NULL }; static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, NULL };
@@ -65,6 +71,11 @@ static const char *termcmd[] = { "st", NULL };
static const char *slockcmd[] = { "slock", NULL }; static const char *slockcmd[] = { "slock", NULL };
static const Key keys[] = { static const Key keys[] = {
/* Volume keys support */
{ 0, XF86XK_AudioLowerVolume, spawn, {.v = downvol } },
{ 0, XF86XK_AudioMute, spawn, {.v = mutevol } },
{ 0, XF86XK_AudioRaiseVolume, spawn, {.v = upvol } },
/* modifier key function argument */ /* modifier key function argument */
{ MODKEY, XK_p, spawn, {.v = dmenucmd } }, { MODKEY, XK_p, spawn, {.v = dmenucmd } },
{ MODKEY, XK_Return, spawn, {.v = termcmd } }, { MODKEY, XK_Return, spawn, {.v = termcmd } },