Auto Start an Application in a Different Virtual Desktop

Booting, installing, newbie
Post Reply
Message
Author
sazeile
Posts: 43
Joined: Thu 05 Jan 2006, 05:06

Auto Start an Application in a Different Virtual Desktop

#1 Post by sazeile »

I'm in the process of converting the in-laws from Windows to Puppy Linux. After getting over the "it's different" learning curve they really like it, especially the virtual desktops. "It's like having multiple computers". They also like the quick boot time and I'm looking forward to not spending my holidays chasing viruses.

To automatically start applications for them I created a shell script in /root/Startup with lines like:

nohup skype &

nohup pidgin &

nohup firefox &

It works fine but the desktop is crowded.

Is there a way to specify in which virtual desktop the app should start so that I can spread them out across the virtual desktops?

Thanks,

Steve

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#2 Post by disciple »

You can make a program always start on a particular desktop, which is not exactly what you're asking:
Look at the "Group" settings in http://joewing.net/programs/jwm/config.shtml
You'll want to edit ~/jwm/jwmrc-personal
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

sazeile
Posts: 43
Joined: Thu 05 Jan 2006, 05:06

Background Type of "Command" sort of works

#3 Post by sazeile »

Disciple,

Thanks for the reply.

You're right, it's not quite what I'm looking for.

I also discovered in desktops that you can specify a different background for each desktop. If I set the background type to "command" and then specify the app that I want then that app will start when I go to that desktop.

What is doesn't do is auto start that app on that desktop without going to that desktop.

However, I think that will be good enough.

Thanks again,

Steve Z.

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#4 Post by disciple »

A clever misuse of that feature :)
You should suggest in the JWM improvement thread a feature to have separate startup commands for each desktop http://www.murga-linux.com/puppy/viewto ... 081#379081

There is probably a "better" way to do what you want, but you can do it by inserting lines in your startup script that switch between the desktops by using xte, (which might actually be included in Puppy now, I can't remember) to send whatever keystrokes are bound in your JWM configuration for desktop switching. If you do this I imagine you'll see the screen flicker briefly at startup while it cycles through the desktops.
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

sazeile
Posts: 43
Joined: Thu 05 Jan 2006, 05:06

Xte Worked!

#5 Post by sazeile »

Disciple,

Turns out there was a minor problem with my "clever misuse".
Everytime you go to a desktop with a background="command" that command gets executed.

I was able to set up a function key to toggle between desktops and then I used xte in my startup script and it did the trick.

Thanks for the link to xte. It isn't in 4.3.1.

I had to add some "sleep" steps to allow the apps to get started before toggling to the next desktop.
Otherwise the app will land on the next desktop if it hasn't had time to get started.

I wasn't able to figure out how to use the "desktop#" key action to go to a specific desktop.
That would be better then toggling through all of the desktops.

Do you know what Joe means by:

desktop# Key to switch to a specific desktop. To use this, # must be specified in the key section.
Then numbers from 1 to the number of desktops configured are substituted for #.

I tried:

<Key key="F1">desktop#</Key>
<Key key="F2">desktop#</Key>
<Key key="F3">desktop#</Key>
<Key key="F4">desktop#</Key>

No errors on "jwm -p" but all four keys just toggle to the next desktop instead of going to a specific desktop.

Thanks,

Steve Z.

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#6 Post by disciple »

Hmmm.
I've never tried it before - it isn't actually what I thought. The default Puppy configuration includes

Code: Select all

<Key mask="A" key="#">desktop#</Key>
If I hold down "Alt" and press "#" ("Shift" + "3" on my keyboard) then "2" it switches to desktop 2. That might not be as useful as what I thought it was. Maybe another feature suggestion is in order... and some rewording of the documentation :)
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

sazeile
Posts: 43
Joined: Thu 05 Jan 2006, 05:06

Xte can now change to a specific virtual desktop

#7 Post by sazeile »

Disciple,

Thanks for the explanation.

I now have a startup script that looks like:

Code: Select all

# Switch to desktop 2
xte "keydown Alt_L"  "keydown #" "key 2" "keyup Alt_L" "keyup #"
# Start Firefox at Google
/root/firefox/firefox  -new-window 'www.google.com'   &
# Wait for Firefox and Internet Connection to get started
sleep 10
# Switch to desktop 3
xte "keydown Alt_L"  "keydown #" "key 3" "keyup Alt_L" "keyup #"
# Start AOL
/root/firefox/firefox  -new-window 'www.aol.com'  &
sleep 5
# Switch to desktop 1
xte "keydown Alt_L"  "keydown #" "key 1" "keyup Alt_L" "keyup #"
While it does the trick, there's a bit of flashing. I'll leave a suggested improvement for JWM to allow the "StartupCommand" to be run within "Desktop". No doubt a lot easier to suggest than implement.

