Setting primary display

When at home I hook up the laptop to an external monitor. For the most part it works great, plug it in and it works. I want the external monitor to be the primary. Pretty simple with xrandr --output DISPLAY --primary so I adapted my vij command to list out the monitors and present the list to me.

#!/bin/sh

monitors=$(xrandr | grep " connected " | awk '{print $1}')
matches=$(echo $monitors | gawk '{print NF}')

case "$matches" in
    0)
       echo "No matches found"
       show=""
       ;;
    1)
       show=$monitors
       ;;
    *)
       echo
       echo "Multiple matches found..."
       i=1
       for option in $monitors
       do
          echo "$i: $option"
          i=`expr $i + 1`
       done
       echo "q: Quit"
       echo
       read -p "? " ans
       if [ "q" == "$ans" ]; then
          show=""
       else
          show=$(echo $monitors | gawk '{print $'$ans'}')
       fi
       ;;
esac

if [ "" != "$show" ]; then
   xrandr --output $show --primary
fi

When you run the script this is what you see:

$ bin/prim 

Multiple matches found...
1: LVDS1
2: VGA1
q: Quit

? 

Gnome 3 why do you hate me?

So my Gnome 3 (gnome-shell, Fedora 18) went to screensaver. When I unlocked it this is what my desktop looks like.

lockup

How do I get out of this? My machine is running fine. I can ssh into it and it’s running normal but I can’t interact with the desktop. Quite annoying.