LukeSmithxyz / voidrice

My dotfiles (deployed by LARBS)
GNU General Public License v3.0
4.29k stars 1.21k forks source link

sb-volume script does not work #1078

Closed JimPix1 closed 2 years ago

JimPix1 commented 2 years ago

sb-volume doesn't display properly in dwmblocks and when I check ~/.xsession-errors I see this

The sink doesn't exist

/home/matt/.local/bin/statusbar/sb-volume: line 16: [: =: unary operator expected
The sink doesn't exist

/home/matt/.local/bin/statusbar/sb-volume: line 20: [: : integer expression expected
/home/matt/.local/bin/statusbar/sb-volume: line 22: [: : integer expression expected
/home/matt/.local/bin/statusbar/sb-volume: line 24: [: : integer expression expected

Somehow the sink doesn't exist? When I try using sb-volume again it works but now whenever I turn on my laptop and open dwm the volume is not displayed properly (it's always muted even when it isnt) and I need to press one of my volume keys to change it. How do I fix this?

LukeSmithxyz commented 2 years ago

pamixer is a dependency for this script. You'll get errors there if you don't have it or if there's something wrong with your Pulse/Pipewire system.

JimPix1 commented 2 years ago

I have pamixer installed and I'm using pipewire. This has been working for months but a few hours ago this has began happening and I'm unsure as to why..

LukeSmithxyz commented 2 years ago

Okay. What happens if you run commands like:

pamixer --get-volume

or

pamixer --get-mute

LukeSmithxyz commented 2 years ago

Actually, I guess you say works after the first run, so it's probably a pipewire issue.

Assuming you haven't changed anything recently, how does your system start pipewire?

JimPix1 commented 2 years ago

Actually, I guess you say works after the first run, so it's probably a pipewire issue.

Yeah, it will display the output normally only after the first time.

Assuming you haven't changed anything recently, how does your system start pipewire?

Prior to when this started I hadn't touched my pipewire configuration nor had their been any update today to have caused something to go wrong. Pipewire is started the normal way with systemd afaik

JimPix1 commented 2 years ago

I used timeshift a few times and after a lot of testing I believe the issue was with me replacing the power manager I've been using for dwm (xfce4-power-manager) with lxqt-powermanagement and xautolock. I'm not sure why or how this would make pipewire get messed up, it's odd.

JimPix1 commented 2 years ago

Alright I did more testing, xautolock is not the issue. it's lxqt-powermanagement I suspect it may be one of the dependencies it installs that may be the problem.

JimPix1 commented 2 years ago

Update: I now believe this happens due to Pipewire race conditioning/pipewire not starting quickly enough. I recently removed the update checking script for a few reasons, one being it took a few seconds longer to load my dwmblocks when it was in use. When removing it however I got the same sb-volume error. To solve this I've added a blank module in my dwmblocks config.h that simply executes sleep 6, This will mean dwmblocks will take 6 seconds to load, giving pipewire-pulse sufficient time to load. (Note: Below 6 seconds still gives the error) @LukeSmithxyz If it's not too much trouble for you, could you try disabling sb-pacpackages in your dwmblocks config and then reboot and see if you get the sb-volume errors in your ~/.xsession-errors? (Or the module being displayed as muted when it shouldn't be)

JimPix1 commented 2 years ago

Alright I'll close this now The only solution is that there is none. My HDD isn't fast enough to start pipewire-pulse before dwmblocks (to be fair dwmblocks loads pretty much instantly) so sleep 6 is the only way to get it to work.

LukeSmithxyz commented 2 years ago

Why not move the initialization of pipewire earlier in boot? If you log in via tty, putting it to start in the ~/.zprofile or another profile file will have it start a bit before.

You can also use systemd/runit to start it up on boot, which would definitely fix the issue.

JimPix1 commented 2 years ago

You can also use systemd/runit to start it up on boot, which would definitely fix the issue.

I didn't think about doing that. That's a good idea. If I started it via systemd would it cause a conflict when it tries to start it after login or would it not happen after login anymore?

LukeSmithxyz commented 2 years ago

Definitely remove all other lines attempting to start it if using systemd.

JimPix1 commented 2 years ago

Thanks! I'll have to look into where it's even started from and how to get it to start via SystemD. Maybe I just need to make a service file for pipewire-pulse

JimPix1 commented 2 years ago

I'm not actually sure where pipewire-pulse specifically gets started.. does anyone know where?

LukeSmithxyz commented 2 years ago

If you're using these files, it's in ~/.config/x11/xprofile, although if you have had them installed for a while, I think I had it started elsewhere. Just remove pipewire there.

pirewire-pulse is started by pipewire.

JimPix1 commented 2 years ago

I'm using a lot of your stuff but sadly not LARBS so it's not in ~/.config/x11/xprofile I did more research and it's actually started by systemd by a service file in ~/.config/systemd but this would only start after login so doing systemctl --user --now enable pipewire pipewire-pulse pipewire and pipewire-pulse is now started on boot and I no longer have the problem Thanks for your help!

JimPix1 commented 2 years ago

Weirdly I get a smaller error in ~/.xsession-errors about the sink not existing but the volume is still displayed correctly so I'll just ignore it.

I would like to ask you though what do you use for power management? I've been using xfce4-power-manager but I'm not able to change the locker it uses so I'd like an alternative. I know you can use init services and xautolock to do a lot of the stuff but but I'm not sure how to do more complex things like locking the screen if the laptop lid is closed when charging but then suspending and locking when the lid is closed but it's on battery