add volume control

auto-flake-update
Yorick van Pelt 2012-11-14 21:39:44 +01:00
parent cfb5b698e8
commit edd6a2b6c4
4 changed files with 84 additions and 1 deletions

View File

@ -312,7 +312,10 @@ globalkeys = awful.util.table.join(
awful.key({ modkey, "Control" }, "l", function () awful.util.spawn("xscreensaver-command -lock") end),
-- brightness adjustment
awful.key({ }, "XF86MonBrightnessDown", function() awful.util.spawn("/home/yorick/dotfiles/bin/brightne.sh down") end),
awful.key({ }, "XF86MonBrightnessUp", function() awful.util.spawn("/home/yorick/dotfiles/bin/brightne.sh up") end)
awful.key({ }, "XF86MonBrightnessUp", function() awful.util.spawn("/home/yorick/dotfiles/bin/brightne.sh up") end),
awful.key({ }, "XF86AudioMute", function() awful.util.spawn("/home/yorick/dotfiles/bin/mute_toggle.sh") end),
awful.key({ }, "XF86AudioLowerVolume", function() awful.util.spawn("/home/yorick/dotfiles/bin/vol_down.sh") end),
awful.key({ }, "XF86AudioRaiseVolume", function() awful.util.spawn("/home/yorick/dotfiles/bin/vol_up.sh") end)
)
clientkeys = awful.util.table.join(

34
bin/mute_toggle.sh Executable file
View File

@ -0,0 +1,34 @@
#!/bin/bash
# Credit to Roland Latour
# http://www.freak-search.com/en/thread/4707111/q_volume_control,_xfce
# Find default sink
sink=$(pacmd info|grep "Default sink name"|awk '{print $4}')
# Now we need to get mute status of default sink
# get line# of start of definition for default sink (plus 1, actually)
let line=$(pacmd list-sinks|grep -n $sink|sed '{s/://}'|awk '{print $1}')
# add 12 for "muted" line
let line=($line + 12)
# extract mute status from that line
mute=$(pacmd list-sinks|awk 'NR==i"'"$line"'"{print $2}')
if [[ "$mute" == "yes" ]]; then
# show the volume
# Now we need to find volume of default sink
# get line# of start of definition for default sink (plus 1, actually)
let line=$(pacmd list-sinks|grep -n $sink|sed '{s/://}'|awk '{print $1}')
# index down a bit for volume line
let line=($line + 6)
volume=$(pacmd list-sinks|awk 'NR=="'"$line"'"{print $3}'|sed '{s/%//}')
pacmd set-sink-mute "$sink" 0 > /dev/null 2>&1
volnoti-show $volume
fi
[[ "$mute" == "no" ]] && pacmd set-sink-mute "$sink" 1 > /dev/null 2>&1 && volnoti-show -m

23
bin/vol_down.sh Executable file
View File

@ -0,0 +1,23 @@
#!/bin/bash
# Credit to Roland Latour
# http://www.freak-search.com/en/thread/4707111/q_volume_control,_xfce
# lower volume by 1%
# Find default sink
sink=$(pacmd info|grep "Default sink name"|awk '{print $4}')
# Now we need to find volume of default sink
# get line# of start of definition for default sink (plus 1, actually)
let line=$(pacmd list-sinks|grep -n $sink|sed '{s/://}'|awk '{print $1}')
# index down a bit for volume line
let line=($line + 6)
volume=$(pacmd list-sinks|awk 'NR=="'"$line"'"{print $3}'|sed '{s/%//}')
# pacmd returns volume as %, but demands setting as range: 0-65535
let volume=($volume - 1)
let volume=($volume * 65536);let volume=($volume / 100)
[[ $volume -lt 0 ]] && let volume=0
pacmd set-sink-volume $sink $volume > /dev/null 2>&1
volnoti-show $(((volume * 100) / 65536))

23
bin/vol_up.sh Executable file
View File

@ -0,0 +1,23 @@
#!/bin/bash
# Credit to Roland Latour
# http://www.freak-search.com/en/thread/4707111/q_volume_control,_xfce
# raise volume by 1%
# Find default sink
sink=$(pacmd info|grep "Default sink name"|awk '{print $4}')
# Now we need to find volume of default sink
# get line# of start of definition for default sink (plus 1, actually)
let line=$(pacmd list-sinks|grep -n $sink|sed '{s/://}'|awk '{print $1}')
# index down a bit for volume line
let line=($line + 6)
volume=$(pacmd list-sinks|awk 'NR=="'"$line"'"{print $3}'|sed '{s/%//}')
# pacmd returns volume as %, but demands setting as range: 0-65535
let volume=($volume + 1)
let volume=($volume * 65536);let volume=($volume / 100)
[[ $volume -gt 65536 ]] && let volume=65536
pacmd set-sink-volume $sink $volume > /dev/null 2>&1
volnoti-show $(((volume * 100) / 65536))