You are not logged in.

#1 2011-12-21 00:09:10

david.brazdil
Member
Registered: 2011-12-20
Posts: 6

Volnoti - Lightweight Volume Notification

Hey guys,

Let me share a little piece of code I've put together recently. I'm using XMonad and one thing all the lightweight window managers always lacked was a nice notification when the volume is changed. What I'm specially fond of is the Apple-like notification you can get for example with Compiz. So I took bits and pieces of GNOME's notification-daemon, assembled my own and I present it here to you.

The main point for Volnoti was to be absolutely independent of the system configuration and WM. Therefore, Volnoti doesn't read the volume level itself, but rather waits for someone to tell it what it is. The idea is that the users can attach a script to their hot keys, read the volume level in it and then call Volnoti's client application. It just sends the 0-100 integer to the daemon, which displays the notification (all details in README). Currently, calling the client application is the only way of dealing with the daemon. I guess that it might be handy to create a small library as well, which people could use when writing plugins for volume-control applications. On the other hand, it is possible to just call a UNIX command from C, so there's no actual need for the library at the moment. Feel free to comment on this - I'd be happy to get your feedback.

This is just a first draft, which suits me, but I can imagine that people would appreciate more ways of customizing it. Currently, it is possible to replace all the icons and change the duration of notification (details in README). Let me know, what else you would like to change and I'll add suitable parameters to the daemon. One thing is definitely the level of transparency (if you use composite desktop), other might be the radius of corner rounding. In the future, more sophisticated ways of theming might be added, which would allow to completely change the look of the notifications. For now, it's quite limited...

So please, do look at the screenshots, do give it a try yourself and let me know what you think, whether you have any suggestions, problems, etc. Bugs can be reported on GitHub.

More details on the GitHub page:
https://github.com/davidbrazdil/volnoti

The package is ready in AUR:
https://aur.archlinux.org/packages.php?ID=55159

Screenshot:
http://i42.tinypic.com/10eq9lt.png


mod edit: Welcome to the forums. Please read Forum Etiquette: Pasting Pictures and Code. Thanks. --fsckd

Last edited by david.brazdil (2011-12-21 17:43:10)

Offline

#2 2011-12-21 11:38:55

ri
Member
Registered: 2008-10-09
Posts: 73

Re: Volnoti - Lightweight Volume Notification

Looks like a nice take on volume handling, I'll try it when i get home. Some ideas of customization (just emptying my mind): size, background color (in case you have no compisite), position.

Offline

#3 2011-12-21 13:29:59

Šaran
Member
From: Bosnia
Registered: 2011-09-03
Posts: 407

Re: Volnoti - Lightweight Volume Notification

Just tried it, and it looks awesome!

I think notification size and position should be changeable.
I don't want it to appear in the middle of fullscreen mplayer. And md5 in PKGBUILD is wrong.

And can you share your script for volume binds and config for the bar on the screenshot?

Offline

#4 2011-12-21 17:38:34

david.brazdil
Member
Registered: 2011-12-20
Posts: 6

Re: Volnoti - Lightweight Volume Notification

Šaran wrote:

Just tried it, and it looks awesome!

I think notification size and position should be changeable.
I don't want it to appear in the middle of fullscreen mplayer. And md5 in PKGBUILD is wrong.

And can you share your script for volume binds and config for the bar on the screenshot?

Ooops, sorry about the bad MD5, it's fixed now... Size and position are one of the more complicated customization options, but I'll definitely put it on the TODO list.

You can find all my scripts on GitHub page https://github.com/davidbrazdil/config. The volume script is under https://github.com/davidbrazdil/config/ … e_audio.sh, top panel is in https://github.com/davidbrazdil/config/ … p_panel.sh and everything is bound to the keys and events in https://github.com/davidbrazdil/config/ … /xmonad.hs. Actually, the top panel is made of three things: top_panel.sh clock.sh and stalonetray (executed in autorun.sh)... Enjoy :-)

David

Last edited by david.brazdil (2011-12-21 18:26:18)

