You are not logged in.

#1 2021-02-19 02:30:08

kendew
Member
Registered: 2016-11-09
Posts: 41

Openbox autostart troubles

This one is especially for Openbox WM experts.  This is my Openbox autostart file:

picom --config ~/.config/picom.conf -b &
feh &
bgchd -dir /usr/share/wallpaper -bcknd feh -intv 11m &
plank &
fcitx5 &
nm-applet &
tint2 &
dunst &
gvfs &
udisks2 & 
udiskie &
volumeicon &
python3 /home/kendew/.config/openbox/minimize.py dino &

If I turn on my computer, reach the sddm login screen and login, everything works pretty much as desired.  However, if I exit Openbox (logout), the next time I login there are problems.  Everything eventually autostarts, but whereas autostart seems pretty much instantaneous when booting the computer and logging in, when I login after logging out (no reboot), plank in particular takes nearly a minute to load, and bgchd doesn't load for a couple of minutes, not really ideal. I wonder why.
I tried re-arranging the order of these apps, but the way they are ordered above is about the best I've found.
I'd like to know what I can do so they all load pretty much instantaneously like they do on computer startup.  But I'd also appreciate any other suggestions about load order, or any advantages to be had by introducing periods of sleep before loading some apps, or whatever.
I think most of the apps are self explanatory.  The bgchd is a script found in the aur to produce a desktop wallpaper slide show.  The python3 command runs a script to autostart Dino minimized to taskbar.
Thanks.

Offline

#2 2021-02-19 07:00:57

seth
Member
Registered: 2012-09-03
Posts: 49,992

Re: Openbox autostart troubles

after logging out

Login to a console and check what of your former session is still running.

Offline

#3 2021-02-20 20:35:20

kendew
Member
Registered: 2016-11-09
Posts: 41

Re: Openbox autostart troubles

Very interesting suggestion, seth!  After logging out and logging in to a console, pstree shows bgchd still active as a branch of systemd and bgchd is what is slowest of all  in getting started.  I must have had to enable it as a systemd service at some point.  Even so, not sure if this is relevant or what to do about it if it is...

Offline

#4 2021-02-20 20:59:59

seth
Member
Registered: 2012-09-03
Posts: 49,992

Re: Openbox autostart troubles

pgrep -u kendew bgchd || bgchd -dir /usr/share/wallpaper -bcknd feh -intv 11m &

or

pkill -u kendew bgchd; bgchd -dir /usr/share/wallpaper -bcknd feh -intv 11m &

?

Offline

#5 2021-02-22 00:37:51

kendew
Member
Registered: 2016-11-09
Posts: 41

Re: Openbox autostart troubles

Unfortunately those suggestions don't help, though they don't seem to hurt anything either.  I'm not attached to bgchd as a desktop wallpaper slideshow app.  I would just like something more minimalist than variety, for example.

Offline

#6 2021-02-22 05:11:39

duaner
Member
From: Oklahoma City
Registered: 2018-10-13
Posts: 35
Website

Re: Openbox autostart troubles

kendew wrote:

I would just like something more minimalist than variety, for example.

I just have a bash script change my background. It's definitely minimal. smile

#!/bin/bash
# ~/bin/change-background

export DISPLAY=:0

if ! /usr/bin/xset q &>/dev/null; then
  exit 0
fi

# It was just this:
#feh --bg-max "$(find ~/.local/backgrounds/ -type f | shuf -n 1)" &

# but I wanted a darker background:
PIC="$(/usr/bin/find ~/bin/python/art/pics/ -type f | /usr/bin/shuf -n 1)"
/usr/bin/convert &>/dev/null "$PIC" -fill black -colorize 80% ~/.cache/background.png

#/usr/bin/pcmanfm --wallpaper-mode fit -w ~/.cache/background.png

/usr/bin/feh --no-fehbg --bg-max ~/.cache/background.png

I run it from a systemd timer, but crontab would be easier.

Last edited by duaner (2021-02-22 05:14:48)

Offline

#7 2021-02-22 10:47:53

justasug
Member
Registered: 2014-08-03
Posts: 165

Re: Openbox autostart troubles

I have also had issues with programs started by Openbox's autostart script still running after the Openbox session ended. I switched to starting everything with systemd user services. Openbox's autostart has just a few lines, one of them is starting the desktop systemd target, to which all of the other background programs that I normally start with Openbox's autostart file are bound.

