Topic: volume-notify

here's a small script to inform you about the volume

[modified june 8th]

http://i.imm.io/6g6e.png

download link: http://ticcaso.fileave.com/volume-notify.tar.gz

what's in the .tar.gz?
the ali-vol script and the icons folder
the icons folder contains 202 images, each reflecting the current state

just replace whatever you're interested in changing in the elements list

what will you need?
- notification-daemon
- libnotify-bin

why would you need this?
well i never knew at what percentage i was when voluming up and down and i often found myself checking the mixer so i thought i'd make a small script to make my life a bit easier smile

place it where ever you like just remember to change the icon variable in the script to reflect the changes
i called mine ali-vol

how to call it?

    <keybind key="XF86AudioRaiseVolume">
      <action name="Execute">
        <command>*script-name* up</command>
      </action>
    </keybind>
    <keybind key="XF86AudioLowerVolume">
      <action name="Execute">
        <command>*script-name* down</command>
      </action>
    </keybind>
    <keybind key="XF86AudioMute">
      <action name="Execute">
        <command>*script-name* toggle</command>
      </action>
    </keybind>

/*
the reason why i said you need notification-daemon is because notify-osd doesn't support notify timeout
*/

Last edited by ali (2011-06-08 12:01:06)

Re: volume-notify

I really think I've seen something like that here a year ago. We should put some work and make a master list :-D

Anyway, nice work.

I'm so meta, even this acronym

Re: volume-notify

thanks, also i forgot to mention, the reason why i said you need notification-daemon is because notify-osd doesn't support notify timeout, so you would have to wait 10 seconds every time you change the volume to find out what value you're at right now

Re: volume-notify

You can control the timeout for notify-osd in ~/.notify-osd.

Mine is set to 5sec and it dissapears after 5 sec

Let's do it and don't screw it.
      Github || Deviantart

Re: volume-notify

that timeout is universal, not all notifications are equally important, volume notifications may be set for 100 ms where as normal notifications should last more than 5000 ms

Re: volume-notify

I had to place this script under /usr/bin and make it executable to work, is that okay?

It toggles the volume up/down, and shows the osd but no actual value, I guess my output differs and awk isn't parsing it right, can you point out what needs to change to awk the correct value?

in terminal I get this:

kbmonkey@bitwise:~$ amixer sset PCM 10+
Simple mixer control 'PCM',0
  Capabilities: pvolume penum
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 255
  Mono:
  Front Left: Playback 210 [82%] [-9.00dB]
  Front Right: Playback 210 [82%] [-9.00dB]

As you can see, I set the PCM device volume, Master does not seem to work. I'm happy, I just need to awk the [82%].

Thanks smile

Re: volume-notify

kbmonkey wrote:

As you can see, I set the PCM device volume, Master does not seem to work. I'm happy, I just need to awk the [82%].

Something like:

amixer get PCM | grep 'Front Left:' | awk '{print $5}' | sed 's/\[/Volume: /g' | sed 's/\]//g'

will get the volume %

Last edited by Tunafish (2011-01-30 21:08:52)

Re: volume-notify

kbmonkey wrote:

I had to place this script under /usr/bin and make it executable to work, is that okay?

It toggles the volume up/down, and shows the osd but no actual value, I guess my output differs and awk isn't parsing it right, can you point out what needs to change to awk the correct value?

in terminal I get this:

kbmonkey@bitwise:~$ amixer sset PCM 10+
Simple mixer control 'PCM',0
  Capabilities: pvolume penum
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 255
  Mono:
  Front Left: Playback 210 [82%] [-9.00dB]
  Front Right: Playback 210 [82%] [-9.00dB]

As you can see, I set the PCM device volume, Master does not seem to work. I'm happy, I just need to awk the [82%].

Thanks smile

replace Master Front with PCM in the script tongue

Re: volume-notify

ali wrote:

replace Master Front with PCM in the script tongue

*slaps forehead* Thanks smile

Re: volume-notify

kbmonkey wrote:

I had to place this script under /usr/bin and make it executable to work, is that okay?

I think that's OK as well. I prefer to put my scripts in /home/username/bin
Makes it easier to maintain them. Don't know what's best.

11

Re: volume-notify

i'd put them in ~/bin/scripts and create a symbolic link in /usr/bin

sudo ln -s ~/bin/scripts/whatever-script /usr/bin/whatever-script

i modified the initial post, made the script better using tunafish's method of getting the %

Last edited by ali (2011-01-31 09:51:39)

Re: volume-notify

Trying this out now. I'd like to control my master, so I specify Master in the script. Volume changing works, but no OSD. I get the message "No summary specified". If I specify PCM instead of Master in the script, OSD works.

Any ideas?

13

Re: volume-notify

write

amixer get Master

and see if you get a good reading

Re: volume-notify

ali wrote:

i'd put them in ~/bin/scripts and create a symbolic link in /usr/bin

sudo ln -s ~/bin/scripts/whatever-script /usr/bin/whatever-script

Or make links from ~/bin for the ones that only have to be in that user's $PATH.

Last edited by johnraff (2011-02-21 18:09:36)

John
------------------------
( a boring Japan blog , and idle twitterings )
“Good morning sir, which way up would you like your reality today?”  "As it comes, Jeeves, as it comes..."

Re: volume-notify

ali wrote:

i'd put them in ~/bin/scripts and create a symbolic link in /usr/bin

Or make links from ~/bin for the ones that only need to be in that user's $PATH.

Last edited by johnraff (2011-02-21 18:11:14)

John
------------------------
( a boring Japan blog , and idle twitterings )
“Good morning sir, which way up would you like your reality today?”  "As it comes, Jeeves, as it comes..."

Re: volume-notify

ali wrote:

write

amixer get Master

and see if you get a good reading

Yeah, the reading seems to be fine:

gustav@eeernst:~$ amixer get Master
Simple mixer control 'Master',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined penum
  Playback channels: Mono
  Limits: Playback 0 - 64
  Mono: Playback 59 [92%] [-5.00dB] [on]

But wouldn't it be possible to get this OSD (well this one is for brightness, but you get the point...) instead of the one with text your script makes?
http://ompldr.org/vN2lwYw/2011-02-22--1298404405_1024x600_scrot.png

17

Re: volume-notify

it probably would be possible but i'm not that good

#! /bin/bash

if [[ $1 -eq 1  ]]
then
     P=`amixer sset 'Master',0 2+ | grep 'Mono:' | awk '{print $4}' | sed 's/\[/Volume: /g' | sed 's/\]//g'`
     notify-send -t 300 "$P"
else if [[ $1 -eq 2 ]]
then
     P=`amixer sset 'Master',0 2- | grep 'Mono:' | awk '{print $4}' | sed 's/\[/Volume: /g' | sed 's/\]//g'`
     notify-send -t 300 "$P"
else if [[ $1 -eq 3 ]]
then
    P=`amixer sset 'Master',0 toggle | grep "Mono:" | awk '{print $6}'`
    if [[ ''$P'' == '[off]' ]] 
    then
    P="Volume is off"
    else
    P="Volume is on"
    fi
    notify-send -t 300 "$P"
fi 
fi
fi

Re: volume-notify

Thanks ali!
That script works great!

19

Re: volume-notify

glad your problem was solved

20

Re: volume-notify

GuruX wrote:

But wouldn't it be possible to get this OSD (well this one is for brightness, but you get the point...) instead of the one with text your script makes?
http://ompldr.org/vN2lwYw/2011-02-22--1298404405_1024x600_scrot.png

i just tried that, see first post to see what i came up with