Offline

#5 2011-12-21 19:11:20

sugardeath
Member
Registered: 2010-03-02
Posts: 82

Re: Volnoti - Lightweight Volume Notification

Man, this is awesome.  Minimal yet still pretty.  I love it.

Offline

#6 2011-12-21 19:11:39

ri
Member
Registered: 2008-10-09
Posts: 73

Re: Volnoti - Lightweight Volume Notification

Worked just as I hoped it would. Definitely a keeper.

Here is the script I use (with alsa):
edit: btw, I'm no bash pro wink

#!/bin/bash

# Configuration
STEP="2"    # Anything you like.
UNIT="dB"   # dB, %, etc.

# Set volume
SETVOL="/usr/bin/amixer -qc 0 set Master"

case "$1" in
    "up")
          $SETVOL $STEP$UNIT+
          ;;
  "down")
          $SETVOL $STEP$UNIT-
          ;;
  "mute")
          $SETVOL toggle
          ;;
esac

# Get current volume and state
VOLUME=$(amixer get Master | grep 'Mono:' | cut -d ' ' -f 6 | sed -e 's/[^0-9]//g')
STATE=$(amixer get Master | grep 'Mono:' | grep -o "\[off\]")

# Show volume with volnoti
if [[ -n $STATE ]]; then
  volnoti-show -m
else
  volnoti-show $VOLUME
fi

exit 0

And .xbindkeysrc:

# Increase volume
"sh $HOME/script/sound.sh up"
    m:0x0 + c:123
    XF86AudioRaiseVolume

# Decrease volume
"sh $HOME/script/sound.sh down"
    m:0x0 + c:122
    XF86AudioLowerVolume

# Toggle mute
"sh $HOME/script/sound.sh mute"
    m:0x0 + c:121
    XF86AudioMute

Last edited by ri (2011-12-21 19:15:23)

Offline

#7 2011-12-21 19:15:35

david.brazdil
Member
Registered: 2011-12-20
Posts: 6

Re: Volnoti - Lightweight Volume Notification

Just a quick recommendation: set the step to 5%, it will add/remove exactly one box in the progress bar ;-)

Offline

#8 2011-12-21 19:54:15

intrntbrn
Member
From: Germany
Registered: 2011-12-01
Posts: 66

Re: Volnoti - Lightweight Volume Notification

can someone can tell how to set it up using awesome wm?

Offline

#9 2011-12-21 19:56:10

david.brazdil
Member
Registered: 2011-12-20
Posts: 6

Re: Volnoti - Lightweight Volume Notification

intrntbrn wrote:

can someone can tell how to set it up using awesome wm?

It shouldn't depend on your wm... What do you use to change the volume in your setup?

Offline

#10 2011-12-21 21:18:27

intrntbrn
Member
From: Germany
Registered: 2011-12-01
Posts: 66

Re: Volnoti - Lightweight Volume Notification

david.brazdil wrote:
intrntbrn wrote:

can someone can tell how to set it up using awesome wm?

It shouldn't depend on your wm... What do you use to change the volume in your setup?

i use simple binds in awesome rc.lua

    awful.key({}, "#122", function () awful.util.spawn("amixer -q sset Master 5%- " ) end),
    awful.key({}, "#123", function () awful.util.spawn("amixer -q sset Master 5%+ ") end),

pretty sure thats wrong for gettin notifications...

Last edited by intrntbrn (2011-12-21 21:21:21)

Offline

#11 2011-12-21 21:28:36

david.brazdil
Member
Registered: 2011-12-20
Posts: 6

Re: Volnoti - Lightweight Volume Notification

intrntbrn wrote:
david.brazdil wrote:
intrntbrn wrote:

can someone can tell how to set it up using awesome wm?

It shouldn't depend on your wm... What do you use to change the volume in your setup?

i use simple binds in awesome rc.lua

    awful.key({}, "#122", function () exec("amixer -q sset Master 5%- & " ) end),
    awful.key({}, "#123", function () exec("amixer -q sset Master 5%+ &") end),

