Skip to content

Instantly share code, notes, and snippets.

@Ohcanep
Last active September 23, 2016 21:03
Show Gist options
  • Save Ohcanep/8baf722267833192e988be176fdb4952 to your computer and use it in GitHub Desktop.
Save Ohcanep/8baf722267833192e988be176fdb4952 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# For a vastly more feature-rich tool, have a look at
# https://gist.github.com/Ohcanep/48dac84c5916821d150c545a6eb12547
# https://gist.github.com/wandernauta/6800547 (original)
DEST="org.mpris.MediaPlayer2.spotify"
OBJECT_PATH="/org/mpris/MediaPlayer2"
INTERFACE="org.mpris.MediaPlayer2.Player"
dbus_send_spotify ()
{
dbus-send --dest="$DEST" --type=method_call "$OBJECT_PATH" "$INTERFACE"."$1"
}
case "$1" in
play)
dbus_send_spotify PlayPause;;
stop)
dbus_send_spotify Stop;;
prev)
dbus_send_spotify Previous;;
next)
dbus_send_spotify Next;;
*)
echo "Usage: $0 play|stop|prev|next"
exit 1;;
esac
#!/usr/bin/env bash
xfconf_set_shortcut ()
{
xfconf-query --channel xfce4-keyboard-shortcuts \
--create --property "/commands/custom/$1" --type string --set "$2"
}
xfconf_set_shortcut "XF86AudioPlay" "spotify-ctrl play"
xfconf_set_shortcut "XF86AudioStop" "spotify-ctrl stop"
xfconf_set_shortcut "XF86AudioPrev" "spotify-ctrl prev"
xfconf_set_shortcut "XF86AudioNext" "spotify-ctrl next"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment