#!/bin/bash # A tool for putting firefox to sleep when it does not have focus. # Luke Macken alive=1 while true; do if xwininfo -id $(xdotool getactivewindow) | egrep -q '(Firefox|Vimperator)'; then if [ ! $alive ]; then echo "Waking firefox up" kill -CONT `pidof firefox` alive=1 fi else if [ $alive ]; then echo "Putting firefox to sleep" kill -STOP `pidof firefox` alive= fi fi sleep 1 done