View previous topic :: View next topic |
Author |
Message |
Camillus n00b
Joined: 13 Feb 2004 Posts: 24 Location: USA
|
Posted: Wed Mar 24, 2004 4:29 am Post subject: Openbox3: Run applications when window manager is started. |
|
|
Openbox3: Run applications when window manager is started.
Edit: changed to use .xsession file.
Based on Openbox 3.1-r1, assumes the use of bash shell for scripts.
By default when Openbox3 runs you are greeted with a blank screen, these steps will guide you through two methods of starting applications automatically when openbox starts.
General Notes
- If you use kdm follow method 1 and select openbox or Xsession in the kdm login session type. If X is started with the startx command go to method 2.
- Method 1 will work with xdm if the XSESSION variable in rc.conf is set to "openbox" or "Xsession".
Method 1 - kdm startup script.
If you use kdm these instructions will create a startup script, this script will be executed when openbox starts. At a terminal prompt create a new file (or edit it if it exists):
Copy the following code into the file, it will open an xterm window then start openbox. If there is existing text comment it out by placing a # in front of each line. Be certain to put the #!/bin/bash line first and note that any applications you launch before openbox should have the & after them!
Code: | #!/bin/bash
#
# Applications to run when X starts, probably shouldn't use with KDE or Gnome, they have their own autostart methods.
#
exec xterm &
exec openbox |
The following example is my startup file, it sets permission for xhost using a script, turns on numlock, sets the root window image and launches a few applications.
Code: | #!/bin/bash
#
# Applications to run when X starts, probably shouldn't use with KDE or Gnome, they have their own autostart methods.
#
exec ~/bin/set_xhost.sh
exec numlockx &
exec Esetroot -fit ~/themes/wallpaper/red_leaf.jpg
exec Eterm &
exec gkrellm2 &
exec pypanel &
exec openbox |
Save the file and exit the editor. Now change the permissions to make the file executable, at the prompt type:
Code: | chmod 755 ~/.xsession |
Now that the startup file has been created some modifications need to be made to run it when openbox starts. Switch to root:
Code: | su -
Password: (root password) |
First make a backup of the session file for open box just in case there's a problem:
Code: | cp /etc/X11/Sessions/openbox /etc/X11/Sessions/bak_openbox |
Now edit the session file for openbox:
Code: | nano -w /etc/X11/Sessions/openbox |
Change the contents to execute the .xsession file if it exists:
Code: | if [ -x ~/.xsession ]; then
~/.xsession
else
/usr/bin/openbox
fi |
Save the file and exit. Next time you start openbox your applications should run automatically!
Method 2 - Using the .xinitrc file with the startx command
If the startx command is used to start openbox do the following, from a terminal open your .xinitrc file.
For a basic file copy the following into the editor:
Code: | xterm &
exec openbox |
Save the file, other applications should be added before the line that starts openbox. Now use the startx command to run openbox.
Other search keywords: autostart
Last edited by Camillus on Fri Apr 16, 2004 3:51 am; edited 4 times in total |
|
Back to top |
|
|
BlindSpy Apprentice
Joined: 20 Mar 2004 Posts: 263
|
Posted: Wed Mar 24, 2004 1:30 pm Post subject: |
|
|
could you add something about how to remove kdm from the boot sequence and add openbox? |
|
Back to top |
|
|
TenPin Guru
Joined: 26 Aug 2002 Posts: 500 Location: Kansas City
|
Posted: Wed Mar 24, 2004 5:05 pm Post subject: |
|
|
My ~/.xinitrc
Code: |
xset m 1 2000
xset b off
xset r rate 250 40
xset +dpms
xset dpms 0 0 1200
xset s off
xmodmap -e "pointer = 1 6 3 2 4 5"
exec rxvt -g 90x22+0+14 &
exec rxvt -g 90x22+634+14 &
exec rxvt -g 90x22+0+319 &
exec rxvt -g 90x22+634+319 &
exec rxvt -g 90x24+0+624 &
exec rxvt -g 90x24+634+624 &
exec gkrellm2 &
exec bash -c "sleep 7;exec xmms" &
exec openbox
|
|
|
Back to top |
|
|
tactless l33t
Joined: 14 Jul 2002 Posts: 642 Location: Mitzpe Adi, Israel
|
Posted: Wed Mar 24, 2004 11:13 pm Post subject: |
|
|
A bit misleading... the applications begin loading before the window manager. This is a problem if you want to use gnome-panel's tasklist with Openbox. _________________ Tactless
"If it wasn't for fog, the world would run at a really crappy framerate."
Jabber: tactless@amessage.info |
|
Back to top |
|
|
M104 Tux's lil' helper
Joined: 13 Jan 2003 Posts: 132 Location: Riverside, CA
|
Posted: Thu Mar 25, 2004 7:03 am Post subject: |
|
|
If you want to delay execution of programs until after the WM has started, you can always change the syntax of your .xinitrc file, or whatever startup file you are using. Below is the poster's startup file with delayed execution:
Code: | #!/bin/bash
#
# Applications to run when X starts, probably shouldn't use with KDE or Gnome.
#
~/bin/set_xhost.sh
numlockx
Esetroot -fit ~/themes/wallpaper/red_leaf.jpg
(sleep 2 && pypanel) &
(sleep 3 && gkrellm2) &
(sleep 4 && Eterm) &
|
This particular setup staggers the programs to start one second apart, which has a nice "startup" feel to it, but you could have them all execute two seconds later, as well.
KDE has a better way of doing all of this, BTW, and I'm sure GNOME does too. _________________ "Pulling together is the aim of despotism and tyranny. Free men pull in all kinds of directions."
Terry Pratchett, The Truth |
|
Back to top |
|
|
gungholady Guru
Joined: 19 Oct 2003 Posts: 392
|
Posted: Tue Apr 13, 2004 5:43 pm Post subject: |
|
|
I tried your Method One instructions since I use gdm. I followed all the the instructions for Method One. Nothing gets loaded from the x_startup_script.sh. I even tried using with sleep as mentioned here in these posts. I'm using gnome 2.6. My only difference from what you have here is gnome-panel instead of pypanel since I want access to the gnome menu. I don't even get the background image that I specified unless I run nautilus. The x_startup_script.sh mentions something about ~/bin/set_xhost.sh but I don't have this file. What should be in this file? |
|
Back to top |
|
|
pathose Retired Dev
Joined: 08 Nov 2003 Posts: 35 Location: Ohio, USA
|
Posted: Wed Apr 14, 2004 3:06 am Post subject: |
|
|
This is the right idea but a bit misleading. THere are two circumstances: either you login at the console and issue `startx` or you have (x|g|k)dm set to manage your logins for you. As above, I'll break things town according to the two cases:
Case 1, startx:
When you run `startx`, it's runs a script that (among other things) starts X and executes a session script. It'll look for your ~/.xinitrc file as the script to run. If ~/.xinitrc does not exist, it will then run one of the session scripts found /etc/X11/Sessions/, as is set in your /etc/rc.conf file by the XSESSION variable. If this variable is not set, it'll load the default (Xsession) TWM with a couple xterms. So, you have some options as all of these are configurable. We'll start with the simple, general case and work backwards.
Simplest thing you can do is set your /etc/rc.conf file's XSESSION variable. This will effect all users no matter how they log in. It can be set to anything in /etc/X11/Sessions. Make sure you set it exactly (including case) because I think this variable is appended to the base path and the result is executed. The scripts in this dir are put there by the ebuilds as you emerge them, so mine currently has Gnome, Xsession, and openbox. If you want to build a custom session available to all users, you can write the script and add it to this directory. It will become accessable in all ways the other entries in this dir are (ie, XSESSION variable, on the "sessions" listing in gdm, etc.)
Alternatly, you can make a ~/.xinitrc file. This is a script that is run in place of /etc/X11/Sessions/[script]. It has exactly the same format as the scripts in /etc/X11/Sessions. The general idea here is that you'll want your default programs to run before the display manager, so if you want openbox and gdesklets, you'll have something like
Code: |
gdesklets &
openbox
|
There are some exceptions, such as was listed above about the gnome-panel task-list applet. Play around and post back here to let us know.
Case 2, (x|g|k)dm:
This is effectivly the same as above, it's just a matter of what files you edit. I don't use this method, so this info will be general. The only real difference from case 1 is that here ~/.Xsession is referenced instead of ~/.xinitrc. All the same rules apply.
Good luck and have fun! Don't forget to report back here with what works and what doesn't. |
|
Back to top |
|
|
Camillus n00b
Joined: 13 Feb 2004 Posts: 24 Location: USA
|
Posted: Thu Apr 15, 2004 1:42 am Post subject: |
|
|
I'm not sure what's misleading. . . I will admit that I am not an expert on X, if there are errors I will be happy to correct them but I certainly don't mean to deceive anyone. All I really want to be able to do is use kdm to login to any of several wms (because I'm easily bored) and have various apps start automatically.
My understanding is that if you are using kdm the XSESSION variable is ignored because the login manager allows you to choose the session to start. Maybe this is not true with gdm or xdm?
I have tried using the ~/.Xsession method with kdm and have never gotten it to work, identical to my .xinitrc file or not. Perhaps this is unique to kdm and it works with gdm or xdm (which I have never used)? Maybe it works if your XSESSION variable is set to the session you have selected in the login manager? Maybe my attempts were wrong or mis-configured. |
|
Back to top |
|
|
MagnusBerg Guru
Joined: 07 Oct 2003 Posts: 370 Location: Burgsvik, Gotland, Sweden
|
Posted: Thu Apr 15, 2004 3:44 pm Post subject: |
|
|
Camillus wrote: | I have tried using the ~/.Xsession method with kdm and have never gotten it to work, identical to my .xinitrc file or not. Perhaps this is unique to kdm and it works with gdm or xdm (which I have never used)? Maybe it works if your XSESSION variable is set to the session you have selected in the login manager? Maybe my attempts were wrong or mis-configured. |
Ha, ha I'm happy now! I have finaly found the solution. I tried and tried and tried but didn't got the .xsession (yes x not X) to work either.
I'm use FWVM and now I set XSESSION="Xsession" (yes X not x) in /etc/rc.conf. Before I had it to XSESSION="fvwm2" and that results in that the .xsession file wasn't read at X startup. It just start fvwm. Now the .xsession is read and the apps in it starts nice.
I must say I use Xdm as displaymanager but don't think it matter. Look in /etc/X11/Session and read the scripts to see that happed then you set XSESSION in /etc/rc.conf
This is my .xsession file
#!/bin/bash
exec thunderbird &
exec firefox &
exec gclipper &
exec fvwm2 |
|
Back to top |
|
|
pathose Retired Dev
Joined: 08 Nov 2003 Posts: 35 Location: Ohio, USA
|
Posted: Thu Apr 15, 2004 4:06 pm Post subject: |
|
|
Quote: | Ha, ha I'm happy now! I have finaly found the solution. |
Good deal. Glad to see someone worked it out. Quick, write a HOWTO or submit an entry for the gentoo handbook documenting what you've learned. |
|
Back to top |
|
|
Bonkie Guru
Joined: 28 Oct 2002 Posts: 501 Location: Antwerpen, Belgium
|
Posted: Thu Apr 15, 2004 5:08 pm Post subject: |
|
|
AFAIK you dont have to set anything special in /etc/rc.conf. "Xsession" is the default value of the XSESSION parameter so unless you have something else specified there (like I dont know flubox or openbox), you should leave it that way.
Then why isn't your .xsession read ??? Probably because it's not executable, just do a
and your Xsession shoud work fine now.
That's probably the main difference I can think of between .xinitrc and .xsession when creating them (yes, they are read in different situations but thats not the point). They can contain exactly the same, but .xsession has to be executable, while .xinitrc doesn't. _________________ "I would say we have a 50% chance of survival, but I consider myself an optimist so I'll give us 50,5% ..."
~ Arthur C. Clarke [Physics PHD,SF Writer], when asked about the chances of the human race's survival |
|
Back to top |
|
|
Camillus n00b
Joined: 13 Feb 2004 Posts: 24 Location: USA
|
Posted: Fri Apr 16, 2004 3:06 am Post subject: |
|
|
Edit: added .xinitrc to summary.
OK, I did some further investigation based on the post by MagnusBerg.
If you are using XDM the .xsession file will work, also as pointed out by Bonkie you can just leave the XSESSION variable uninitialized in rc.conf.
But. . . kdm still has a mind of it's own. It looks like it collects a list of sessions available, displays them in the list, when the session is selected it runs the session script located in /etc/X11/Sessions.
Looking at the Xsession script it: calls a startup script (~/.xsession), in that script file you place some apps to run in the background, then execute the window manager session. I'll change my instructions to reference the .xsession file (instead of creating my own).
In summary (I think):
- startx - XSESSION variable determines which session script to run, .xinitrc starts apps before wm.
- xdm - XSESSION determines which session to run
Note: If XSESSION is not set in rc.conf or set to "Xsession" the Xsession script is run which executes the ~/.xsession file.
- kdm - The selected session is executed from the script in /etc/X11/Sessions.
- gdm - ?
|
|
Back to top |
|
|
BinaryReality n00b
Joined: 08 Apr 2004 Posts: 7 Location: sweden
|
Posted: Mon May 03, 2004 10:25 pm Post subject: a question |
|
|
Hey!
Got it to work myself, but a question (wich may or may not be part of this topic) takes me to ask - how do I tell my programs to start at specific places on the desktop?
For example - I want aterm to start at bottom left corner of the screen, is this possible to do?
Same thing with xmms - top right.
I've been editing using version 2 of the helptext.
Thanks in advance
/Marcus |
|
Back to top |
|
|
pussi l33t
Joined: 08 May 2004 Posts: 727 Location: Finland
|
Posted: Tue Jun 01, 2004 9:12 pm Post subject: |
|
|
You can start aterm to bottom left corner with
Code: | aterm --geometry 80x24+0-0 |
but that should work only with aterm. ;) |
|
Back to top |
|
|
LAsk n00b
Joined: 02 Dec 2003 Posts: 32 Location: Avesta, Sweden
|
Posted: Thu Jun 03, 2004 11:23 pm Post subject: |
|
|
I've got a similar to BinaryReality's. Is it possible to specify on which workspace each application would start?
I'm using fluxbox btw. _________________ Many that live deserve death. And some that die deserve life. Can you give it to them? Then do not be too eager to deal out death in judgement.
- Tolkien |
|
Back to top |
|
|
R!tman Veteran
Joined: 18 Dec 2003 Posts: 1303 Location: Zurich, Switzerland
|
Posted: Sun Oct 16, 2005 7:21 pm Post subject: |
|
|
I know how to autostart things, but I would like gkrellm, 2 xterms and gaim to start on the first desktop, firefox on the second and thunderbird on the third.
Does anyone know how I can do that during autostart? |
|
Back to top |
|
|
ahubu Guru
Joined: 16 Aug 2003 Posts: 400 Location: Groningen, The Netherlands
|
Posted: Sun Nov 20, 2005 7:40 pm Post subject: |
|
|
R!tman wrote: | I know how to autostart things, but I would like gkrellm, 2 xterms and gaim to start on the first desktop, firefox on the second and thunderbird on the third.
Does anyone know how I can do that during autostart? |
I think you can make those start at different desktops by using te right syntax in the menu, but for autostarting an application in the right workspace something like devilspie is needed. It's in portage. I have not found a way yet (I use openbox3 for years now) to do this with plain openbox at startup. _________________ Anne // Light travels faster than sound. That's why people appear bright until
you hear them speak. -Unknown |
|
Back to top |
|
|
|