1

I'm configuring my i3 window manager (version 4) and sometimes I think the auto-start using its native exec or exec_all fail. (*)

So I decided to create a i3_autostart.sh script to add all the stuff I need in a single organized place. Much like KDE or GNOME have their own folders to do that.

The script is called from ~/.config/i3/config with the following line (**):

exec_always --no-startup-id /home/beco/.config/i3/i3_autostart.sh

Then enters the Autostart script that basically just calls a function that runs each program I want to auto start. This is an example:

Autostart()
{
    # why, o my?
    sleep 1

    # set keyboard bindings
    xkbcomp -w 0 /home/beco/.config/xkbmap_kde $DISPLAY

    # toggle touchpad
    /home/beco/bin/touchpad off 

    # set wallpaper
    feh --bg-scale /home/beco/Pictures/wallpaper/Stonehenge-Desktop-Wallpaper-i3help.png

    # clipboard
    parcellite

    # network manager
    nm-tray

    # why, o my?
    sleep 1

}

All programs start just fine except nm-tray. I've tried several command combinations and techniques to no avail.

From what I'm seeing, the problem is that nm-tray likes to run foreground, but needs to run background, and as far as I can tell it have no option to set that in the command line. So we need to use bash facilities.

Here my attempts:

  1. simple background
    # network manager
    nm-tray &
  1. trying to disown
    # network manager
    nm-tray &>/dev/null &
    disown $!
  1. nohup and disown
    # network manager
    nohup nm-tray &>/dev/null &
    disown $!

I even tried to let the whole autostart script in background, just to be sure nm-tray kept running with: exec_always --no-startup-id /home/beco/.config/i3/i3_autostart.sh &>/dev/null &

I see the clipboard icon, the keyboard icon. Touchpad is set to off. But the nm-tray icon insists in not working.

Any suggestions? Thanks.

@drbeco


(*) I've read some bug reports, but this question is not about solving that issue. It is simply to create a good workaround that I can rely on, while the issue continues.

(**) This line with exec_always have never failed to start, so I'm good with it.

  • 1
    I had only 465 points when I started this bounty of 50 points (losing 12% of my points), so please understand that I'll be picky with the answer. – Dr Beco Oct 7 '19 at 18:11
  • Can you add some debug code and post the exit status of nm_tray as well as any stderr/stdout from that command (perhaps just redirect these to a file) from the script context that your are invoking that command? – 111--- Oct 11 '19 at 17:38
  • I'll try that later today. Thanks for the interest. – Dr Beco Oct 13 '19 at 0:24
  • Are you using systemd? If yes, have you tried to add nm_tray as a service? – McSinyx Oct 13 '19 at 9:09
  • yes, systemd here. That may be an option. Thanks. BTW: without systemd, linux also have the option to start scripts as service/daemons. Systemd is irrelevant. But thanks – Dr Beco Oct 14 '19 at 23:55
1

The only programs that deny to run in background (or do not work then) are programs that need terminals.
Your problem is that nm-tray is not run at all because You did not start parcellite in the background.
So just add the ampersand to the end of that two lines (and others if You start other long-running/persistent programs that do not detach themselves, but I think currently there are none in Your above list) and add a disown at end of script to not let the script hang around there waiting for the programs to finish.


Try with this block instead of Your above example:

Autostart()
{
    # why, o my?
    sleep 1

    # set keyboard bindings
    xkbcomp -w 0 /home/beco/.config/xkbmap_kde $DISPLAY

    # toggle touchpad
    /home/beco/bin/touchpad off 

    # set wallpaper
    feh --bg-scale /home/beco/Pictures/wallpaper/Stonehenge-Desktop-Wallpaper-i3help.png

    # clipboard
    parcellite &

    # network manager
    nm-tray &

    # detach the started background programs
    disown
    # why, o my?
    #sleep 1

}
| improve this answer | |
  • Somehow what you wrote should work. It's been a few days now that I'm in the middle of another task and haven't had the time to check, but if my memory doesn't fail, I tried & on some lines. What exactly is the lines you are talking about? My question is long and show many examples. Care to add the lines on your answer? Thanks – Dr Beco Oct 14 '19 at 23:58
  • OK I added block how it would work. You have to background all the programs that keep running. In addition You can do the same for programs that run for some time before if it is not needed they are finished before the next one starts. But I thinks all the others only run vey short - and You told everything works fine including parcellite. So problem is that parcellite is not returning control back to script so You have to run in background. – EOhm Oct 15 '19 at 5:21
  • Sounds good. I'm gonna test it. – Dr Beco Oct 19 '19 at 19:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.