I know it's not a solution to your problem, but consider that approach if you don't find a suitable solution. Consult the Wiki about systemd user services or the official documentation.

Last edited by justasug (2021-02-22 10:48:45)

Offline

#8 2021-02-22 15:46:23

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 7,680
Website

Re: Openbox autostart troubles

duaner wrote:

I just have a bash script change my background. It's definitely minimal.

I take it you haven't noticed feh's --randomize option then?

duaner wrote:

I run it from a systemd timer, but crontab would be easier.

Even easier:

while true ; do feh --randomize --no-fehbg --bg-max /usr/share/wallpaper ; sleep 600 ; done &

But enough of this diversion...

kendew wrote:

when I login after logging out (no reboot), plank in particular takes nearly a minute to load, and bgchd doesn't load for a couple of minutes, not really ideal. I wonder why

Have you checked the X.Org log & the journal?

kendew wrote:

I'd also appreciate any other suggestions about load order, or any advantages to be had by introducing periods of sleep before loading some apps, or whatever

Are you sure all those ampersands are necessary? Run each command in a terminal and only add an ampersand in the autostart file if the prompt is not returned, this will help avoid any potential race conditions. I know for sure that picom shouldn't have both an ampersand and the -b option applied at the same time.

Applying sleep commands shouldn't be needed at all but you could look at using the XDG autostart specification instead of ~/.config/openbox/autostart (this needs the python-pyxdg package).

Offline

#9 2021-03-02 21:04:34

kendew
Member
Registered: 2016-11-09
Posts: 41

Re: Openbox autostart troubles

Great suggestions here!  I knew I came to the right place.
As for the ampersands, I was following the Arch man page for Openbox:

On log in, openbox  will  run
       the ~/.config/openbox/autostart.sh script if it exists,
       and will  run  the  system-wide  script  /etc/xdg/open‐
       box/autostart.sh  otherwise. You may place anything you
       want to run automatically in those files, for example:

              xsetroot -solid grey &
              gnome-settings-daemon &

       Make sure that each line is followed by a "&"  or  else
       the  script  will  stop there and further commands will
       not be executed.

I am experimenting with starting some of the services with XDG Autostart.  Plank seems to consistently work better with that.  I am not sure what other services I could use, as I want them limited to Openbox.  I also have LXQt installed where I do not want plank, picom or others opening, as with LXQt I am using kwin for compositing, and LXQt's own panel and desktop slideshow feature.  XDG Autostart gives me the option to limit autostart to Openbox.
I wonder if it would be an improvement to start them all with XDG?  It would mean creating a bunch of autostart files.
My wallpaper files were all created in GIMP at 1920x1080 for the particular monitor I use.  They are about 20 in number.  A script like Duaner uses would interest me as a possible improvement on the bkchd script I am using as it continues to be problematic.  Since I am not interested in background color, I wonder what the simplest possible script might be and how to set it up to run only in Openbox.

Offline

#10 2021-03-03 19:29:28

Head_on_a_Stick
Member
From: London
Registered: 2014-02-20
Posts: 7,680
Website

Re: Openbox autostart troubles

kendew wrote:

As for the ampersands, I was following the Arch man page for Openbox

In this case the man page is incorrect — adding ampersands where they are not needed can precipitate race conditions. An ampersand is only needed if the command does not return the prompt after it is run in a terminal.

Offline

#11 2021-03-04 00:06:53

manyroads
Member
From: off the edge...
Registered: 2019-12-09
Posts: 15
Website

Re: Openbox autostart troubles

@kendew FWIW: Like bunches of folks, I have tried to over-engineer any number of autostart functions.  Ultimately, my solution/decision is that simple is better.  For example, I use this dumb, utterly simple, command to initially set a wallpaper:

# wallpaper changer #####################
# currently using nitrogen (manually change)
feh --randomize --bg-fill $HOME/.wallpapers/active-wallpapers/* # inital wallpaper load

And I use a keybind to nitrogen when I feel like changing my wallpaper when logged in... But since I log in & out 'too much', I need not worry (very often) about such a huge manual effort.  I do the same with other functions...


Pax vobiscum,
Mark Rabideau - http://many-roads.com
spectrwm, i3, bspwm, dwm  ~ Reg. Linux User #449130
"For every complex problem there is an answer that is clear, simple, and wrong." H. L. Mencken

Offline

Board footer

Powered by FluxBB