eww timings

This commit is contained in:
soraefir
2026-06-14 12:37:21 +02:00
parent 65b88e8c55
commit d5ea865a4e
8 changed files with 38 additions and 33 deletions

View File

@@ -14,10 +14,10 @@
:orientation "v"
(label :show-truncated false
:class "hour"
:text {hour})
:text {time.hour})
(label :show-truncated false
:class "minute"
:text {minute}))
:text {time.minute}))
(revealer
:reveal date_rev
(box
@@ -25,10 +25,10 @@
:orientation "v"
(label :show-truncated "false"
:class "day"
:text {day})
:text {time.day})
(label :show-truncated "false"
:class "month"
:text {month}))
:text {time.month}))
)
)
)
@@ -36,7 +36,5 @@
)
)
(defpoll hour :interval "15s" "date '+%H'")
(defpoll minute :interval "15s" "date '+%M'")
(defpoll day :interval "15s" "date '+%d'")
(defpoll month :interval "15s" "date '+%m'")
(defpoll time :interval "15s" "date '+{\"hour\":\"%H\",\"minute\":\"%M\",\"day\":\"%d\",\"month\":\"%m\"}'")

View File

@@ -22,7 +22,8 @@ case "$1" in
*)
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
udevadm monitor --udev --subsystem-match=backlight 2>/dev/null | while read -r _; do
gen_output
done
;;
esac

View File

@@ -27,8 +27,8 @@ pipe="$tmp/bt-events"
mkfifo "$pipe"
trap 'rm -rf "$tmp"; kill 0 2>/dev/null' EXIT INT TERM
# Poll every 2s as reliable fallback for missed events
(while true; do sleep 2; echo poll; done) > "$pipe" &
# Poll every 10s as reliable fallback for missed events
(while true; do sleep 10; echo poll; done) > "$pipe" &
# bluetoothctl monitor for reactive device connect/disconnect events
(bluetoothctl monitor 2>/dev/null | grep --line-buffered -E "Powered|Connected|Device") > "$pipe" &

View File

@@ -22,8 +22,8 @@ pipe="$tmp/bt-dev-events"
mkfifo "$pipe"
trap 'rm -rf "$tmp"; kill 0 2>/dev/null' EXIT INT TERM
# Poll every 3s as fallback for missed events
(while true; do sleep 3; echo poll; done) > "$pipe" &
# Poll every 10s as fallback for missed events
(while true; do sleep 10; echo poll; done) > "$pipe" &
# Reactive updates from D-Bus
(bluetoothctl monitor 2>/dev/null | grep --line-buffered -E "Connected|Device|Powered") > "$pipe" &

View File

@@ -1,9 +1,15 @@
#!/usr/bin/env bash
current=$(eww state 2>/dev/null | grep '^power-save:' | awk '{print $2}')
if [ "$current" = "true" ]; then
case "$1" in
status)
powerprofilesctl get | grep -q power-saver && echo true || echo false
;;
*)
if powerprofilesctl get | grep -q power-saver; then
powerprofilesctl set balanced 2>/dev/null || true
echo false
else
else
powerprofilesctl set power-saver 2>/dev/null || true
echo true
fi
fi
;;
esac

View File

@@ -33,8 +33,8 @@ case "$1" in
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" &
# 2s polling fallback
(while true; do sleep 2; echo poll; done) > "$pipe" &
# PipeWire property-change events (fires on mute/volume change)
(pw-cli -m 2>/dev/null | grep --line-buffered "changed") > "$pipe" &

View File

@@ -69,8 +69,8 @@
; --- Quick Actions ---
(defvar power-save false)
(defvar night-light false)
(defpoll power-save :interval "5s" :initial "false" "scripts/power-save status")
(defpoll night-light :interval "5s" :initial "false" "scripts/nightlight status")
(defwidget quick-btn [icon label onclick active]
(button :class "quick-btn ${active ? 'quick-btn-active' : ''}"
@@ -85,8 +85,8 @@
(box :orientation "v" :space-evenly false :class "quick-grid" :spacing 4
(box :orientation "h" :space-evenly true
(quick-btn :icon "󰸉" :label "Wallpaper" :onclick "scripts/wallpaper" :active false)
(quick-btn :icon "󱐋" :label "Power Save" :onclick "eww update power-save=$(scripts/power-save)" :active {power-save})
(quick-btn :icon "󰌵" :label "Night Light" :onclick "eww update night-light=$(scripts/nightlight)" :active {night-light}))
(quick-btn :icon "󱐋" :label "Power Save" :onclick "scripts/power-save" :active {power-save})
(quick-btn :icon "󰌵" :label "Night Light" :onclick "scripts/nightlight" :active {night-light}))
(box :orientation "h" :space-evenly true
(quick-btn :icon "󰹑" :label "Screenshot" :onclick "scripts/screenshot" :active false)
(quick-btn :icon "󰌾" :label "Lock" :onclick "scripts/lock" :active false)

View File

@@ -1,11 +1,11 @@
(defpoll swap :interval "5s" "scripts/sys/swap")
(defpoll swap :interval "30s" "scripts/sys/swap")
(defpoll cpu-freq-min :interval "60s"
"awk '{print $1/1000}' /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq")
(defpoll cpu-freq-max :interval "60s"
"awk '{print $1/1000}' /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq")
(defpoll cpu-temp :interval "2s"
(defpoll cpu-temp :interval "4s"
"scripts/sys/cputemp")
(defpoll cpu-freq-avg :interval "2s"
"awk '{sum+=$1; count++} END {printf \"%.1f\", sum/count/1000000}' /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq")