add quick actions tab
This commit is contained in:
28
modules/home/wayland/apps/eww/bar/scripts/brightness
Executable file
28
modules/home/wayland/apps/eww/bar/scripts/brightness
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
BACKLIGHT="/sys/class/backlight"
|
||||
DEV=$(ls "$BACKLIGHT" 2>/dev/null | head -n1)
|
||||
|
||||
gen_output() {
|
||||
if [ -z "$DEV" ]; then
|
||||
echo '{"percent":0,"available":false}'
|
||||
return
|
||||
fi
|
||||
max=$(cat "$BACKLIGHT/$DEV/max_brightness")
|
||||
cur=$(cat "$BACKLIGHT/$DEV/actual_brightness" 2>/dev/null || cat "$BACKLIGHT/$DEV/brightness")
|
||||
percent=$(awk -v c="$cur" -v m="$max" 'BEGIN{print int(c/m*100+0.5)}')
|
||||
printf '{"percent":%d,"available":true}\n' "$percent"
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
set)
|
||||
[ -z "$DEV" ] && exit 0
|
||||
brightnessctl -d "$DEV" set "${2}%" -q 2>/dev/null
|
||||
;;
|
||||
*)
|
||||
gen_output
|
||||
[ -z "$DEV" ] && exit 0
|
||||
# Poll for changes every 2s (sysfs files don't support inotify reliably)
|
||||
while true; do sleep 2; gen_output; done
|
||||
;;
|
||||
esac
|
||||
13
modules/home/wayland/apps/eww/bar/scripts/nightlight
Executable file
13
modules/home/wayland/apps/eww/bar/scripts/nightlight
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
case "$1" in
|
||||
status)
|
||||
pgrep -x wlsunset >/dev/null 2>&1 && echo true || echo false
|
||||
;;
|
||||
*)
|
||||
if pgrep -x wlsunset >/dev/null 2>&1; then
|
||||
pkill -x wlsunset && echo false
|
||||
else
|
||||
wlsunset -T 4500 -t 3200 & echo true
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
9
modules/home/wayland/apps/eww/bar/scripts/power-save
Executable file
9
modules/home/wayland/apps/eww/bar/scripts/power-save
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
current=$(eww state 2>/dev/null | grep '^power-save:' | awk '{print $2}')
|
||||
if [ "$current" = "true" ]; then
|
||||
powerprofilesctl set balanced 2>/dev/null || true
|
||||
echo false
|
||||
else
|
||||
powerprofilesctl set power-saver 2>/dev/null || true
|
||||
echo true
|
||||
fi
|
||||
5
modules/home/wayland/apps/eww/bar/scripts/screenshot
Executable file
5
modules/home/wayland/apps/eww/bar/scripts/screenshot
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
DIR="$HOME/Pictures/Screenshots"
|
||||
mkdir -p "$DIR"
|
||||
FILE="$DIR/$(date +%Y-%m-%d_%H-%M-%S).png"
|
||||
grim -g "$(slurp)" "$FILE" && wl-copy < "$FILE"
|
||||
@@ -12,13 +12,14 @@ gen_output() {
|
||||
lvl=$(awk -v n="$percent" 'BEGIN{print int(n/34)}')
|
||||
sink_muted=$(ismuted "SINK")
|
||||
source_muted=$(ismuted "SOURCE")
|
||||
sink=$(wpctl inspect @DEFAULT_AUDIO_SINK@ 2>/dev/null | grep -m1 'node\.nick' | sed 's/.*= "\(.*\)"/\1/')
|
||||
|
||||
[ "$sink_muted" = 0 ] && icon="" || icon="${volicons[$lvl]}"
|
||||
[ "$sink_muted" = 0 ] && icon="" || icon="${volicons[$lvl]}"
|
||||
[ "$source_muted" = 0 ] && mic_icon="" || mic_icon=""
|
||||
|
||||
printf '{"icon":"%s","percent":%s,"sink_muted":%s,"mic_icon":"%s","microphone":%s,"source_muted":%s}\n' \
|
||||
printf '{"icon":"%s","percent":%s,"sink_muted":%s,"mic_icon":"%s","microphone":%s,"source_muted":%s,"sink":"%s"}\n' \
|
||||
"$icon" "$percent" "$([ "$sink_muted" = 0 ] && echo true || echo false)" \
|
||||
"$mic_icon" "$(vol SOURCE)" "$([ "$source_muted" = 0 ] && echo true || echo false)"
|
||||
"$mic_icon" "$(vol SOURCE)" "$([ "$source_muted" = 0 ] && echo true || echo false)" "$sink"
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
@@ -26,7 +27,18 @@ case "$1" in
|
||||
setvol) setvol "$2" "$3" ;;
|
||||
*)
|
||||
gen_output
|
||||
pw-cli -m 2>/dev/null | rg --line-buffered "PipeWire:Interface:Client" | while read -r _; do
|
||||
|
||||
tmp=$(mktemp -d)
|
||||
pipe="$tmp/vol-events"
|
||||
mkfifo "$pipe"
|
||||
trap 'rm -rf "$tmp"; kill 0 2>/dev/null' EXIT INT TERM
|
||||
|
||||
# 1s polling fallback
|
||||
(while true; do sleep 1; echo poll; done) > "$pipe" &
|
||||
# PipeWire property-change events (fires on mute/volume change)
|
||||
(pw-cli -m 2>/dev/null | grep --line-buffered "changed") > "$pipe" &
|
||||
|
||||
while IFS= read -r _ < "$pipe"; do
|
||||
gen_output
|
||||
done
|
||||
;;
|
||||
|
||||
2
modules/home/wayland/apps/eww/bar/scripts/wallpaper
Executable file
2
modules/home/wayland/apps/eww/bar/scripts/wallpaper
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env bash
|
||||
nohup bash "$HOME/.config/script/wallpaper.sh" >/dev/null 2>&1 &
|
||||
Reference in New Issue
Block a user