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

Improve the default volume script #49

Closed
vivien opened this issue Oct 1, 2014 · 13 comments
Closed

Improve the default volume script #49

vivien opened this issue Oct 1, 2014 · 13 comments
Milestone

Comments

@vivien
Copy link
Owner

vivien commented Oct 1, 2014

This is meant to regroup the different issues about the volume: #46, #47, #48 and find a convenient solution, according to #36.

Let's agree on what the default script should look like. So far, I suggest:

  • wheel up increase the volume (+10%? or +3dB?)
  • wheel down to decrease the volume (same as above, which unit?)
  • display "MUTE" if the output is off
  • Mute on middle click (I find it convenient to keep the left click free, to manually update the volume after being changed by an alternative UI)
  • convenient values for CARD, MIXER, SCONTROL? Is there a candidate for BLOCK_INSTANCE?

ATM, I ended up with this, from all the PR: https://gist.github.com/vivien/0dbbecd0372f808a895c

It would be neat to convert the Ruby snippet to Perl to avoid this dependency, if not to complicated.

Cc: @xelite, @jpleau, @Elfram, @Nycroth

@ghost
Copy link

ghost commented Oct 1, 2014

  • wheel up increase the volume (+10%? or +3dB?)
  • wheel down to decrease the volume (same as above, which unit?)

I would suggest the +/-3dB for volume because that typically gives a better human sound gradient.
Volume Humor

  • Mute on middle click (I find it convenient to keep the left click free, to manually update the volume after being changed by an alternative UI)

I'm curious if the right click might be more appropriate. I agree the left click is inappropriate because that is how a manual refresh is achieved, but I feel that middle click may be a touch counter intuitive.

  • convenient values for CARD, MIXER, SCONTROL? Is there a candidate for BLOCK_INSTANCE?

I'd suggest the defaults be 0, defalut, and Master respectively. I'm not sure what you mean by BLOCK_INSTANCE? however.

For a perl alternative you can use:

perl -ne '/.*\[(\d+%)\].*?\[(on|off)\]/; if ($2 eq "on") {print "$1"; exit} elsif ($2 eq "off") {print "MUTE"; exit}'

In fact, this script better handles microphones and stereo controls. 👍

I also noted the SCONTROL patch wasn't present in the latest version. It'll need to be rewritten to handle the volume adjust patches of course. Want me go ahead and do that?

@vivien
Copy link
Owner Author

vivien commented Oct 1, 2014

OK with +/-XdB then. (Is 3 a confortable value?)
OK with the right click, since the middle click is used to scroll with the trackpoint on Lenovo keyboards.
The BLOCK_INSTANCE env variable is set to what you specify as instance= in the block config, I was just wondering if it could be used for the mixer for instance, but it doesn't seem interesting here.

Thanks for the snippet! I was able to make it even shorter:

format () {
  perl -ne 'if (/\[(\d+%)\].*?\[(on|off)\]/) {CORE::say $2 eq "off" ? "MUTE" : "$1"; exit}'
}

Yes, please go ahead for the patch, I'll give credits to you guys in the commit message before merging.

@ghost
Copy link

ghost commented Oct 1, 2014

Love the shortening! I would however change it from 'if (/\[(\d+% to 'if (/.*\[(\d+% to enable it's use for microphones.

@ghost
Copy link

ghost commented Oct 1, 2014

I may have assumed incorrectly. I see my output of amixer get Mic as:
Mono: Playback 0 [0%] [-41.00dB] [on] Capture 0 [0%] [16.00dB] [on]
then I run amixer sset Mic 3dB+ and get:
Mono: Playback 48 [10%] [-38.00dB] [on] Capture 3 [23%] [19.00dB] [on]

Can someone confirm that we want to see and modify Capture or if ALSA is messing with me and we only want Playback?

@xelite
Copy link

xelite commented Oct 1, 2014

@Nycroth, only Playback IMO.
@vivien, dB unit seems fine.

@ghost
Copy link

ghost commented Oct 1, 2014

Thanks @xelite!
Alright, the second commit I made to the merge pull then is the one to fully merge.

vivien pushed a commit that referenced this issue Oct 2, 2014
Thanks to:
  @xelite for mouse volume controls
  @jpleau for feedback about UI design
  @Elfram for mute display
  @Nycroth & @vivien for converting the ruby filter to perl

[vd: fix whitespace and remove the ? char from the regex]

Closes #46, #47, #48, #49, #51
@vivien
Copy link
Owner Author

vivien commented Oct 2, 2014

@Nycroth I adjusted #51 in scripts/volume but there's an issue, the volume change doesn't work for me. Am I the only one?

@vivien
Copy link
Owner Author

vivien commented Oct 2, 2014

If it works for you, it means that my mixer doesn't have dB information, which might be the case for others. In that case, we should maybe use +/-5%.

@jpleau
Copy link
Contributor

jpleau commented Oct 2, 2014

I can only change the volume when using percentage values, as @vivien just suggested. Using dB does not work for me.

I'm using PulseAudio, if that matters.

vivien pushed a commit that referenced this issue Oct 3, 2014
Thanks to:
  @xelite for mouse volume controls
  @jpleau for feedback about UI design
  @Elfram for mute display
  @Nycroth & @vivien for converting the ruby filter to perl

[vd: fix whitespace and remove the ? char from the regex]

Closes #46, #47, #48, #49, #51
@ghost
Copy link

ghost commented Oct 3, 2014

That may just be a Pulse thing. I'm running pure ALSA and it's working fine for me but I barely notice the difference between the percent and dB. I'm also liking control of 5%.

vivien pushed a commit that referenced this issue Oct 3, 2014
Thanks to:
  @xelite for mouse volume controls
  @jpleau for feedback about UI design
  @Elfram for mute display
  @Nycroth & @vivien for converting the ruby filter to perl

[vd: fix whitespace and remove the ? char from the regex]

Closes #46, #47, #48, #49, #51
@vivien vivien closed this as completed Oct 3, 2014
@vivien
Copy link
Owner Author

vivien commented Oct 3, 2014

Merged, thanks guys!

@jpleau
Copy link
Contributor

jpleau commented Oct 6, 2014

I am currently testing the scripts in a default install (Debian stable at the moment), and the script gives me this error:

CORE::say is not a keyword at -e line 1.
amixer: invalid option -- 'M'
Invalid switch or option needs an argument.

This is with perl 5.14, could it be that it's just an old version or there's a perl library that's required ? (if it's just the old version then nevermind that, i3blocks package will never be for current debian stable anyway..)

@ghost
Copy link

ghost commented Oct 6, 2014

The problem is your audio card doesn't use "Master" as it's default main control. Many USB cards do this. I've created a patch to prevent this issue in future and more sensibly allow you to change it. Try out patch pull request #53 and see if that's got it for you.

@vivien vivien added this to the 1.3 milestone Oct 7, 2014
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

No branches or pull requests

3 participants