Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- MEDIA_WINDOW=$(xdotool search --name ".*Google Play Music|YouTube.*")
- CURRENT_WINDOW=$(xdotool getactivewindow)
- while getopts tpn opt; do
- case $opt in
- t)
- # Play/pause
- xdotool windowfocus --sync $MEDIA_WINDOW
- xdotool key --clearmodifiers space
- xdotool windowfocus --sync $CURRENT_WINDOW
- ;;
- p)
- # Previous
- xdotool windowfocus --sync $MEDIA_WINDOW
- xdotool key --clearmodifiers Left
- xdotool windowfocus $CURRENT_WINDOW
- ;;
- n)
- # Next
- xdotool windowfocus --sync $MEDIA_WINDOW
- xdotool key --clearmodifiers Right
- xdotool windowfocus --sync $CURRENT_WINDOW
- ;;
- :)
- # Usage
- cat <<EOF
- Usage: mediacontrol -t|-p|-n
- -t Toggle: Toggle play/pause in the media window
- -p Previous: Seek previous in the media window
- -n Next: Seek next in the media window
- EOF
- esac
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement