Advertisement
Guest User

Untitled

a guest
May 26th, 2021
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.42 KB | None | 0 0
  1. #/bin/bash
  2. # killOld=`ps -ef | grep CitrixCaffeine.sh | awk '{print $2}' | xargs kill -9`
  3. #get the details of currently open windows | get only the full title | put 'FALSE " "'' around each title for zenity usage | replace newlines with spaces -- o/p is ready as a list of options for zenity radiolist
  4. listOfWindows=`wmctrl -l | awk '{print substr($0,index($0,$4))}' | sed 's/\(.*\)/FALSE "\1"/g' |  tr '\n' ' '`
  5. #echo ${listOfWindows}
  6.  
  7.  
  8. ListType=`eval $(echo "zenity --width=400 --height=275 --window-icon='/usr/share/icons/CitrixCaffeine.png' --list --radiolist --title 'Window Picker' --text 'Pick the window to keep alive:' --column 'Select' --column 'Window Name:' $listOfWindows")`
  9.  
  10. echo $ListType
  11.  
  12. #still doesn't handle case where multiple windows have same title
  13. WID=$(xdotool search --name "${ListType:0:10}")
  14. echo $WID
  15.  
  16.  
  17.  
  18.  
  19. Response=$(zenity --scale --title "Ping frequency" --window-icon='/usr/share/icons/CitrixCaffeine.png' --text "Select ping frequency." --min-value=10 --max-value=180 --step=5 --value=120);
  20. echo $Response
  21.  
  22. if [[ $WID > -1 ]]; then
  23.     while [ 1 ]; do
  24.     sleep $Response
  25.     xdotool key --window $WID F13
  26.     #sleep 2
  27.     #xdotool key --window $WID a
  28.     done
  29. fi
  30. else
  31.     #unlikely as we're picking from a list, but if window is closed between execution, it branches here, it doesn't. WID is stored in variable, fix this
  32.     zenity --error --title="Error!" --width=200 --text="This window doesn't exist"
  33.  
  34. exit
  35.  
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement