add volumesh

This commit is contained in:
lelgenio 2020-07-15 03:18:27 -03:00
parent 89aca822df
commit 183602bc79
3 changed files with 119 additions and 11 deletions

View File

@ -11,7 +11,7 @@ markup=1
actions=1
layer=overlay
[app-name=pavolume]
[app-name=volumesh]
default-timeout=5000
group-by=app-name
format=<b>%s</b>\n%b

113
dotfiles/scripts/volumesh Executable file
View File

@ -0,0 +1,113 @@
#!/bin/sh
# depends on: awk, pactl, pacmd, notify-send
# FILLED="◼"
# EMPTY="◻"
MAX_VOL=120
STEP=10
FILLED="■"
EMPTY="□"
STRIPPED="▨"
is_muted(){
env LC_ALL=C pacmd list-sinks | grep 'muted: yes' 1> /dev/null
}
get_bar(){
is_muted &&
FILLED=$STRIPPED
round $1 | awk '{
for (i=1;i <= $1/10;i++) {
if ( i == 11 ) {
printf "|";
}
printf "'$FILLED'"
};
for (i=1;i <= 10-$1/10;i++) {
printf "'$EMPTY'"
};
}'
}
get_vol(){
env LC_ALL=C pactl list sinks |
awk '/^\tVolume/ {
gsub(/%/,"");
printf $5;
}'
}
notify(){
volume=$(get_vol)
bar=$(get_bar $volume)
if is_muted ; then
s="Muted"
else
s="Volume"
fi
notify-send "${s}: ${volume}%" "$bar" --app-name=volumesh
}
round(){
echo $1 | awk '{
print int($1/'$STEP')*'$STEP';
}'
}
min(){
printf '%i\n' ${@} | sort -n | head -n1
}
change_vol(){
pactl set-sink-volume @DEFAULT_SINK@ "${1}$(min 120 $2)%"
newvol=$(min $MAX_VOL $(round $(get_vol)))
pactl set-sink-volume @DEFAULT_SINK@ "${newvol}%"
}
toggle_mute(){
pactl set-sink-mute @DEFAULT_SINK@ toggle
}
while [ $# -gt 0 ]
do
case $1 in
-i | --increase)
shift
change_vol + $1
shift
;;
-d | --decrease)
shift
change_vol - $1
shift
;;
-t | --toggle)
toggle_mute
shift
;;
*)
echo outro = $1
shift
;;
esac
done
notify

View File

@ -182,7 +182,7 @@
bindsym Print exec grim $(xdg-user-dir PICTURES || Imagens)/$(date +'%Y-%m-%d-%H%M%S_grim.png')
# Screen area to file
bindsym Shift+Print exec grim -g "$(slurp)" $(xdg-user-dir PICTURES || Imagens)/$(date +'%Y-%m-%d-%H%M%S_grim-slurp.png')
bindsym Shift+Print exec grim -g "$(slurp)" $(xdg-user-dir PICTURES || echo Imagens)/$(date +'%Y-%m-%d-%H%M%S_grim-slurp.png')
# Screen area to clipboard
bindsym Control+Shift+Print exec grim -g "$(slurp)" - | wl-copy
@ -203,15 +203,10 @@
for_window [app_id="pavucontrol"] floating enable
# Volume controll
{%@@ if exists_in_path ( 'pavolume' ) @@%}
bindsym --locked XF86AudioRaiseVolume exec pavolume volup 5%
bindsym --locked XF86AudioLowerVolume exec pavolume voldown 5%
bindsym --locked XF86AudioMute exec pavolume mutetoggle
{%@@ else @@%}
bindsym --locked XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +5%
bindsym --locked XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -5%
bindsym --locked XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle
{%@@ endif @@%}
# script in dotfiles
bindsym --locked XF86AudioRaiseVolume exec volumesh -i 10
bindsym --locked XF86AudioLowerVolume exec volumesh -d 10
bindsym --locked XF86AudioMute exec volumesh -t
# Media player controls
{%@@ if exists_in_path ( 'playerctl' ) @@%}