You are not logged in.
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
Offline
I've made similar script with libaosd , it have pseudo transparency :
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
Good ideas. I've updated my script to have a small shadow too , 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
Thanks to both of you! Libaosd looks really smooth 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