From ad37463416735a73d4b9bbdbd19eb72acd61be44 Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Fri, 3 Jan 2025 14:15:20 -0600 Subject: [PATCH] photoframe: Start photo slide show on idle The `photoframe` script was based on the one used by the original Buildroot-based photo frame system. I've split it into two processes, though: one to listen to the URL stream and download new photos as instructed by the server, and another to actually display the photos. Getting `feh` and Firefox to both be fullscreen at the same time was difficult, and only works if they are on separate Sway workspaces. Thus, "activating" the slide show means switching to the workspace where `feh` is and "deactivating" it means switching back to Firefox's workspace. --- install.packages | 5 +++- overlay/etc/sway/kiosk.conf | 8 ++++++ overlay/usr/bin/photoframe | 46 ++++++++++++++++++++++++++++++++++ portage/package.use/photoframe | 5 ++++ 4 files changed, 63 insertions(+), 1 deletion(-) create mode 100755 overlay/usr/bin/photoframe create mode 100644 portage/package.use/photoframe diff --git a/install.packages b/install.packages index 1c92159..600e5b5 100644 --- a/install.packages +++ b/install.packages @@ -1,3 +1,6 @@ +gui-apps/swayidle gui-wm/sway -net-wireless/wpa_supplicant +media-gfx/feh media-video/pipewire +net-misc/curl +net-wireless/wpa_supplicant diff --git a/overlay/etc/sway/kiosk.conf b/overlay/etc/sway/kiosk.conf index 590fdde..956f768 100644 --- a/overlay/etc/sway/kiosk.conf +++ b/overlay/etc/sway/kiosk.conf @@ -7,5 +7,13 @@ input * { } exec /usr/lib64/firefox/firefox +exec /usr/bin/photoframe stream + +exec swayidle -w \ + timeout 120 'photoframe show' resume 'photoframe hide' for_window [title="Mozilla Firefox"] fullscreen +for_window [class="photoframe"] fullscreen + +assign [title="Mozilla Firefox"] 1 +assign [class="photoframe"] 2 diff --git a/overlay/usr/bin/photoframe b/overlay/usr/bin/photoframe new file mode 100755 index 0000000..d1ebdab --- /dev/null +++ b/overlay/usr/bin/photoframe @@ -0,0 +1,46 @@ +#!/bin/sh + +photoframe_hide() { + swaymsg 'workspace 1' +} + +photoframe_show() { + # Run on a separate workspace so Firefox can stay fullscreen, too + swaymsg 'workspace 2' + if [ -f /tmp/photoframe.pid ]; then + # feh is already running + return 0 + fi + if [ ! -f /tmp/photoframe-current ]; then + cp /usr/share/feh/images/feh.png /tmp/photoframe-current + fi + feh -FZ --draw-exif --class photoframe /tmp/photoframe-current & + # Wait for the feh window to actually appear ... + swaymsg -t subscribe '["window"]' + # Sometimes, Sway's `for_window ... fullscreen` doesn't work? + swaymsg fullscreen + echo $! > /tmp/photoframe.pid +} + +photoframe_stream() { + while :; do + curl -NsS https://photos.pyrocufflink.blue/stream | + while read url; do + curl -fsL -o /tmp/photoframe-next "${url}" || continue + mv /tmp/photoframe-next /tmp/photoframe-current + done + sleep 30 + done +} + +case $1 in +show) + photoframe_show + ;; +hide) + photoframe_hide + ;; +stream) + photoframe_stream + ;; +esac diff --git a/portage/package.use/photoframe b/portage/package.use/photoframe new file mode 100644 index 0000000..9888bdf --- /dev/null +++ b/portage/package.use/photoframe @@ -0,0 +1,5 @@ +gui-apps/swayidle -systemd +gui-libs/wlroots X +gui-wm/sway X +media-gfx/feh exif inotify +net-misc/curl -alt-svc -ftp -hsts -http3 -imap -pop3 -progress-meter -psl -quic -smtp -tftp -websockets -adns -http2 CURL_QUIC: -*