You are not logged in.

#1 2009-05-17 16:18:08

nawitus
Member
Registered: 2009-05-11
Posts: 112

Quick and dirty volume notification text

Hi,
I created a simple bash script which will show the current volume level when I press the volume controls on my laptop.
It uses extra/xosd and amixer command, and gets the volume level from Master. The volume is simply drawn on top of everything else..
volnot.sh:

!/bin/bash
var=$(amixer get Master | grep "Front Left:")
var=$(echo "$var" | sed -ne 's/^[^[]*\[\([^]]*\)\].*/\1/p')
killall osd_cat
echo "Volume $var" | osd_cat --font='-b&h-lucida-medium-r-normal-*-34-*-*-*-p-*$
   --color=green \
   --pos=middle \
   --align=center \
   --delay=1 \

I used xbindkeys to run this script everytime I change volume..

Here's an screenshot
volnot.png

Offline

#2 2009-05-17 18:58:58

coolaman
Member
From: france
Registered: 2008-07-28
Posts: 34
Website

Re: Quick and dirty volume notification text

I've made similar script with libaosd , it have pseudo transparency :

                                                                           Screenshot_volume.png
for alsa :

#!/bin/bash

case $1 in
up) a="Volume: `amixer sset PCM 2%+ unmute | grep Left: | awk '{ gsub(/\[/, " "); gsub(/%\]/, " "); print $5 }'`%" ;;
down) a="Volume: `amixer sset PCM 2%- unmute | grep Left: | awk '{ gsub(/\[/, " "); gsub(/%\]/, " "); print $5 }'`%" ;;
mute)
case `amixer set PCM toggle | grep Left: | awk '{ gsub(/\[/, " "); gsub(/%\]/, " "); print $7 }' | cut -f1 -d]` in
            on) a="Unmute" ;;
             *) a="Mute" ;;
             esac ;;
*) echo "Usage: $0 { up | down | mute }"  ;;
esac

killall aosd_cat &> /dev/null
echo "$a" |  aosd_cat  -p 7 --x-offset=-10 --y-offset=-30 --font="bitstream bold 20" --fore-color="#dfe2e8" --transparency=1 --fade-full=2000

and for ossv4 :

#!/bin/bash

case $1 in
oss_up) a="Volume: `ossmix vol -- +2 | cut -f1 -d. | awk '{print $NF}'`%" ;;
oss_down) a="Volume: `ossmix vol -- -2 | cut -f1 -d. | awk '{print $NF}'`%" ;;
oss_mute) if [ -f ~/.volume ]; then
        ossmix vol `cat ~/.volume` ; a="Unmute"
        rm ~/.volume
    else
        VOLUME=$(ossmix vol | awk '{print $10}' | awk -F : '{print $1}')
        ossmix vol 0 ; a="Mute"
        echo $VOLUME > ~/.volume
    fi ;;
*) echo "Usage: $0 {oss_up | oss_down | oss_mute }"  ;;
esac

killall aosd_cat &> /dev/null
echo "$a" |  aosd_cat  -p 7 --x-offset=-10 --y-offset=-30 --font="bitstream bold 20" --fore-color="#dfe2e8" --transparency=1 --fade-full=2000

Offline

#3 2009-05-17 19:15:56

nawitus
Member
Registered: 2009-05-11
Posts: 112

Re: Quick and dirty volume notification text

Good ideas. I've updated my script to have a small shadow too lol, and a slider.

#!/bin/bash
var=$(amixer get Master | grep "Front Left:")
var=$(echo "$var" | sed -ne 's/^[^[]*\[\([^]]*\)\].*/\1/p')
killall osd_cat
osd_cat --font='-b&h-lucida-medium-r-normal-*-18-*-*-*-p-*-iso10646-1' \
   --color=green \
   --pos=middle \
   --align=center \
   --delay=1 \
   --shadow=1 \
   --barmode=percentage \
   --percentage=$var \
   --text="VOLUME $var" \

Offline

#4 2009-05-19 17:45:27

ap_
Member
From: Finland
Registered: 2008-10-14
Posts: 48

Re: Quick and dirty volume notification text

Thanks to both of you! Libaosd looks really smooth smile Now everything is starting to work and look the way I want on my laptop, yey!

I edited the script to fit me better;

#!/bin/bash
#
case $1 in
volup) a="Volume: `amixer sset PCM 2%+ unmute | grep Left: | awk '{ gsub(/\[/, " "); gsub(/%\]/, " "); print $5 }'`%" ;;
voldown) a="Volume: `amixer sset PCM 2%- unmute | grep Left: | awk '{ gsub(/\[/, " "); gsub(/%\]/, " "); print $5 }'`%" ;;
next) a="Next: `mpc next|head -1`";;
prev) a="Previous: `mpc prev|head -1`";;
np) a="np: `mpc|head -1`";;

mute)
case `amixer set PCM toggle | grep Left: | awk '{ gsub(/\[/, " "); gsub(/%\]/, " "); print $7 }' | cut -f1 -d]` in
            on) a="Unmute" ;;
             *) a="Mute" ;;
             esac ;;
*) echo "Usage: $0 { up | down | mute }"  ;;
esac

killall aosd_cat &> /dev/null
echo "$a" |  aosd_cat --fore-color=white --font="bitstream bold 20" -p 7 --x-offset=-10 --y-offset=-30 --transparency=1 --fade-full=2500

Last edited by ap_ (2009-05-19 18:05:02)

Offline

Board footer

Powered by FluxBB