Dough Git

commit

Forgot these

commit
eb7876f9079e9be6d41dec1f6217abce5f7ce9f8
author
Clove Twilight <[email protected]>
date
2026-11-07 13:00

diff --git a/README.md b/README.md
index 529bd4e..faa4989 100644
--- a/README.md
+++ b/README.md
@@ -72,7 +72,7 @@ Anything already in the way is renamed to `.bak-<date>`, never deleted.
 | Bluetooth | Bluetooth on/off | Open bluetui | |
 | Volume | Mute | Open pavucontrol | |
 | CPU / RAM | Open btop | | |
-| Picture icon (next to the logo) | Still / animated wallpaper (only plays when plugged in and not in power saver) | | |
+| Picture icon (next to the logo) | Still / animated wallpaper (pauses in power saver or when the battery is at 20% or less) | | |
 | Coffee cup | Stay awake (no auto-lock) | | |
 | Moon | Night light (warm screen) | | |
 | Bell | Notification list (pick one to see it again) | | Do not disturb |
diff --git a/binaries/wallpaper b/binaries/wallpaper
index 3afc912..cb494d3 100755
--- a/binaries/wallpaper
+++ b/binaries/wallpaper
@@ -8,8 +8,9 @@
 #   wallpaper sync      play/stop the video to match power (run by waybar-battery)
 #   wallpaper status    JSON for the waybar button
 #
-# Animated mode only actually plays on AC power and outside power-saver;
-# otherwise the still shows and the button turns amber ("paused").
+# Animated mode plays on AC or battery, but pauses in power-saver or when the
+# battery is discharging at 20% or less; then the still shows and the button
+# turns amber ("paused").
 #
 # The still (sway/config "output * bg") always runs underneath, so stopping
 # the video just reveals it. mpvpaper pauses itself while windows cover it.
@@ -21,14 +22,16 @@ mode() { cat "$STATE" 2>/dev/null || echo static; }
 save() { mkdir -p "$(dirname "$STATE")"; echo "$1" > "$STATE"; }
 refresh() { pkill -RTMIN+9 -x waybar; }
 
-# Should the video run right now? Plugged in and not in power-saver.
+# Should the video run right now? Not in power-saver, and no battery
+# discharging at or below LOW percent.
+LOW=20
 power_ok() {
-  ac=0
-  for f in /sys/class/power_supply/*/online; do
-    [ -r "$f" ] && [ "$(cat "$f")" = 1 ] && ac=1
+  [ "$(powerprofilesctl get 2>/dev/null)" != power-saver ] || return 1
+  for b in /sys/class/power_supply/BAT*; do
+    [ -r "$b/capacity" ] || continue
+    [ "$(cat "$b/status")" = Discharging ] && [ "$(cat "$b/capacity")" -le "$LOW" ] && return 1
   done
-  [ "$ac" = 1 ] || return 1
-  [ "$(powerprofilesctl get 2>/dev/null)" != power-saver ]
+  return 0
 }
 
 start_video() {
@@ -47,7 +50,7 @@ case ${1:-status} in
   animated)
     save animated
     if power_ok; then start_video || save static
-    else notify-send "Animated wallpaper" "Paused until you plug in and leave power-saver"
+    else notify-send "Animated wallpaper" "Paused: power-saver is on, or the battery is at ${LOW}% or less"
     fi
     refresh ;;
   toggle)   if [ "$(mode)" = animated ]; then "$0" static; else "$0" animated; fi ;;
@@ -60,7 +63,7 @@ case ${1:-status} in
     fi ;;
   status)
     if [ "$(mode)" = animated ] && ! pgrep -x mpvpaper >/dev/null; then
-      printf '{"text":"<span color=\\"#E8964A\\">\\udb82\\udd3a</span>","tooltip":"Animated wallpaper paused (on battery or power-saver)\\nClick for the still","class":"paused"}\n'
+      printf '{"text":"<span color=\\"#E8964A\\">\\udb82\\udd3a</span>","tooltip":"Animated wallpaper paused (power-saver, or battery at 20%% or less)\\nClick for the still","class":"paused"}\n'
     elif [ "$(mode)" = animated ]; then
       printf '{"text":"<span color=\\"#5FD4F0\\">\\udb82\\udd3a</span>","tooltip":"Animated wallpaper (click for still)","class":"animated"}\n'
     else
diff --git a/sway/config b/sway/config
index 9c5982a..5f4c98d 100644
--- a/sway/config
+++ b/sway/config
@@ -49,6 +49,10 @@ exec --no-startup-id gnome-keyring-daemon --start --components=secrets,ssh,pkcs1
 exec --no-startup-id wl-paste --type text --watch cliphist store
 exec --no-startup-id wl-paste --type image --watch cliphist store
 
+# Give D-Bus services (screen-sharing portal, etc.) the Wayland session vars.
+# Without this xdg-desktop-portal-wlr can't reach sway, so OBS/browsers can't capture the screen.
+exec dbus-update-activation-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP SWAYSOCK DISPLAY
+
 exec /usr/bin/pipewire
 
 # Cursor Style