Redesign Eww bars
This commit is contained in:
30
modules/home/wayland/apps/eww/bar/scripts/unused/brightness
Executable file
30
modules/home/wayland/apps/eww/bar/scripts/unused/brightness
Executable file
@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
function get_time_ms {
|
||||
date -u +%s%3N
|
||||
}
|
||||
|
||||
icons=("" "" "")
|
||||
|
||||
gen_output() {
|
||||
icon="${icons[$(awk -v n="$(brillo)" 'BEGIN{print int(n/34)}')]}"
|
||||
prcnt=$(brillo | xargs printf "%.*f\n" "0")
|
||||
echo '{"percent": '$prcnt', "icon": "'$icon'"}'
|
||||
}
|
||||
|
||||
if [[ $(brillo 2>/dev/stdout 1>/dev/null | head -n1 | awk '{print $1}') == "No" ]]; then
|
||||
echo '{"percent": 100, "icon": ""}'
|
||||
elif [ "$1" = "" ]; then
|
||||
# initial
|
||||
last_time=$(get_time_ms)
|
||||
gen_output
|
||||
|
||||
udevadm monitor | rg --line-buffered "backlight" | while read -r _; do
|
||||
current_time=$(get_time_ms)
|
||||
delta=$((current_time - last_time))
|
||||
if [[ $delta -gt 50 ]]; then
|
||||
gen_output
|
||||
last_time=$(get_time_ms)
|
||||
fi
|
||||
done
|
||||
fi
|
23
modules/home/wayland/apps/eww/bar/scripts/unused/flightmode
Executable file
23
modules/home/wayland/apps/eww/bar/scripts/unused/flightmode
Executable file
@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
|
||||
icon() {
|
||||
[ "$STATUS" = "no" ] && echo "" || echo ""
|
||||
}
|
||||
|
||||
toggle() {
|
||||
if [ "$STATUS" = "no" ]; then
|
||||
rfkill block all
|
||||
else
|
||||
rfkill unblock all
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "$1" = "toggle" ]; then
|
||||
toggle
|
||||
else
|
||||
icon
|
||||
rfkill event | while read -r _; do
|
||||
STATUS="$(rfkill list | sed -n 2p | awk '{print $3}')"
|
||||
icon
|
||||
done
|
||||
fi
|
20
modules/home/wayland/apps/eww/bar/scripts/unused/powermode
Executable file
20
modules/home/wayland/apps/eww/bar/scripts/unused/powermode
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
|
||||
icon() {
|
||||
[ "$STATUS" = "no" ] && echo "" || echo ""
|
||||
}
|
||||
|
||||
toggle() {
|
||||
if [ "$STATUS" = "no" ]; then
|
||||
echo ""
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "$1" = "toggle" ]; then
|
||||
toggle
|
||||
icon
|
||||
else
|
||||
icon
|
||||
fi
|
64
modules/home/wayland/apps/eww/bar/scripts/unused/volume
Executable file
64
modules/home/wayland/apps/eww/bar/scripts/unused/volume
Executable file
@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
function get_time_ms {
|
||||
date -u +%s%3N
|
||||
}
|
||||
|
||||
volicons=("" "" "")
|
||||
|
||||
vol() {
|
||||
wpctl get-volume @DEFAULT_AUDIO_"$1"@ | awk '{print int($2*100)}'
|
||||
}
|
||||
ismuted() {
|
||||
wpctl get-volume @DEFAULT_AUDIO_"$1"@ | rg -qi muted
|
||||
echo -n $?
|
||||
}
|
||||
setvol() {
|
||||
wpctl set-volume @DEFAULT_AUDIO_"$1"@ "$(awk -v n="$2" 'BEGIN{print (n / 100)}')"
|
||||
}
|
||||
setmute() {
|
||||
wpctl set-mute @DEFAULT_AUDIO_"$1"@ toggle
|
||||
}
|
||||
|
||||
gen_output() {
|
||||
percent="$(vol "SINK")"
|
||||
lvl=$(awk -v n="$percent" 'BEGIN{print int(n/34)}')
|
||||
ismuted=$(ismuted "SINK")
|
||||
|
||||
if [ "$ismuted" = 1 ]; then
|
||||
icon="${volicons[$lvl]}"
|
||||
else
|
||||
icon=""
|
||||
fi
|
||||
|
||||
echo '{"icon": "'$icon'", "percent": '$(vol "SINK")', "microphone": '$(vol "SOURCE")'}'
|
||||
}
|
||||
|
||||
if [ "$1" = "mute" ]; then
|
||||
if [ "$2" != "SOURCE" ] && [ "$2" != "SINK" ]; then
|
||||
echo "Can only mute SINK or SOURCE"
|
||||
exit 1
|
||||
fi
|
||||
setmute "$2"
|
||||
elif [ "$1" = "setvol" ]; then
|
||||
if [ "$2" != "SOURCE" ] && [ "$2" != "SINK" ]; then
|
||||
echo "Can only set volume for SINK or SOURCE"
|
||||
exit 1
|
||||
elif [ "$3" -lt 0 ] || [ "$3" -gt 100 ]; then
|
||||
echo "Volume must be between 0 and 100"
|
||||
exit 1
|
||||
fi
|
||||
setvol "$2" "$3"
|
||||
else
|
||||
last_time=$(get_time_ms)
|
||||
gen_output
|
||||
|
||||
pw-cli -m 2>/dev/null | rg --line-buffered "PipeWire:Interface:Client" | while read -r event; do
|
||||
current_time=$(get_time_ms)
|
||||
delta=$((current_time - last_time))
|
||||
if [[ $delta -gt 50 ]]; then
|
||||
gen_output
|
||||
last_time=$(get_time_ms)
|
||||
fi
|
||||
done
|
||||
fi
|
Reference in New Issue
Block a user