Skip to content

Instantly share code, notes, and snippets.

@misebox
Last active May 26, 2020 09:32
Show Gist options
  • Save misebox/a4927e661aafd0822daf53c34ac14076 to your computer and use it in GitHub Desktop.
Save misebox/a4927e661aafd0822daf53c34ac14076 to your computer and use it in GitHub Desktop.
Shellscript to search firefox and close its all tabs and windows.
#!/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
@misebox
Copy link
Author

misebox commented May 26, 2020

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.

foxhunt-description

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment