d34n

Maximize a running program with bash & xdotool

Apr 17th, 2014
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #!/bin/bash
  2. PROG='thunderbird'; # set to your program process name
  3. RUNNING=`ps auxw | grep $PROG | grep -v grep | wc -l`
  4. if [ "$RUNNING" == "1" ]; then
  5. # get PID
  6. PID=`ps auxw | grep $PROG | grep -v grep | awk '{print $2}'`
  7. # get window ID from PID
  8. WINID=`xdotool search --pid $PID | tail -1`
  9. # focus window, wait until focused, maximize with shortcut
  10. xdotool windowactivate --sync $WINID key --clearmodifiers --delay 100 ctrl+super+Up
  11. else
  12. # not running, run it
  13. $PROG
  14. fi
Advertisement
Add Comment
Please, Sign In to add comment