Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Fluxbox volume notifications
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
teapot
Tux's lil' helper
Tux's lil' helper


Joined: 09 Nov 2006
Posts: 85
Location: Stockholm , Sweden

PostPosted: Sun Apr 08, 2012 12:13 pm    Post subject: Fluxbox volume notifications Reply with quote

Hey.

I'm using Fluxbox and I wonder if there is a simple lightweight daemon for handling volume change notifications (and possibly other notifications) ?.
Back to top
View user's profile Send private message
i92guboj
Moderator
Moderator


Joined: 30 Nov 2004
Posts: 9464
Location: Córdoba (Spain)

PostPosted: Sun Apr 08, 2012 6:19 pm    Post subject: Reply with quote

What I and most people do is a self-crafted script or something like that, and bind it to a key. I use something like this for setting the volume:

Code:
#!/bin/bash -x

CHANNEL="Master"
vol=$(amixer sget "$CHANNEL" | grep "Mono: Playback" | sed -e "s/%.*//" | sed -e "s/.*\[//")

if [ $# -eq 0 ]; then
        echo $vol
        exit 0
fi

let vol=vol+$1
if [ $vol -gt 100 ]; then
        vol=100;
elif [ $vol -lt 0 ]; then
        vol=0;
fi
#echo $vol
amixer sset "$CHANNEL" $vol% > /dev/null

echo $vol


I do it this way because I need some fine grained control over the output (it's used for something else later, once the script is done). This receives an integer (as '1' or '-1', for example), and increases the volume by that amount. It's intended just as an example to give you a general idea (it won't probably work for you without some slight change(s)), you can use any other command line mixer application and you can also use some notifier plugin just as notify-send, kdialog, zenity, osd_cat or whatever people use these days to draw nice stuff on their screen (I can live without that).

The simplest solution would probably be to bind some command line mixer that can increase the volume in steps (or decrease it) via the fluxbox configuration file (I don't remember at all how keybindings are configure in fluxbox, but I assume the process is similar to this on pekwm, openbox, fvwm and most minimalist wm's.
_________________
Gentoo Handbook | My website
Back to top
View user's profile Send private message
VoVaN
l33t
l33t


Joined: 02 Jul 2003
Posts: 656
Location: The Netherlands

PostPosted: Thu Apr 12, 2012 12:01 pm    Post subject: Re: Fluxbox volume notifications Reply with quote

teapot wrote:
Hey.

I'm using Fluxbox and I wonder if there is a simple lightweight daemon for handling volume change notifications (and possibly other notifications) ?.


I use a script as well, the only tricky thing was to get a proper notifications with the old notifications daemon. Of course notify-send will do, but every volume change will create new notification, so I use gdbus to create proper volume notification (they are replacing each other). The script is below:

Code:
#!/bin/sh
usage="usage: $0 -c {up|down|mute} [-i increment] [-m mixer]"
increment=1%
mixer=Master
uid_file="/tmp/volume_notify_${USER}"

if [ -f $uid_file ]; then
    uid=`cat $uid_file`
else
    uid=1
fi

while getopts i:m:h o
do case "$o" in
    i) increment=$OPTARG;;
    m) mixer=$OPTARG;;
    h) echo "$usage"; exit 0;;
    ?) echo "$usage"; exit 0;;
esac
done

shift $(($OPTIND - 1))
command=$1

if [ "$command" = "" ]; then
    echo "usage: $0 {up|down|mute} [increment]"
    exit 0;
fi

display_volume=0

if [ "$command" = "up" ]; then
    display_volume=$(amixer set $mixer $increment+ unmute | grep -m 1 "%]" | cut -d "[" -f2|cut -d "%" -f1)
fi

if [ "$command" = "down" ]; then
    display_volume=$(amixer set $mixer $increment- unmute | grep -m 1 "%]" | cut -d "[" -f2|cut -d "%" -f1)
fi

icon_name=""

if [ "$command" = "mute" ]; then
    if amixer get Master | grep "\[on\]"; then
        display_volume=0
        icon_name="audio-volume-muted"
        amixer set $mixer mute
    else
        display_volume=$(amixer set $mixer unmute | grep -m 1 "%]" | cut -d "[" -f2|cut -d "%" -f1)
    fi
fi

if [ "$icon_name" = "" ]; then
    if [ "$display_volume" = "0" ]; then
        icon_name="audio-volume-min"
    else
        if [ "$display_volume" -lt "33" ]; then
            icon_name="audio-volume-low"
        else
            if [ "$display_volume" -lt "67" ]; then
                icon_name="audio-volume-medium"
            else
                icon_name="audio-volume-high"
            fi
        fi
    fi
fi
gdbus call --session --dest org.freedesktop.Notifications \
           --object-path /org/freedesktop/Notifications \
           --method org.freedesktop.Notifications.Notify \
           Volume $uid $icon_name "" "<b>Volume: ${display_volume}%</b>" \[\] {} 5000 \
           | sed -r 's/\(uint32 (.+)\,\)/\1/' > $uid_file

Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum