From ec3d3899b9a19d5702388ba5b29219645e56118a Mon Sep 17 00:00:00 2001 From: Donovan Glover Date: Fri, 11 Oct 2024 23:41:20 -0400 Subject: [PATCH] meta: add audio keys support with playerctl Actually quite useful now that I've figured out how to do this properly. --- home/dwm.nix | 10 ++++++++++ home/hyprland.nix | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/home/dwm.nix b/home/dwm.nix index 218cdfd7..c3cc7d6f 100644 --- a/home/dwm.nix +++ b/home/dwm.nix @@ -99,6 +99,11 @@ in static const char *mute_vol[] = { "${dunst-scripts}/bin/mv-mute", NULL }; static const char *mute_mic[] = { "${dunst-scripts}/bin/mv-mic", NULL }; static const char *wallpaper[] = { "fish", "${homeDirectory}/.config/${wallpaperScript}", NULL }; + static const char *audio_prev[] = { "playerctl", "-p", "playerctld", "previous", NULL }; + static const char *audio_next[] = { "playerctl", "-p", "playerctld", "next", NULL }; + static const char *audio_play_pause[] = { "playerctl", "-p", "playerctld", "play-pause", NULL }; + static const char *audio_forward[] = { "playerctl", "-p", "playerctld", "position", "10+", NULL }; + static const char *audio_rewind[] = { "playerctl", "-p", "playerctld", "position", "10-", NULL }; static const Key keys[] = { { 0, XF86XK_AudioMute, spawn, {.v = mute_vol } }, @@ -107,6 +112,11 @@ in { 0, XF86XK_AudioRaiseVolume, spawn, {.v = up_vol } }, { 0, XF86XK_MonBrightnessDown, spawn, {.v = dimmer } }, { 0, XF86XK_MonBrightnessUp, spawn, {.v = brighter } }, + { 0, XF86XK_AudioPrev, spawn, {.v = audio_prev } }, + { 0, XF86XK_AudioNext, spawn, {.v = audio_next } }, + { 0, XF86XK_AudioPlay, spawn, {.v = audio_play_pause } }, + { 0, XF86XK_AudioForward, spawn, {.v = audio_forward } }, + { 0, XF86XK_AudioRewind, spawn, {.v = audio_rewind } }, { 0, XK_Print, spawn, {.v = print } }, { MODKEY, XK_bracketleft, spawn, {.v = dmenucmd } }, { MODKEY, XK_bracketright, spawn, {.v = explorercmd } }, diff --git a/home/hyprland.nix b/home/hyprland.nix index a7f50151..c8d01351 100644 --- a/home/hyprland.nix +++ b/home/hyprland.nix @@ -35,6 +35,7 @@ in lnch wev wf-recorder + playerctl ]; wayland.windowManager.hyprland = { @@ -242,6 +243,12 @@ in ", XF86MonBrightnessDown, exec, ${dunst-scripts}/bin/mb-down" ", XF86MonBrightnessUp, exec, ${dunst-scripts}/bin/mb-up" ", XF86Display, exec, ~/.config/${monitorScript}" + ", XF86AudioPrev, exec, playerctl -p playerctld previous" + ", XF86AudioNext, exec, playerctl -p playerctld next" + ", XF86AudioPlay, exec, playerctl -p playerctld play" + ", XF86AudioPause, exec, playerctl -p playerctld pause" + ", XF86AudioForward, exec, playerctl -p playerctld position 10+" + ", XF86AudioRewind, exec, playerctl -p playerctld position 10-" ", XF86Messenger, togglespecialworkspace" ]; };