segunda-feira, 20 de outubro de 2008

How to Specify a Gnome Workpace an Application will Launch in - LinuxQuestions.org

How to Specify a Gnome Workpace an Application will Launch in - LinuxQuestions.org

bobbrandt
LQ Newbie

Registered: Sep 2006
Posts: 14
How to Specify a Gnome Workpace an Application will Launch in


[Log in to get rid of this advertisement]
I know there is a similar thread in the Newbie section, but it is a year old and was never answered fully.

Basically I want to create a Desktop with two Workspaces for general office users. The main workspace will be the default one, but the second will be used for VMWare Player running a Windows VM or perhaps a RDP session to a terminal server (for all those apps which haven't quite made it to Linux yet.)

Getting the processes to run on startup is easy, the problem is I am unable to figure out how to force the apps to launch in the second workspace.

Any ideas?

Thanks
Bob
bobbrandt is offline
Tag This Post , ,
Reply With Quote
Old 05-23-2007, 09:26 AM #2
bobbrandt
LQ Newbie

Registered: Sep 2006
Posts: 14
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:
  1. Change the to the target Workspace
  2. Launch the target application
  3. Wait for that application to actually launch
  4. 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
bobbrandt is offline Reply With Quote
Old 12-24-2007, 01:36 PM #3
archtoad6
Senior Member

Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 2,948
devilspie:
http://www.burtonini.com/blog/computers/devilspie
http://ubuntu-tutorials.com/2007/07/...ects-in-gnome/
http://www.linux.com/feature/122471?theme=print [Added]
is definitely able to do this & it specifically targets windows being opened.

Unfortunately "the documentation is sparse" is an understatement.

If you find any evidence that devilspie can "see"/use PID's, please post back.


Edit: In case you aren't aware of it,
http://sweb.cz/tripie/utils/wmctrl/
is an excellent overview of wmctrl

Last edited by archtoad6 : 12-24-2007 at 02:10 PM. Reason: Add add'l links

Nenhum comentário: