Last active
May 26, 2020 09:32
-
-
Save misebox/a4927e661aafd0822daf53c34ac14076 to your computer and use it in GitHub Desktop.
Shellscript to search firefox and close its all tabs and windows.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
while [ `pgrep firefox` != "" ] | |
do | |
for winid in $(xdotool search --onlyvisible --pid `pgrep firefox`) | |
do | |
echo $winid | |
sleep 0.2 | |
if [ "$winid" != "" ] | |
then | |
while true | |
do | |
wmctrl -i -a $winid | |
sleep 0.01 | |
active=`xdotool getactivewindow` | |
if [ "$active" = "$winid" ] | |
then | |
xdotool key ctrl+w; | |
else | |
break | |
fi | |
done | |
else | |
echo "All foxes were hunted out." | |
break | |
fi | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script is sometime useful for example like startup script that opens same url every time without previous session.
Of course I don't hate firefox.