Thanks again,

Steve Z.

User avatar
DanYHKim
Posts: 103
Joined: Mon 15 Sep 2008, 01:51

Switching a virtual desktop

#8 Post by DanYHKim »

I haven't done this. I was just looking for clues about using VMware Tools. On a page about setting up VMware Tools, there are some instructions found at "Step Six" of the list showing a script that invokes the XVKBD virtual keyboard to switch desktops.

Someone smarter than me will have to look at it and see if it makes sense.

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#9 Post by disciple »

Alternatively if you don't mind a program always starting on a particular desktop (not just at when jwm starts) you could use groups in the jwm config to make them do that.
Always start Firefox maximized on the second desktop:2 and without a title bar

Code: Select all

<Group>
  <Class>Firefox</Class>
    <Option>maximized</Option>
    <Option>desktop:2</Option>
    <Option>notitle</Option>
</Group>
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#10 Post by disciple »

If you do mind it always applying, you might find a better solution using wmctrl or devilspie or something...
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#11 Post by disciple »

Ah, a slightly better approach would be to just open the programs on whatever desktop you are on, then use the tiny xdotool to move them to the right desktop e.g.

Code: Select all

 xcalc & ./xdotool set_desktop_for_window `./xdotool search --class xcalc` 1
Note that the first desktop is 0, not 1.

xdotool is included in the pastecolour http://www.murga-linux.com/puppy/viewtopic.php?t=45477 and pastelist http://www.murga-linux.com/puppy/viewtopic.php?t=45327 packages.
You can get documentation here http://www.semicomplete.com/projects/xdotool/xdotool
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

sazeile
Posts: 43
Joined: Thu 05 Jan 2006, 05:06

Xdotool Works and It Makes it Faster

#12 Post by sazeile »

Disciple,

The xdotool makes sending it to another desktop easier and it provided me a way to know when the application has launched and can then be moved.

Here's the code that I added to my startup.sh script in /root/Startup

Code: Select all

#Ping Google
ping -c1 www.google.com >& /dev/ping_google.txt
cat /dev/ping_google.txt |
			awk ' BEGIN {connection=0}
			$0 ~ /1 packets received/{connection=1}
			END {print connection}' > /dev/ping_google_ind.txt
#Wait for Google Ping to Suceed
while [ `cat /dev/ping_google_ind.txt` -ne 1 ]
do
ping -c1 www.google.com  >& /dev/ping_google.txt
cat /dev/ping_google.txt |
			awk ' BEGIN {connection=0}
			$0 ~ /1 packets received/{connection=1}
			END {print connection}' > /dev/ping_google_ind.txt
done
# Start Firefox at Google
/root/firefox/firefox  -new-window 'www.google.com'   &
#Wait for Google Window to be Created
while [`xdotool search --title google` = ""]
do
sleep 0.001 #Recheck Quickly
done
#Send Google Window to Desktop 1
xdotool set_desktop_for_window `xdotool search --title google` 1 

#Ping Yahoo
ping -c1 www.yahoo.com >& /dev/ping_yahoo.txt
cat /dev/ping_yahoo.txt |
			awk ' BEGIN {connection=0}
			$0 ~ /1 packets received/{connection=1}
			END {print connection}' > /dev/ping_yahoo_ind.txt
#Wait for Yahoo Ping to Suceed
while [ `cat /dev/ping_yahoo_ind.txt` -ne 1 ]
do
ping -c1 www.yahoo.com >& /dev/ping_yahoo.txt
cat /dev/ping_yahoo.txt |
			awk ' BEGIN {connection=0}
			$0 ~ /1 packets received/{connection=1}
			END {print connection}' > /dev/ping_yahoo_ind.txt
done &&
#Start Firefox at Yahoo
/root/firefox/firefox  -new-window 'www.yahoo.com'   &
#Wait for Yahoo Window to be Created
while [`xdotool search --title yahoo` = ""]
do
sleep 0.001 #Recheck Quickly
done
#Send Yahoo Window to Desktop 2
xdotool set_desktop_for_window `xdotool search --title yahoo` 2
It waits for Google and Yahoo to be connected before launch.

Thanks!

Steve Z.

Post Reply