Skip to content

Instantly share code, notes, and snippets.

@discarn8
Created August 26, 2022 04:28
Show Gist options
  • Save discarn8/239faaf613f326f5f2797750373417c2 to your computer and use it in GitHub Desktop.
Save discarn8/239faaf613f326f5f2797750373417c2 to your computer and use it in GitHub Desktop.
Switch tabs in Chromium every 8 seconds and reload specific tabs [tabs] only at specific times [times] and in less than 60 seconds
#!/bin/bash
#set -xv
DISPLAY=:0.0
export DISPLAY=:0.0
export XAUTHORITY=/home/pi/.Xauthority
m=0
action=""
min=$(date +"%M")
times=(00 05 10 15 20 25 30 35 40 45 50 55)
tabs=(2 3 5)
if test $(cut -d '.' -f1 /proc/uptime) -gt 60; then
if pidof -o %PPID -x "timer.sh">/dev/null; then
#echo "Process already running"
exit;
else
start=0
end=0
for i in {1..7}; do
if [ $m -lt 52 ]; then
start=$(date +%s)
if [[ ${times[*]} =~ (^|[[:space:]])"$min"($|[[:space:]]) ]]; then
if [[ ${tabs[*]} =~ (^|[[:space:]])"$i"($|[[:space:]]) ]]; then
action="ctrl+$i ctrl+r"
else
action="ctrl+$i"
fi
else
action="ctrl+$i"
fi
wmctrl -xa chromium-browser.Chromium-browser && xdotool search --class Chromium key --window %@ "$action"
sleep 8.3
end=$(date +%s)
seconds=$(($end-$start))
((m=m+$seconds))
else
exit;
fi
if [ $m -gt 58 ]; then
exit;
fi
done;
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment