SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2011-01-22 15:27:00

ali
#! Die Hard
Registered: 2010-05-31
Posts: 1,034

volume-notify

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

[modified june 8th]

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)

Offline

Be excellent to each other!

#2 2011-01-22 15:36:09

Awebb
The Singularity
Registered: 2009-07-23
Posts: 2,812

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

Offline

#3 2011-01-22 17:28:30

ali
#! Die Hard
Registered: 2010-05-31
Posts: 1,034

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

Offline

#4 2011-01-22 17:31:33

Unia
#! Die Hard
From: The Netherlands
Registered: 2010-07-17
Posts: 3,111

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


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres
      Github || Deviantart

Offline

#5 2011-01-22 18:14:22

ali
#! Die Hard
Registered: 2010-05-31
Posts: 1,034

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

Offline

#6 2011-01-28 18:24:13

kbmonkey
#! Junkie
From: South Africa
Registered: 2011-01-14
Posts: 459
Website

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

Online

#7 2011-01-30 19:55:09

Tunafish
#! Die Hard
From: the Netherlands
Registered: 2010-03-07
Posts: 1,201

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)


sed 's/stress/relaxation/g'
Privacy & Security on #!

Offline

#8 2011-01-30 20:51:47

ali
#! Die Hard
Registered: 2010-05-31
Posts: 1,034

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

Offline

#9 2011-01-31 07:23:08

kbmonkey
#! Junkie
From: South Africa
Registered: 2011-01-14
Posts: 459
Website

Re: volume-notify

ali wrote:

replace Master Front with PCM in the script tongue

*slaps forehead* Thanks smile

Online

#10 2011-01-31 08:55:27

Tunafish
#! Die Hard
From: the Netherlands
Registered: 2010-03-07
Posts: 1,201

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.


sed 's/stress/relaxation/g'
Privacy & Security on #!

Offline

#11 2011-01-31 09:31:26

ali
#! Die Hard
Registered: 2010-05-31
Posts: 1,034

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)

Offline

#12 2011-02-20 11:06:31

GuruX
#! Die Hard
Registered: 2009-01-18
Posts: 527

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?

Offline

#13 2011-02-20 15:44:07

ali
#! Die Hard
Registered: 2010-05-31
Posts: 1,034

Re: volume-notify

write

amixer get Master

and see if you get a good reading

Offline

#14 2011-02-21 18:07:37

johnraff
#!Drunkard
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 2,466
Website

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 )

Offline

#15 2011-02-21 18:10:09

johnraff
#!Drunkard
From: Nagoya, Japan
Registered: 2009-01-07
Posts: 2,466
Website

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 )

Offline

#16 2011-02-22 19:59:22

GuruX
#! Die Hard
Registered: 2009-01-18
Posts: 527

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?
2011-02-22--1298404405_1024x600_scrot.png

Offline

#17 2011-02-23 05:55:26

ali
#! Die Hard
Registered: 2010-05-31
Posts: 1,034

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

Offline

#18 2011-02-26 17:48:04

GuruX
#! Die Hard
Registered: 2009-01-18
Posts: 527

Re: volume-notify

Thanks ali!
That script works great!

Offline

#19 2011-02-26 21:27:03

ali
#! Die Hard
Registered: 2010-05-31
Posts: 1,034

Re: volume-notify

glad your problem was solved

Offline

#20 2011-06-08 12:01:44

ali
#! Die Hard
Registered: 2010-05-31
Posts: 1,034

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?
2011-02-22--1298404405_1024x600_scrot.png

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

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo