Last active
December 29, 2015 15:09
-
-
Save bijanebrahimi/7688456 to your computer and use it in GitHub Desktop.
AwesomeWM Progressbar Volume Changer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
STEP="10" | |
UNIT="%" | |
SETVOL="/usr/bin/amixer -q sset Master" | |
STATE=$(amixer get Master | grep Left | egrep 'Playback.*?\[o' | egrep -o '\[o.+\]') | |
case "$1" in | |
"up") | |
if [[ $STATE == '[off]' ]]; then | |
$SETVOL unmute | |
fi | |
$SETVOL $STEP$UNIT+ | |
;; | |
"mute") | |
$SETVOL toggle | |
;; | |
"down") | |
$SETVOL $STEP$UNIT- | |
;; | |
esac | |
STATE=$(amixer get Master | grep Left | egrep 'Playback.*?\[o' | egrep -o '\[o.+\]') | |
VOLUME=$(amixer get Master | grep 'Front Left:' | grep -E -o "[0-9]+%" | tr -d %) | |
if [[ $VOLUME == 0 ]]; then | |
##echo 'volnotiicon="/usr/share/awesome/icons/noti/volbar/bar_00.png"' | awesome-client | |
echo "volnoti('Volume', '🔈 0%', '□□□□□□□□□□')" | awesome-client | |
else | |
ICON='🔉' | |
if [[ $STATE == '[off]' ]]; then | |
ICON='🔇' | |
fi | |
COUNT=$(echo "$VOLUME / 10 - 1" | bc) | |
PROGRESS="" | |
for (( i=0; i<10; i++)) | |
do | |
if [ "$COUNT" -ge "$i" ]; then | |
PROGRESS="$PROGRESS■" | |
else | |
PROGRESS="$PROGRESS□" | |
fi | |
done | |
echo $VOL $PROGRESS | |
echo "volnoti('Volume', '$ICON $VOLUME%', '$PROGRESS')" | awesome-client | |
fi | |
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Notifiction | |
-- Add this to somewhere in beginning of your rc.lua | |
function closeLastNoti(title) | |
screen = mouse.screen | |
for p,pos in pairs(naughty.notifications[screen]) do | |
for i,n in pairs(naughty.notifications[screen][p]) do | |
if (n.width == 258) then -- to close only previous bright/vol notifications | |
naughty.destroy(n) | |
end | |
end | |
end | |
end | |
function volnoti(title, info, progress) | |
closeLastNoti(title) | |
naughty.notify{ | |
position = "bottom_right", | |
-- fg = "#0a0a0b", | |
-- bg = "#426797", | |
timeout = 2, | |
width = 256, | |
title = title, | |
text = "<span>" .. info .. " " .. progress .."</span>" | |
} | |
end | |
-- GlobalKeys bind | |
-- Add this to your globalkeys table | |
awful.key({}, "XF86AudioRaiseVolume", function () awful.util.spawn("bash /usr/local/bin/awesome-volume.sh up" ) end, | |
"Volume up"), | |
awful.key({}, "XF86AudioLowerVolume", function () awful.util.spawn("bash /usr/local/bin/awesome-volume.sh down") end, | |
"Volume down"), | |
awful.key({}, "XF86AudioMute", function () awful.util.spawn("bash /usr/local/bin/awesome-volume.sh mute") end, | |
"Volume mute"), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment