Advertisement
Guest User

mediacontrol

a guest
Feb 22nd, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.91 KB | None | 0 0
  1. #!/bin/bash
  2. MEDIA_WINDOW=$(xdotool search --name ".*Google Play Music|YouTube.*")
  3. CURRENT_WINDOW=$(xdotool getactivewindow)
  4.  
  5. while getopts tpn opt; do
  6.   case $opt in
  7.     t)
  8.       # Play/pause
  9.       xdotool windowfocus --sync $MEDIA_WINDOW
  10.       xdotool key --clearmodifiers space
  11.       xdotool windowfocus --sync $CURRENT_WINDOW
  12.       ;;
  13.     p)
  14.       # Previous
  15.       xdotool windowfocus --sync $MEDIA_WINDOW
  16.       xdotool key --clearmodifiers Left
  17.       xdotool windowfocus $CURRENT_WINDOW
  18.       ;;
  19.     n)
  20.       # Next
  21.       xdotool windowfocus --sync $MEDIA_WINDOW
  22.       xdotool key --clearmodifiers Right
  23.       xdotool windowfocus --sync $CURRENT_WINDOW
  24.       ;;
  25.     :)
  26.       # Usage
  27.       cat <<EOF
  28. Usage: mediacontrol -t|-p|-n
  29.  
  30. -t  Toggle:   Toggle play/pause in the media window
  31. -p  Previous: Seek previous in the media window
  32. -n  Next:     Seek next in the media window
  33.  
  34. EOF
  35.   esac
  36. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement