add volumesh
This commit is contained in:
parent
89aca822df
commit
183602bc79
|
@ -11,7 +11,7 @@ markup=1
|
||||||
actions=1
|
actions=1
|
||||||
layer=overlay
|
layer=overlay
|
||||||
|
|
||||||
[app-name=pavolume]
|
[app-name=volumesh]
|
||||||
default-timeout=5000
|
default-timeout=5000
|
||||||
group-by=app-name
|
group-by=app-name
|
||||||
format=<b>%s</b>\n%b
|
format=<b>%s</b>\n%b
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -182,7 +182,7 @@
|
||||||
bindsym Print exec grim $(xdg-user-dir PICTURES || Imagens)/$(date +'%Y-%m-%d-%H%M%S_grim.png')
|
bindsym Print exec grim $(xdg-user-dir PICTURES || Imagens)/$(date +'%Y-%m-%d-%H%M%S_grim.png')
|
||||||
|
|
||||||
# Screen area to file
|
# 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
|
# Screen area to clipboard
|
||||||
bindsym Control+Shift+Print exec grim -g "$(slurp)" - | wl-copy
|
bindsym Control+Shift+Print exec grim -g "$(slurp)" - | wl-copy
|
||||||
|
@ -203,15 +203,10 @@
|
||||||
for_window [app_id="pavucontrol"] floating enable
|
for_window [app_id="pavucontrol"] floating enable
|
||||||
|
|
||||||
# Volume controll
|
# Volume controll
|
||||||
{%@@ if exists_in_path ( 'pavolume' ) @@%}
|
# script in dotfiles
|
||||||
bindsym --locked XF86AudioRaiseVolume exec pavolume volup 5%
|
bindsym --locked XF86AudioRaiseVolume exec volumesh -i 10
|
||||||
bindsym --locked XF86AudioLowerVolume exec pavolume voldown 5%
|
bindsym --locked XF86AudioLowerVolume exec volumesh -d 10
|
||||||
bindsym --locked XF86AudioMute exec pavolume mutetoggle
|
bindsym --locked XF86AudioMute exec volumesh -t
|
||||||
{%@@ 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 @@%}
|
|
||||||
|
|
||||||
# Media player controls
|
# Media player controls
|
||||||
{%@@ if exists_in_path ( 'playerctl' ) @@%}
|
{%@@ if exists_in_path ( 'playerctl' ) @@%}
|
||||||
|
|
Reference in New Issue