diff --git a/.config/qtile/config.py b/.config/qtile/config.py index 639d30f..cfb775d 100644 --- a/.config/qtile/config.py +++ b/.config/qtile/config.py @@ -27,6 +27,7 @@ WEB_QUICK_OPEN = os.path.expanduser( "~/.local/bin/firefox-quick-keywords" ) # https://github.com/GRFreire/firefox-quick-keywords +MEDIA_CONTROL = os.path.expanduser("~/.config/qtile/media_control.sh") keys = [ # Launch programs Key([MOD], "Return", lazy.spawn(TERMINAL), desc="Launch terminal"), @@ -71,6 +72,14 @@ keys = [ Key([MOD, "control"], "q", lazy.shutdown(), desc="Shutdown Qtile"), # System Key([MOD], "BackSpace", lazy.spawn(POWER_MENU), desc="Open power menu"), + # Media + Key([], "XF86AudioPlay", lazy.spawn(f"{MEDIA_CONTROL} play"), desc="Media control - play"), + Key([], "XF86AudioStop", lazy.spawn(f"{MEDIA_CONTROL} stop"), desc="Media control - stop"), + Key([], "XF86AudioNext", lazy.spawn(f"{MEDIA_CONTROL} next"), desc="Media control - next"), + Key([], "XF86AudioPrev", lazy.spawn(f"{MEDIA_CONTROL} prev"), desc="Media control - prev"), + Key([], "XF86AudioRaiseVolume", lazy.spawn(f"{MEDIA_CONTROL} vol_up"), desc="Media control - volume up"), + Key([], "XF86AudioLowerVolume", lazy.spawn(f"{MEDIA_CONTROL} vol_down"), desc="Media control - volume down"), + Key([], "XF86AudioMute", lazy.spawn(f"{MEDIA_CONTROL} vol_mute"), desc="Media control - mute volume"), ] group_names = [ diff --git a/.config/qtile/media_control.sh b/.config/qtile/media_control.sh new file mode 100755 index 0000000..6820df7 --- /dev/null +++ b/.config/qtile/media_control.sh @@ -0,0 +1,45 @@ +#!/bin/sh + +control_play() { + dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause + mpc toggle +} + +control_stop() { + dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Stop + mpc stop +} + +control_next() { + dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next + mpc next +} + +control_prev() { + dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous + mpc prev +} + +case $1 in + # Control + play ) + control_play ;; + stop ) + control_stop ;; + next ) + control_next ;; + prev ) + control_prev ;; + + # Volume + vol_up ) + amixer -q sset Master 5%+;; + vol_down ) + amixer -q sset Master 5%-;; + vol_mute ) + amixer -q -D pulse sset Master toggle;; + * ) + echo "Command not valid" ; exit 1;; +esac + +exit 0; \ No newline at end of file