-
Notifications
You must be signed in to change notification settings - Fork 10
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
Volume control on mouse scroll #30
Conversation
The volume control based on mpris could be put in too but I wanted to check if there would be a way to implement using I am able to list streams using However, while the names don't really matter for the other extension or gnome settings, it turns out they don't exactly match either Identity or desktopEntry so matching them might be a challenge. There might be other info somewhere which might be more useful to use to match with mpris sources, not sure... (Edit: based on investigation, See log below, the first section is the list of stream id/names from Also, if you have several Google Chrome tabs playing, they will all be called "Google Chrome". On the plus side, the browsers are listed so this definitely gives us the ability to control Chrome/Firefox through this since they can't be controlled via mpris (as far as I can tell). Any thoughts? Some additional info here maybe: https://gitlab.gnome.org/rmader/gnome-shell/-/blob/main/js/ui/status/volume.js |
I guess if we were to run a loose lowercase match with (stream name included in identity) or (identity included in stream name), this would work for all apps listed here and save us from doing any separate mpris volume control. Find the stream matching the |
The object returned from My bet is: we can match desktop entries with properties of this object. I think your idea of loosely matching name with identity could work pretty well too, but that's not a straight forward implementation. |
I just had a look at the content of the .desktop as a quick way to extract info and got the following for main info for Firefox for example:
I was hoping we could somehow get a match with icon but turns out the firefox's stream icon is I went down the fuzzy match route and I have a working draft now. What I had in mind for the match is more something simple like this:
This implementation with this match within the We could identify the stream_id in the player class. However, since it's a sequence, this number could change if another source gets deleted. There are ways to detect |
ok, I think that I've got it now. I moved the streamID identification out of the I also wanted to keep the I have left the logs so you can see what it does. to be removed before merge obviously. try to break me 👍 |
Good job figuring it out! Although the code is sprawling itself too much, it definitely needs a layer of abstraction. |
That sounds good. I just wanted to start step by step to make sure I have a working solution before cleaning up as you probably noticed in the last few commits. A couple of things I was considering:
For info, I did some checks opening multiple tabs in chrome and when a new tab is open, it is given the same volume level as the last one so by default, they should all have the same volume level. If we don't update all matching streams for a given Browser together, we could be adjusting the volume to the wrong stream. |
sorry, just had to make a couple of fixes:
over to you now ;-) |
Ok, for a brief explanation i have this diff stashed and i will merge it with this branch, as the mpris method is discarded for now and the code for changing the volume for the application looks like it benefits greatly if we bind it with the player object, all that code will be moved to the |
Yeah, moving the code into player.js crossed my mind. I'm not sure how many lines of code that would save though. One think to watch out is that the streams may not be created at the same time as the mpris sources so the stream_id or object may not exist when you first initialise a source. Worth checking just in case. |
allow scroll rebinds, and add _changeVolume method
Couple of comments on the diff:
|
|
The scroll up and down clutter events are problematic and always (on my testing) fired alongside a |
And make _changeVolume easier to read
And for the |
ok, see proposed updates. I was actually surprised about how easy it was to implement the stream Array as it worked right away. I'm either getting good at this or I must have missed something (probably option 2)... |
Streams are created/removed as the sources are stopped so the concept of first/last doesn't carry a lot of meaning. The safest would be to pick the one with the lowest volume as it's better to have the sound drop than blasting sound full volume all of a sudden. There's always the OSD to show the volume level so if the user can't hear anything all of a sudden as the sources get realigned, he/she will know why. Again, by default they will all match so the risk is low. |
Sounds about right. The best way i see to do this would be to only raise/lower the volume of the stream that corresponds with the mpris information. |
As you said that, I just thought I might check what comes out of _get_description() again in case we could do a match again some of the mpris info for browsers at least. Unfortunately, |
I added an option to toggle mute on click. I quite like being able to do it with a middle button click, it feels quite natural when combine with the volume up/down on scroll. I embedded it within the current |
Have you tried to pass a very high negative delta instead? That wouldn't require the extra if statement. Although the code might not handle high deltas correctly, we should address it if that's the case. |
The purpose of the 0 delta is so that the existing code remains and the volume isn't affected since |
I see. I wonder if devices can send a delta of 0. Sounds like a possibility, although i don't think a lot of devices would bother to send a useless value even if they can (i hope?). I wonder what's the specification. |
I know that my mouse can send a scroll delta of 0 as it would occasionally trigger mute if I scrolled very slowly before I put the |
I guess the PR is now completed. Anything else we might have missed? |
I got some errors in the logs, it looks like |
I want to use the same controls to change the volume of everything, not only players. I started another extension to do just that. |
Well i think i cleaned all or most of them. I'm gonna go ahead and merge this. |
Preliminary implementation of the volume control with mouse scroll based on selected section of #26
For this initial commit, only the proference drop down and control for "Global" volume are implemented to start the conversation.