1
0
Fork 0

feat: migrate to i3blocks and autotiling-rs

This commit is contained in:
Oliver Ladner 2026-03-01 14:11:51 +01:00
commit 487870a473
14 changed files with 512 additions and 7 deletions

53
home/oli/bin/i3blocks/audio Executable file
View file

@ -0,0 +1,53 @@
#!/usr/bin/env bash
#
# Display audio volume/mute status
# Depends on signals in sway config for XF86AudioMute, XF86AudioLowerVolume and
# XF86AudioRaiseVolume
. ~/bin/i3blocks/_utils
# Get default audio sink volume and mute status
audio_volume() {
local wpctl_output
wpctl_output=$(wpctl get-volume @DEFAULT_AUDIO_SINK@)
local volume
volume=$(echo "$wpctl_output" | awk '{print $NF * 100}')
local muted
muted=$(echo "$wpctl_output" | grep -c '\[MUTED\]')
local bg fg icon stat
if [[ "$muted" -ge 1 ]]; then
bg=$mute_bg
fg=$mute_fg
stat="$(printf '%.0f' "$volume")%"
elif [[ $(echo "$volume >= 80" | bc -l) == "1" ]]; then
bg=$crit_bg
fg=$crit_fg
stat="$(printf '%.0f' "$volume")%"
elif [[ $(echo "$volume >= 65" | bc -l) == "1" ]]; then
bg=$warn2_bg
fg=$warn2_fg
stat="$(printf '%.0f' "$volume")%"
elif [[ $(echo "$volume >= 50" | bc -l) == "1" ]]; then
bg=$warn1_bg
fg=$warn1_fg
stat="$(printf '%.0f' "$volume")%"
else
stat="$(printf '%.0f' "$volume")%"
fi
if [[ -n "$bg" ]]; then
echo -e "SND <span background=\"$bg\" color=\"$fg\"> $stat </span>\n"
else
echo -e "SND $stat \n"
fi
}
case "$BLOCK_BUTTON" in
1) wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle ;;
4) wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+ --limit 1.0 ;;
5) wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%- ;;
esac
audio_volume