aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Singleton <matt@xcolour.net>2023-02-02 20:07:56 -0600
committerMatt Singleton <matt@xcolour.net>2023-02-02 20:07:56 -0600
commite512f4cdd8cc4761245c55983f0527bd93e6503c (patch)
treea858e514fad94ea1340e751b38b1ffb991545caf
parent6035311e447acb0e734505afe500237bd8872df0 (diff)
use wob to show status when setting volume and brightness
-rwxr-xr-xbin/setbright23
-rwxr-xr-xbin/setvol23
-rw-r--r--config/sway/config10
-rw-r--r--config/wob/wob.ini6
4 files changed, 55 insertions, 7 deletions
diff --git a/bin/setbright b/bin/setbright
new file mode 100755
index 0000000..42cd48f
--- /dev/null
+++ b/bin/setbright
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+set -euo pipefail
+
+current=$(brightnessctl -m info | cut -d, -f4 | tr --delete '%')
+case $1 in
+ up)
+ increment=$(( 5 - ( current % 5 ) ))
+ new=$(( current + increment ))
+ if [ $new -gt 100 ]; then
+ new=100
+ fi
+ brightnessctl set $new% > /dev/null 2>&1
+ echo $new;;
+ down)
+ increment=$(( ( ( current - 1 ) % 5 ) + 1 ))
+ new=$(( current - increment ))
+ if [ $new -lt 0 ]; then
+ new=0
+ fi
+ brightnessctl set $new% > /dev/null 2>&1
+ echo $new;;
+esac
diff --git a/bin/setvol b/bin/setvol
new file mode 100755
index 0000000..bf9cbed
--- /dev/null
+++ b/bin/setvol
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+set -euo pipefail
+
+current_volume=$(pactl get-sink-volume @DEFAULT_SINK@ | grep Volume | sed -e 's/.* \([0-9][0-9]*\)%.*/\1/')
+case $1 in
+ up)
+ increment=$(( 5 - ( current_volume % 5 ) ))
+ newvol=$(( current_volume + increment ))
+ if [ $newvol -gt 100 ]; then
+ newvol=100
+ fi
+ pactl set-sink-volume @DEFAULT_SINK@ $newvol%
+ echo $newvol;;
+ down)
+ increment=$(( ( ( current_volume - 1 ) % 5 ) + 1 ))
+ newvol=$(( current_volume - increment ))
+ if [ $newvol -lt 0 ]; then
+ newvol=0
+ fi
+ pactl set-sink-volume @DEFAULT_SINK@ $newvol%
+ echo $newvol;;
+esac
diff --git a/config/sway/config b/config/sway/config
index 5e951d2..a2a0284 100644
--- a/config/sway/config
+++ b/config/sway/config
@@ -69,13 +69,7 @@ output * background /usr/share/backgrounds/sway/Sway_Wallpaper_Blue_1366x768.png
### wob indicator
set $WOBSOCK $XDG_RUNTIME_DIR/wob.sock
-exec rm -f $WOBSOCK && mkfifo $WOBSOCK && tail -f $WOBSOCK | \
- wob --border-color "#676364ff" \
- --background-color "#dee2e0ff" \
- --bar-color "#676364ff" \
- --offset 0 \
- --border 1 \
- --padding 5
+exec rm -f $WOBSOCK && mkfifo $WOBSOCK && tail -f $WOBSOCK | wob
### Key bindings
#
@@ -110,6 +104,8 @@ exec rm -f $WOBSOCK && mkfifo $WOBSOCK && tail -f $WOBSOCK | \
bindsym XF86AudioLowerVolume exec ~/.local/bin/setvol down > $WOBSOCK
bindsym XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle
bindsym XF86AudioMicMute exec pactl set-source-mute @DEFAULT_SOURCE@ toggle
+ bindsym XF86MonBrightnessDown exec ~/.local/bin/setbright down > $WOBSOCK
+ bindsym XF86MonBrightnessUp exec ~/.local/bin/setbright up > $WOBSOCK
#bindsym XF86MonBrightnessDown exec brightnessctl set 5%-
#bindsym XF86MonBrightnessUp exec brightnessctl set +5%
#bindsym XF86AudioPlay exec playerctl play-pause
diff --git a/config/wob/wob.ini b/config/wob/wob.ini
new file mode 100644
index 0000000..8205a29
--- /dev/null
+++ b/config/wob/wob.ini
@@ -0,0 +1,6 @@
+border_color=676364
+background_color=dee2e0
+bar_color=676364
+border_offset=0
+border_size=1
+bar_padding=5