francma / wob

A lightweight overlay volume/backlight/progress/anything bar for Wayland.
ISC License
911 stars 50 forks source link

Wob issues through multiple sway sessions #3

Closed krathalan closed 4 years ago

krathalan commented 5 years ago

When executing sway from a TTY and exiting Sway more than once without logging out, wob doesn't work on sway sessions launched after the first one.

I had to add rm -f /tmp/wobpipe && ... to my swaynag/swaymsg exit keybind. That fixed the issue but there were still tail and wob processes, so I had to add pkill wob && pkill tail && ... to the command as well. So my exit keybind now looks like:

bindsym $mod+Shift+e exec --no-startup-id swaynag -t warning -m 'Do you really want to exit sway?' -b 'Yes, exit sway' 'rm -f /tmp/wobpipe && pkill wob && pkill tail && swaymsg exit'

I'm not sure if this is something you could fix programmatically within wob. I notice this issue as well with redshift so I have to add pkill redshift to the exit command as well.

krathalan commented 5 years ago

So after coming out of hibernation for some reason sway doesn't like my long .. && swaymsg exit command. It's probably best to run sway out of ~/.bash_profile and add rm -f /tmp/wobpipe to ~/.bash_profile before exec sway is called.

StephenCoady commented 5 years ago

@krathalan are the suggestions for running wob in the readme working for you at all? For me I can't run exec mkfifo as it already exists so fails. If I create it manually and run wob through my config with the tail commands I can't show wob at all.

Any suggestions or could you share your sway config?

francma commented 5 years ago

@StephenCoady Can you try it like this?

exec rm -f /tmp/wobpipe && mkfifo /tmp/wobpipe && tail -f /tmp/wobpipe | wob
StephenCoady commented 5 years ago

@francma yes I've tried that and it doesn't seem to work either. Weird thing though - if I run sway -d 2> ~/sway.log from within an existing sway session then wob appears normally in that debug window.

francma commented 5 years ago

And like this?

exec sleep 5 && rm -f /tmp/wobpipe && mkfifo /tmp/wobpipe && tail -f /tmp/wobpipe | wob

I noticed that there is sometimes some weird race condition where wob starts before sway is ready.

StephenCoady commented 5 years ago

Still nothing. Its weird because if I start it from a terminal it works perfectly.

krathalan commented 5 years ago

@StephenCoady here are the relevant lines in my sway config:

bindsym XF86AudioRaiseVolume exec --no-startup-id pamixer -i 5 && pamixer --get-volume > /tmp/wobpipe
bindsym XF86AudioLowerVolume exec --no-startup-id pamixer -d 5 && pamixer --get-volume > /tmp/wobpipe
...
bindsym XF86MonBrightnessUp exec --no-startup-id light -A 2 && light -G | cut -d'.' -f1 > /tmp/wobpipe
bindsym XF86MonBrightnessDown exec --no-startup-id light -U 2 && light -G | cut -d'.' -f1 > /tmp/wobpipe
...
exec --no-startup-id mkfifo /tmp/wobpipe && tail -f /tmp/wobpipe | wob

At least in my sway config I'm using the official instructions in the wob README.

Ultimately I just fixed the issue by not executing sway manually but using ~/.bash_profile. (I decided if I need to get into a raw TTY I can just login as root or create another user for this purpose.)

Anyways, I still had to add some extra stuff to ~/.bash_profile. My full ~/.bash_profile looks like:

#
# ~/.bash_profile
#

pkill tail
pkill wob
rm -f /tmp/wobpipe
exec sway

Hope this helps.

StephenCoady commented 5 years ago

@krathalan thanks for that.

So it actually started working this morning for me. I changed nothing which is what's strange. The only difference is I rebooted my laptop so I am wondering if its an issue with startup and sway sessions. I've reloaded sway and its still working.

francma commented 5 years ago

https://github.com/francma/wob/commit/18c1bb60cb73b8ae18d55fb13e0333488c227a0d - This commit should make Wob exit with Sway session https://github.com/francma/wob/commit/f34a175fee7b54aeded377bd7ac1f3b97244aef9 - This change should allow multiple Sway instances with Wob (even at the same time)

It's not in release yet, but you can test it if you build it from source. Still need to figure out why tail -f command stays after Sway exits.

francma commented 4 years ago

Still need to figure out why tail -f command stays after Sway exits.

Only solution I found is to use Bash Process Substitution, but that requires Bash and I want to keep examples posix shell friendly :slightly_frowning_face:

mkfifo pipe.wob && wob < <(tail -f pipe.wob)