Skip to content

Instantly share code, notes, and snippets.

@Yanik39
Created October 22, 2021 11:57
Show Gist options
  • Save Yanik39/aa884291a58584447860bae30e4fbee1 to your computer and use it in GitHub Desktop.
Save Yanik39/aa884291a58584447860bae30e4fbee1 to your computer and use it in GitHub Desktop.
#!/bin/bash
/usr/bin/logger -t Move "Starting"
while :; do
if [ $(xprintidle) -gt 57000 ]
then
if [[ $(/usr/bin/wmctrl -l | grep Brave | wc -l) -ge 1 ]]
then
/usr/bin/logger -t Move "Moving"
#/usr/bin/wmctrl -l | grep Brave | grep -v Mozilla | sed -ne 's|^\([^ ]*\).*Brave.*|\1|p'
#/usr/bin/wmctrl -R Brave
#/usr/bin/wmctrl -iR $(/usr/bin/wmctrl -l | grep Brave | grep -v 'Mozilla\|Inbox' | sed -ne 's|^\([^ ]*\).*Brave.*|\1|p')
/usr/bin/wmctrl -iR $(/usr/bin/wmctrl -l | grep -E ' - Brave' | grep -v ' — Mozilla Thunderbird\| — Mozilla Firefox' | sed -ne 's|^\([^ ]*\).*Brave.*|\1|p')
/usr/bin/xdotool sleep 0.5
#/usr/bin/xdotool mousemove_relative --sync -- '-50' '-50'
#/usr/bin/xdotool sleep 0.1
#/usr/bin/xdotool mousemove_relative --sync '50' '50'
/usr/bin/xdotool mousemove --sync $(($(rand -M 800) + 300)) $(($(rand -M 500) + 200))
/usr/bin/xdotool sleep 0.2
/usr/bin/xdotool key "ctrl+1"
/usr/bin/xdotool sleep 0.3
/usr/bin/xdotool key F5
#/usr/bin/xdotool windowactivate $(/usr/bin/xdotool search --class brave | /usr/bin/tail -1) key "ctrl+1" F5
else
/usr/bin/logger -t Move "No Brave Browser found!"
fi
else
/usr/bin/logger -t Move "User not idle!"
fi
sleep 63
done &
echo $(($$ + 2))
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment