Skip to content

Instantly share code, notes, and snippets.

@tberghuis
Last active January 15, 2019 22:08
Show Gist options
  • Save tberghuis/2453f622e1b05e2fe507afce2b730582 to your computer and use it in GitHub Desktop.
Save tberghuis/2453f622e1b05e2fe507afce2b730582 to your computer and use it in GitHub Desktop.
media play pause
using xbindkeys and xdotool
"mediapause.sh setmediawindow"
Control+Alt+Mod2 + m
"mediapause.sh playpause"
Alt_R
#!/bin/bash
# this script is ran from ~/.xbindkeysrc
# ctrl + alt + m
# save the current active window id
if [ "$1" = "setmediawindow" ]; then
xdotool getactivewindow > ~/.mediawindowid
fi
# if r_ALT
# send a spacebar to the media window
if [ "$1" = "playpause" ]; then
MEDIAWID=$(head -n 1 ~/.mediawindowid)
CURRENTWID=`xdotool getactivewindow | head -1`
xdotool keyup Alt_R windowactivate --sync $MEDIAWID key space windowactivate $CURRENTWID
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment