I did find a workaround.
I found that the wmctrl application will allow me to change workspaces from the CLI, but there is a time lag. If the target application (I'll use gedit as an example) is not running I need to:
- Change the to the target Workspace
- Launch the target application
- Wait for that application to actually launch
- Switch back to the original Workspace
Code:
CurrentWS=`wmctrl -d | grep "*" | cut -f 1 -d " "`
Application="gedit"
wmctrl -s 1
$Application &
# Wait up to ten seconds for the Application to load
for i in `seq 1 10`
do
sleep 1s
Process=`pgrep -f "$Application"`
WindowID=`wmctrl -l -p | grep $Process | cut -f 1 -d " "`
if [[ "$WindowID" != "" ]]
then
break
fi
done
wmctrl -s $CurrentWS
However if the Application is already running, you can use wmctrl to move that app to the desired Workspace.
Code:
Application="gedit"
Process=`pgrep -f "$Application"`
WindowID=`wmctrl -l -p | grep $Process | cut -f 1 -d " "`
WindowID=${WindowID#0x}
wmctrl -r $WindowID -t 1
However this is just a hack, does anyone know of a better way to do this?
Thanks
Bob