From 4bdd817ae1fd6facf490b02ab96f8f233d0ee696 Mon Sep 17 00:00:00 2001 From: John Mertz Date: Mon, 21 Nov 2022 18:44:59 -0500 Subject: [PATCH] New 'fade' action as first step to 'idle' Will take ~1-2s to fade all windows (depending on number of windows. Allows for fullscreen wallpaper for a couple of minutes before next steps. --- sway/idle.sh | 8 ++++++-- sway/window-transparency.py | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/sway/idle.sh b/sway/idle.sh index e11e571..5a47373 100755 --- a/sway/idle.sh +++ b/sway/idle.sh @@ -46,9 +46,13 @@ elif [ $1 == "start" ]; then elif [ $1 == "stop" ]; then pkill swayidle elif [ $1 == "fade" ]; then - $HOME/scripts/sway/fade.pl start + if [ ! -e $HOME/.spool/sway-hidden ]; then + kill -USR2 `cat $HOME/.spool/sway-transparency` + fi elif [ $1 == "unfade" ]; then - $HOME/scripts/sway/fade.pl stop + if [ -e $HOME/.spool/sway-hidden ]; then + kill -USR2 `cat $HOME/.spool/sway-transparency` + fi elif [ $1 == "dim" ]; then echo $($HOME/scripts/thinkpad/blc.pl %) > $BLFILE $HOME/scripts/thinkpad/blc.pl = 1 &>- diff --git a/sway/window-transparency.py b/sway/window-transparency.py index dd97c44..9178307 100755 --- a/sway/window-transparency.py +++ b/sway/window-transparency.py @@ -10,6 +10,7 @@ import i3ipc import signal import sys import os +import time from pathlib import Path from functools import partial @@ -48,6 +49,21 @@ def show_hide(ipc, opacity): else: w.command("opacity "+str(opacity)) +def fade(ipc, opacity): + global flag + if os.path.exists(flag): + show_hide(ipc, opacity) + return + for i in range(1,100): + for workspace in ipc.get_tree().workspaces(): + for w in workspace: + if w.focused: + w.command("opacity "+str(1-(i/100))) + elif float(opacity) >= (i/100): + w.command("opacity "+str(float(opacity)-(i/100))) + time.sleep(0.005) + Path(flag).touch() + def remove_opacity(ipc): global pid global flag @@ -101,6 +117,7 @@ if __name__ == "__main__": for sig in [signal.SIGINT, signal.SIGTERM]: signal.signal(sig, lambda signal, frame: remove_opacity(ipc)) signal.signal(signal.SIGUSR1, lambda signal, frame: show_hide(ipc, opacity)) + signal.signal(signal.SIGUSR2, lambda signal, frame: fade(ipc, opacity)) ipc.on("window::focus", partial(on_window_focus, args.opacity)) ipc.main()