You are not logged in.

#1 2022-06-04 01:28:42

zw
Member
Registered: 2022-05-31
Posts: 19

[SOLVED] Condition Openbox autostart file on which session I am in

I recently installed Arch Linux with the LXQt desktop environment using the archinstall script.

Depending on the task, I sometimes use a pure Openbox session instead of the full desktop environment.

For pure Openbox sessions, I have conky and nitrogen in my ~/.config/openbox/autostart file:

# Conky (to display clock and date)
conky -c ~/.config/conkyrc &

# Wallpaper
sleep 2
while true; do
    nitrogen --random --set-auto
    sleep 3600
done

I've noticed that LXQt also runs these commands when I log into an LXQt session (because LXQt's window manager is Openbox). However, these settings are superfluous in LXQt sessions because it has a clock in the menubar and its own wallpaper manager.

How can I set the autostart commands above to run only in pure Openbox sessions, and not in LXQt sessions?

I found a similar discussion concerning the Openbox rc.xml file on the LXQt Github here: https://github.com/lxqt/lxqt/issues/1002

There, it was suggested that LXQt should favor ~/.config/openbox/lxqt-rc.xml over ~/.config/openbox/rc.xml if both files exist. If a similar policy exists for the autostart file, that would solve my issue, but I can't see any mention of it.

Thank you in advance.

Last edited by zw (2022-06-04 13:11:15)

Offline

#2 2022-06-04 01:54:57

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,480
Website

Re: [SOLVED] Condition Openbox autostart file on which session I am in

Just rename the file and run openbox with the --startup flag with the new file as an argument.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#3 2022-06-04 03:01:19

zw
Member
Registered: 2022-05-31
Posts: 19

Re: [SOLVED] Condition Openbox autostart file on which session I am in

Trilby wrote:

Just rename the file and run openbox with the --startup flag with the new file as an argument.

Thank you. How do I get this to happen when I select an Openbox session from the sddm login screen? It seems like I need to modify /usr/share/xsessions/openbox.desktop, which currently reads

[Desktop Entry]
Name=Openbox
Comment=Log in using the Openbox window manager (without a session manager)
Exec=/usr/bin/openbox-session
TryExec=/usr/bin/openbox-session
Icon=openbox
Type=Application

But notice that the command invoked here is openbox-session rather than plain openbox. I tried modifying the Exec line to read

Exec='/usr/bin/openbox --session /home/zw/.config/openbox/pure-openbox-autostart.sh'

but attempting to login produces an error (it drops momentarily to a CLI then puts me back at the sddm prompt).

Offline

#4 2022-06-04 05:56:00

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,573

Re: [SOLVED] Condition Openbox autostart file on which session I am in

Compare

printenv | grep -iE '(XDG|desktop)'

- lxqt probably sets an evironment variable you could test for.

Offline

#5 2022-06-04 12:22:52

zw
Member
Registered: 2022-05-31
Posts: 19

Re: [SOLVED] Condition Openbox autostart file on which session I am in

seth wrote:

Compare

printenv | grep -iE '(XDG|desktop)'

- lxqt probably sets an evironment variable you could test for.

Thanks, this ended up being the easiest solution:

if [[ $DESKTOP_SESSION -eq 'openbox' ]]; then
    # Conky (clock and date)
    conky -c ~/.config/conkyrc &

    # Wallpaper
    while true; do
        nitrogen --random --set-auto
        sleep 3600
    done
fi

(In the LXQt session, DESKTOP_SESSION is set to 'lxqt'.)

Offline

#6 2022-06-04 12:35:02

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,648

Re: [SOLVED] Condition Openbox autostart file on which session I am in

Please remember to mark your thread [SOLVED] (edit the title of your first post).

Offline

#7 2022-06-04 12:47:11

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,480
Website

Re: [SOLVED] Condition Openbox autostart file on which session I am in

My suggestion was to change how you run openbox.  Leave LXQT to do whatever it does (which includes reading the "default" autostart file, which would be emtpy).  As I said, rename your current autostart file to something else.  The run openbox - when you want just openbox, with the --startup flag to select the newly named autostart file - I assume this call to openbox would be in your xinitrc.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#8 2022-06-04 14:37:38

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,573

Re: [SOLVED] Condition Openbox autostart file on which session I am in

Trilby wrote:

I assume this call to openbox would be in your xinitrc.

zw wrote:

How do I get this to happen when I select an Openbox session from the sddm login screen?

But notice that the command invoked here is openbox-session rather than plain openbox. I tried modifying the Exec line

openbox-session runs

exec /usr/bin/openbox --startup "/usr/lib/openbox/openbox-autostart OPENBOX" "$@"

/usr/lib/openbox/openbox-autostart then draws ${XDG_CONFIG_HOME:-"$HOME/.config"}/openbox/autostart

I'm not sure how lxqt ends up running the autostart scripts unless it starts openbox-session instead of just openbox and in that case you'd have to derive the xsession to run some "openbox-session2" and split the behavior there.
Making the autostart scripts context aware is probably easier.

Offline

Board footer

Powered by FluxBB