pretty sure thats wrong for gettin notifications...

No worries, look at ri's post (#6) - he has a simple script that calls amixer in exactly the same fashion as you do (just with 2db instead of 5%, but that can be changed under #Configuration). Afterwards it reads back the volume level and calls volnoti-show. So just download it and change the bindings in your rc.lua to call that script either with parameter up, down or mute.

You will also have to add volnoti into your startup applications. Again, no idea how this works with awesome, but it shouldn't be hard - maybe put it into ~/.xinitrc? One way or the other, just call this command when awesome loads up:

volnoti

And that's it... Enjoy :-)

Offline

#12 2011-12-21 21:42:07

intrntbrn
Member
From: Germany
Registered: 2011-12-01
Posts: 66

Re: Volnoti - Lightweight Volume Notification

sry for showing that i dont read the entry post... ur very fast smile
no i got how the script works.. the notifications are working very well, but i have to fix the grep! nice work!

Offline

#13 2011-12-21 21:45:51

irtigor
Member
Registered: 2011-01-21
Posts: 44

Re: Volnoti - Lightweight Volume Notification

Great piece of software! I would love to use it to others things (to display brightness, for instance). I also took the liberty to change your script a bit:

#!/bin/bash

VOLUME=$(pamixer --get-volume)
VALUE=5

case "$1" in
  "up")
    [[ "$VOLUME" -eq 100 ]] && VALUE=0
    pamixer --increase $VALUE
    ;;
  "down")
    pamixer --decrease $VALUE
    ;;
  "mute")
    pamixer --toggle-mute
    ;;
esac

# notification
VOLUME=$(pamixer --get-volume)
MUTE=$(pamixer --get-mute)

if [ "$MUTE" == "false" ]; then
  volnoti-show $VOLUME
else
  volnoti-show -m $VOLUME
fi

Offline

#14 2011-12-21 22:28:57

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 13,697
Website

Re: Volnoti - Lightweight Volume Notification

Love it.  I'll look forward to developments for customization, but this is just what I've been looking for for a while as other notification daemons I tried were just bulky and unreliable.

Before I read the rest of the thread I tossed together my own script as well - short and to the point:

#!/bin/bash

[[ "$1" == "up" ]] && amixer set Master 5%+
[[ "$1" == "down" ]] && amixer set Master 5%-
[[ "$1" == "mute" ]] && amixer sset Master toggle

VOL=$(amixer get Master | grep Mono: | sed 's|[^[]*\[\([0-9]*\).*|\1|')
[[ $(amixer get Master | grep "\[off\]") ]] && volnoti-show -m $VOL && exit
volnoti-show $VOL

InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#15 2011-12-21 22:42:09

kaptenen
Member
Registered: 2009-12-06
Posts: 266
Website

Re: Volnoti - Lightweight Volume Notification

Very nice!

Offline

#16 2011-12-22 00:53:42

intrntbrn
Member
From: Germany
Registered: 2011-12-01
Posts: 66

Re: Volnoti - Lightweight Volume Notification

would love to have a similar notification for brightness!
for the first i use it for it too smile

#!/bin/bash
bright=`cat /sys/class/backlight/acpi_video0/actual_brightness`
perc=`expr $bright "*" 100 "/" 15`
volnoti-show $perc
exit 0

Offline

#17 2011-12-22 10:42:52

Šaran
Member
From: Bosnia
Registered: 2011-09-03
Posts: 407

Re: Volnoti - Lightweight Volume Notification

Thanks for configs!
Volnoti works great with @ri's script.

Offline

#18 2011-12-23 02:02:21

kyla
Member
From: Arlington, VA
Registered: 2011-03-12
Posts: 112
Website

Re: Volnoti - Lightweight Volume Notification

Thank you, this is really nice! (Also, thank you for the script ri!)

I would like to second (erm, nth?) the request for a similar thing for brightness smile

Offline

#19 2011-12-23 08:29:15

