Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a shell-script example #40

Closed
wants to merge 1 commit into from
Closed

Conversation

shizeeg
Copy link

@shizeeg shizeeg commented May 21, 2022

we don't need Python dependency anymore. Useful with pipewire for example.

@florentc
Copy link
Owner

Thank you for your contribution. Getting rid of python for the example script would be nice indeed. However your script does not seem to work as intended. It only fetches the current volume once, and then stops after one second.

The sleep 1 suggests that you intended to put this inside a loop. There would be two issues even with this fix:

  1. the value would be printed every time even when nothing has changed (easily fixable by storing the previous value in a variable and comparing before displaying)
  2. It would be based on polling the current volume every second instead of listening to volume change events like in the current python script

The current python script should work well both with pulseaudio or pipewire. Do you have any issue with it?

@shizeeg
Copy link
Author

shizeeg commented May 25, 2022

The current Python script does not work with pipewire, I have no idea why. That why I replaced it with a shell script.
On polling volume level value once a second. I'm using it with https://github.com/baskerville/sxhkd as follows:

# Increase / decrease volume
{super + F11, super + F12, XF86AudioLowerVolume, XF86AudioRaiseVolume}
        pactl set-sink-volume @DEFAULT_SINK@ {-,+,-,+}1000; \
        volume | xob

it shows the volume level every time I press the media-keys or hotkeys so there is no reason for me to poll anything and wasting CPU cycles on it.

@florentc
Copy link
Owner

The current script does work with pipewire. I have just tested it. Make sure to update the pulsectl python library.

As for your proposed shell script, it needs to be bound manually to volume change keys. Running ./volume | xob will only show the bar once, then xob will close, waiting to be launched again later. I think this is why you add a sleep 1 in the end, otherwise it closes before you can even see it. xob is not actually intended to be used like that : opening and dying over and over.

Just launch xob in a terminal (not piping anything into it) and start writing numbers yourself. You will see that xob appears then disappears after a second without having to do anything on your side. Also you will notice that it remains open, waiting for new values.

The idea behind the current script is to listen to volume change events. No need to bind it to any key. It works regardless of your existing keybindings, and even if volume changes for another reason (e.g. through another volume control app or when plugging/unplugging headphones). In your pull request, the instructions in the README no longer fit that anymore.

If you want to go the manual way, by binding keys to trigger bar updates, refer to the fallback method in the readme that uses a named pipe. You won't need any script and you will be able to control how long the bar appears using the dedicated -t command line argument.

@shizeeg
Copy link
Author

shizeeg commented May 25, 2022

yeah, I've read the source code, I know how it works. ;) The script does exactly what I needed, so my thought process was pretty simple: let's see if the author finds it useful. If not it's whatever I keep it to myself. I'm gonna close the PR then. Thanks for the tips and xob itself! Take care.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants