this post was submitted on 07 Mar 2025
5 points (85.7% liked)

i3 Window Manager

309 readers
1 users here now

About

Community for the i3 window manager and its popular fork i3-gaps.

Resources

founded 4 years ago
MODERATORS
 

I've been having problems with nm-applet that crashes on a regular basis lately. Apparently I'm not the only one, but it's not often enough to do anything about it apart form restarting it when it drops off the system tray.

I got tired of doing it by hand, so I got i3 to do it for me of course ๐Ÿ™‚

If you too need to start a program at login and keep restarting it if it stops, you might find this little trick useful:

In case you didn't know, exec and exec_always in the i3 config file don't directly call an executable, but rather execute the command in a shell. So naturally, you can run an inline shell script rather than a single command.

So in my case, instead of this line in my i3 config file:

exec --no-startup-id nm-applet

I have this line:

exec --no-startup-id while [ 1 ]; do nm-applet; sleep 0.2; done

The latter is a one-liner equivalent of running the following shell script inside the shell that i3 calls to run the argument of exec:

while [ 1 ]; do
  nm-applet
  sleep 0.2
done

This script will run nm-applet in a loop forever. The sleep delay is just there to throttle the script and avoid killing the CPU if nm-applet fails to start altogether for some reason.

no comments (yet)
sorted by: hot top controversial new old
there doesn't seem to be anything here