david.brazdil
Member
Registered: 2011-12-20
Posts: 6

Re: Volnoti - Lightweight Volume Notification

Hello everyone,

Thanks for your replies, I'm really glad you like it. Encourages me to work on volnoti more. Brightness control is a nice idea - that didn't occur to me, maybe because my laptop has horrible support for changing it. But yeah, definitely worth adding it in. I'll also add more parameters, as promised, especially for changing the size and position, which is what you seem to request the most.

So stay tuned, I'll keep you posted
David

Offline

#20 2011-12-23 10:58:35

ri
Member
Registered: 2008-10-09
Posts: 73

Re: Volnoti - Lightweight Volume Notification

Brightness control is a great idea! Glad my script was useful for some of you smile

Offline

#21 2011-12-23 11:04:11

ViruSzZ
Member
From: The Streets
Registered: 2010-10-14
Posts: 202
Website

Re: Volnoti - Lightweight Volume Notification

Really helpful man. It works perfectly and now I have wicked audio notification. I've struggled with this using 'notify-send' and my own bash script because my HP G62 a22se Fn and multimedia keys are dead and are not recognized by the kernel.

This solution works perfectly and again get my respect and thank you.

Out


Their Momma Made Em, Their Momma Gave em & now she can`t even SAVE`em | My WebLog

Offline

#22 2011-12-23 22:36:50

Shinryuu
Member
From: 俺のコスモス
Registered: 2010-02-27
Posts: 338

Re: Volnoti - Lightweight Volume Notification

For some odd reason, sometimes Volnoti refuses to work and I get the following output. I wonder what's the cause/problem behind it because it works sometimes.

ERROR: Failed to send notification (The name uk.ac.cam.db538.volume-notification was not provided by any .service files)

Offline

#23 2011-12-23 22:56:49

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 13,697
Website

Re: Volnoti - Lightweight Volume Notification

Shinryuu, is Volnoti running?  I only see that error if I try to execute a 'volnoti-show' without volnoti already running.


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#24 2011-12-23 23:02:14

Shinryuu
Member
From: 俺のコスモス
Registered: 2010-02-27
Posts: 338

Re: Volnoti - Lightweight Volume Notification

Trilby wrote:

Shinryuu, is Volnoti running?  I only see that error if I try to execute a 'volnoti-show' without volnoti already running.

Ah! That's the problem, "volnoti &" fixes the problem. Thanks

Offline

#25 2011-12-24 01:27:06

Shinryuu
Member
From: 俺のコスモス
Registered: 2010-02-27
Posts: 338

Re: Volnoti - Lightweight Volume Notification

Trilby wrote:

Shinryuu, is Volnoti running?  I only see that error if I try to execute a 'volnoti-show' without volnoti already running.

Ah! That's the reason, running "volnoti" fixes the problem and runs just fine with scripts on my PC.

Trilby wrote:

Love it.  I'll look forward to developments for customization, but this is just what I've been looking for for a while as other notification daemons I tried were just bulky and unreliable.

Before I read the rest of the thread I tossed together my own script as well - short and to the point:

#!/bin/bash

[[ "$1" == "up" ]] && amixer set Master 5%+
[[ "$1" == "down" ]] && amixer set Master 5%-
[[ "$1" == "mute" ]] && amixer sset Master toggle

VOL=$(amixer get Master | grep Mono: | sed 's|[^[]*\[\([0-9]*\).*|\1|')
[[ $(amixer get Master | grep "\[off\]") ]] && volnoti-show -m $VOL && exit
volnoti-show $VOL

I had to fiddle, search and configure your script around to make it to work (to show volnoti info) on my laptop because it uses an "Intel CougarPoint HDMI" chip and "HDA Intel PCH" card. I was able to solve the problem by changing "grep Mono" line to "grep 'Front Left'" or "grep 'Front Right'" (I keep both left/right levels equally same) so that quick'n'dirty fix is just enough for my needs. Hope this helps someone else too.

Also thanks for the script!

Offline

Board footer

Powered by FluxBB