this post was submitted on 21 Mar 2024
79 points (95.4% liked)

Linux

48287 readers
627 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS
 

in my config file exists...

exec-once = zsh -c 'sleep 1' && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar && waybar

Why? Because waybar crashes sometimes when I turn my monitor off/on, I documented this here: https://github.com/Alexays/Waybar/issues/3047

...this opens waybar if it crashes... and if that crashes, it opens another waybar, and you'll notice, if that one crashes, it opens another one... now you may have seen the pattern here but in case you didn't, that one will then lead to another waybar...

Is there a less ridiculous way of making waybar open every time when waybar crashes, giving me better fault tolerance?

all 20 comments
sorted by: hot top controversial new old
[–] Shadow@lemmy.ca 67 points 8 months ago (2 children)

while true; do waybar; done

[–] Communist@lemmy.ml 8 points 8 months ago
[–] dgriffith@aussie.zone 6 points 8 months ago
[–] NegativeLookBehind@lemmy.world 50 points 8 months ago

I think OPs solution is fucking hilarious

[–] communism@lemmy.ml 43 points 8 months ago (1 children)

Ok firstly that's hilarious. Secondly I'm pretty sure && means "execute the second thing if the first thing exits with code 0" so if waybar is segfaulting it shouldn't execute any of the other waybars; if you were to do it this way (while true or a systemd service as suggested in the comments makes more sense) a semicolon would probably make sense?

[–] Communist@lemmy.ml 21 points 8 months ago (1 children)

Yeah I noticed it wasn't actually working and for some reason assumed that it was because it crashed so many times that I ran out of waybars, so I added a million after that, and you're totally right, I know better than that, thanks!

[–] just_another_person@lemmy.world 42 points 8 months ago (1 children)

Just make a user systemd unit if one doesn't already exist, set to relaunch on failure, then all set.

[–] hallettj@leminal.space 32 points 8 months ago

I would install a systemd user service with the setting Restart=always. If your window manager is started with systemd, or defines a systemd target you can configure the waybar service to start and stop automatically with the window manager.

[–] x3i@kbin.social 20 points 8 months ago

Same problem here, this is my solution:

exec-once = bash -c 'until waybar; do echo "Waybar crashed with exit code $?.  Respawning..." >&2; done'

[–] mvirts@lemmy.world 20 points 8 months ago (1 children)

I thought && only proceeded to the next statement if the first did not crash

[–] Shadow@lemmy.ca 6 points 8 months ago (1 children)

I guess waybar still returns 0 on segfault. Seems weird.

[–] Communist@lemmy.ml 7 points 8 months ago (1 children)

Nah I just noticed it crashed anyway and didn't assume it was a flaw in my methodology but rather that i ran out of waybars queue'd

[–] Shadow@lemmy.ca 5 points 8 months ago

Yeah you would need to use a ; instead of &&

[–] sekhat@lemmy.temporus.me 18 points 8 months ago

Just do an infinite loop

exec_once = zsh -c 'while true; do waybar; done'

[–] d3Xt3r@lemmy.nz 17 points 8 months ago* (last edited 8 months ago) (1 children)

Have you tried using the latest git version of Waybar? They fixed a segfault a few days ago which might be the same one you're facing.

[–] Communist@lemmy.ml 8 points 8 months ago

...that does indeed look very similar, but my solution makes it so that if waybar crashes it doesn't even matter, which I quite like, even if the segfault has been fixed.

[–] neurospice@lemmy.dbzer0.com 17 points 8 months ago

This is so ridiculous, I fucking love it. I just have waybar bound to a hotkey, but this solution is truly amazing

[–] SeeJayEmm@lemmy.procrastinati.org 15 points 8 months ago

What about a while loop?