Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
FVDWLR - Firefox Virtual Desktop Window Location Restore-er Simple shell script to restore firefox window locations to their previous virtual desktop location.
#!/bin/bash
# FVDWLR - Firefox Virtual Desktop Window Location Restore-er
#
#When Firefox restarts (crash/whatever), when the previous browsing session is restored, the virtual desktop that the window was running on is not also restored. If you're like me, and categorize browsing by windows and virtual desktops this is very annoying. (ie I have a Firefox window researching matlab on the same desktop that matlab is running on, and then on a different desktop I have Gmail/barnowl/irssi running.) This failure to restore desktops is thus quite annoying.
#
#This simple shell script fixes that by restarting Firefox within the shell script. It uses xprop and wmctrl to read and restore the virtual desktop location of windows after (forcibly) restarting Firefox.
#Note that I'm on Debian and so 'Firefox' is technically Iceweasel, so change the variable as needed
#Requires x11-utils and wmctrl packages:
# sudo apt-get install x11-utils wmctrl
#
#Patches welcome.
FF_NAME='iceweasel'
FF_PID=`pidof $FF_NAME`
WINDOWS=`wmctrl -l -p | grep $FF_PID| awk '{print $1}'`
declare -A WIN_LOC
declare -A WIN_NAME
for WIN in $WINDOWS; do
WIN_LOC[$WIN]=`xprop -id $WIN _NET_WM_DESKTOP | sed 's/^.*= //'`
WIN_NAME[$WIN]=`xprop -id $WIN _NET_WM_VISIBLE_NAME | sed -e 's/^.*= "//' -e 's/"$//'`
done;
echo 'Press [enter] to kill firefox.'
read foo
sync # for good measure since we're just killing ff
kill $FF_PID
pidof $FF_NAME >/dev/null
while [ "$?" -eq "0" ]; do
echo 'firefox still running; sleeping'
sleep .8
pidof $FF_NAME >/dev/null
done;
echo 'running firefox'
`$FF_NAME` 1>/dev/null 2>&1 &
disown
echo 'Press [enter] to restore desktop positions'
echo "AFTER you've pressed 'restore' in firefox"
echo "And AFTER FF has had a chance to restore window names"
read foo
sleep 2
for WIN in $WINDOWS; do
NAME=${WIN_NAME[$WIN]}
LOC=${WIN_LOC[$WIN]}
#echo $NAME - DESKTOP $LOC
wmctrl -r $NAME -t $LOC
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.