SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2010-05-26 05:25:34

johnraff
nullglob
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 3,266
Website

Sessions and autostart - couple of ideas

There are a couple of FIXME's in the xfce statler autostart.sh file, one of them in the openbox version too, and I thought I'd poke around a bit and try and see where some of that stuff was coming from. A couple of tentative suggestions follow, along with some unsolved problems and vague ideas for hacking and tweaking...

starting up the desktop: what happens between the gdm login screen and getting a working desktop, xfce in particular. Please post corrections if I've got anything wrong or left anything out!
* X (needed for a graphic environment) is already running at this point.
* /usr/share/xsessions contains a .desktop file for each session type available on the computer (and maybe some that aren't roll ) and gdm shows those sessions in its "sessions" menu. (xfce, lxde, gnome, kde...) The chosen session's file has a line 'Exec=somecommand' and gdm runs that command (eg startxfce4, startlxde, openbox-session...).
* If you have a look at /usr/bin/startxfce4 the main thing it does is call the user's ~/.config/xfce4/xinitrc if it exists, or the system-wide /etc/xdg/xfce4/xinitrc .
* The xfce xinitrc in turn sets a few environment variables, launches xscreensaver, etc etc, then starts xfce4-session, where most of the startup work is done - window manager, panel etc are started up here.
* The applications needed for an xfce4 session are defined in /etc/xdg/xfce4/xconf/xfce-perchannel-xml/xfce4-session.xml, but can be overwritten by the user's ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-session.xml if it contains any data.
* More apps - more likely the ones added by the user - are started up from the .desktop files in /etc/xdg/autostart and ~/.config/autostart . (Other desktop environments like lxde will check those autostart folders too.)
* One of those .desktop files also runs CrunchBang's ~/.config/xfce4/autostart.sh script, where more processes can be started up, events run...

...phew... roll

OK the xscreensaver FIXME: possibly unlike gnome-screensaver, the xscreensaver daemon needs to be started up by the user. In xfce this is done in the xinitrc file, but with an openbox session it has to be done in autostart.sh so for #! Statler-Openbox I don't think there's anything to fix... smile
With Statler-Xfce out of the box, though, gdm seems to be invoking the "default" session by, er, default, which means, I think, running startx, which, although it does most of the needed stuff in xfce's xinitrc, doesn't start xscreensaver. To get that you need to run startxfce4 by selecting the "xfce session" in gdm. If the user does that everything is fixed, but you can get it as the default session on first boot by adding the line

DefaultSession=xfce.desktop

to /etc/gdm/gdm.conf , under

[daemon]

The xfce4-panel FIXME: agreed it seems messy to let xfce4-panel be started up, then kill it so you can run tint2. You can stop xfce4-panel from being run by editing one of those xfce4-session.xml files. Perhaps it's safer to leave the system file alone and do it for each user, something like:

cp  ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-session.xml ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-session.xml.bak # this file is almost empty
cp /etc/xdg/xfce4/xconf/xfce-perchannel-xml/xfce4-session.xml ~/.config/xfce4/xfconf/xfce-perchannel-xml/
gedit ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-session.xml

This is an xml file: these are fragile, so be careful! Find the section

      <property name="Client1_Command" type="array">
        <value type="string" value="xfce4-panel"/>
      </property>
      <property name="Client1_PerScreen" type="bool" value="false"/>

and delete it. Now edit

      <property name="Count" type="int" value="5"/>

to read 4 not 5, now (carefully) go over all the other entries and renumber them because Client1 is missing. With any luck, xfce4-panel will no longer be started up.

A much easier way to do this is just to replace "xfce4-panel" with "tint2" - now tint2 will automatically be started up for you and you can take it out of autostart.sh smile

Not so fast... if a user ever chooses the "save session" option tint2 will be lost. sad I don't know why, but for some reason xfce4-session doesn't seem to recognise the tint2 process when closing down, so there's no alternative to starting it up in autostart.sh, or possibly the autostart folders.

multiple conkys: "Save session" works only too well with conky though. Every time you shut down with that option a new conky will be added to your session, one from autostart.sh and others saved in a file in ~/.cache/sessions from the previous session. If you try to start conky from xfce4-session.xml it seems to work OK until you try to "save session"... aaah... I can't think of any way to get rid of these multiple conkys - maybe some kind of wrapper script that checks if it's already running or not?

openbox as window manager: Better news: it is possible to replace "xfwm4" with "openbox" in xfce4-session.xml and the system won't turn a hair. You'll have an xfce session with openbox as window manager and pretty much everything seems to work! This could be fun to play with smile

other ramblings...
* How about a startcrunchbang script some day, and a .desktop file in /usr/share/xsessions ie a CrunchBang desktop environment? Any point? Maybe not.
* Hybrid systems, mixing bits of xfce and lxde using either xfce4-session or lxsession - xfbang and lxbang... ??
* If you've got lxsession, have a look at /usr/share/doc/lxsession/README.gz - an explanation of the startup process, and ideas for customization.

Anyway, some ideas. smile

Last edited by johnraff (2010-05-26 16:49:29)


John     Please help us keep your forums manageable.
--------------------
( a boring Japan blog , idle twitterings  and GitStuff )
#! forum moderator

Online

Help fund CrunchBang, donate to the project!

#2 2010-05-26 05:50:31

73ChargerFan
#! Member
From: California
Registered: 2010-01-02
Posts: 91

Re: Sessions and autostart - couple of ideas

pgrep conky will test if conky is running.

#!/bin/bash
if [ ! `pgrep conky` ]; then
    conky &
fi

Last edited by 73ChargerFan (2010-05-26 06:02:10)

Offline

#3 2010-05-26 06:40:45

corenominal
WRONG
From: Lincoln, UK
Registered: 2008-11-20
Posts: 5,081
Website

Re: Sessions and autostart - couple of ideas

@johnraff, nice work! I left those FIXMEs in the config files as they are basically my own ugly hacks and I wanted to know if anyone could come up with better solutions. I think there is definitely room for improving the session start-up scripts and I am open to ideas. It is good to see someone beginning to tackle these. smile

@73ChargerFan, that should work fine, thanks. smile


Ex-developer of #! CrunchBang. Follow me on Twitter smile

Offline

#4 2010-05-26 16:57:10

johnraff
nullglob
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 3,266
Website

Re: Sessions and autostart - couple of ideas

73ChargerFan wrote:

pgrep conky will test if conky is running.

#!/bin/bash
if [ ! `pgrep conky` ]; then
    conky &
fi

This will be a good check, as long as the autostart.sh file is run after the cached session file. If it comes before, the session manager will add the unneeded conkys after it's been started by the script. Some more poking about needed, maybe we can find out...
Also, what if the user has more than one conky running, with different config files? (I have 4 right now)

Last edited by johnraff (2010-05-26 17:00:30)


John     Please help us keep your forums manageable.
--------------------
( a boring Japan blog , idle twitterings  and GitStuff )
#! forum moderator

Online

#5 2010-05-26 19:32:31

73ChargerFan
#! Member
From: California
Registered: 2010-01-02
Posts: 91

Re: Sessions and autostart - couple of ideas

(sleep 30 && if [ ! `pgrep conky` ]; then conky& fi) &

should delay starting conky by 30 seconds.  Not tested.

Offline

#6 2010-05-27 04:12:50

johnraff
nullglob
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 3,266
Website

Re: Sessions and autostart - couple of ideas

^Ah yes! That ought to work. Kind of busy the next few days, but I'll play around with this stuff some more next week or so...


John     Please help us keep your forums manageable.
--------------------
( a boring Japan blog , idle twitterings  and GitStuff )
#! forum moderator

Online

#7 2010-06-22 01:28:24

corenominal
WRONG
From: Lincoln, UK
Registered: 2008-11-20
Posts: 5,081
Website

Re: Sessions and autostart - couple of ideas

johnraff wrote:
73ChargerFan wrote:

pgrep conky will test if conky is running.

#!/bin/bash
if [ ! `pgrep conky` ]; then
    conky &
fi

This will be a good check, as long as the autostart.sh file is run after the cached session file. If it comes before, the session manager will add the unneeded conkys after it's been started by the script. Some more poking about needed, maybe we can find out...
Also, what if the user has more than one conky running, with different config files? (I have 4 right now)

I had a play with this earlier today and I came up with:

## Condition: Start Conky after a slight delay
if ! egrep -iqR 'conky' ~/.cache/sessions; then
    (sleep 3s && conky -q) &
fi

Basically it checks Xfce's session/saved state files for instances of 'conky' and if it does not find any, it will start Conky. I have tested it and it seems to sort out the problem of having multiple Conky instances. smile


Ex-developer of #! CrunchBang. Follow me on Twitter smile

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo