[X2Go-Commits] [live-build-x2go] 78/108: almost complete rewrite of 60x11-spawn-configure-slideshow-screensaver, as restoring the foreground app(s) didn't work properly

git-admin at x2go.org git-admin at x2go.org
Wed Mar 20 22:13:21 CET 2019


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch feature/openbox
in repository live-build-x2go.

commit a9c8d50b6579501f044e3a3ccaacee8e0b0df610
Author: Stefan Baur (BAUR-ITCS) <kontakt at baur-itcs.de>
Date:   Sat Jan 12 13:52:20 2019 +0000

    almost complete rewrite of 60x11-spawn-configure-slideshow-screensaver, as restoring the foreground app(s) didn't work properly
---
 .../60x11-spawn-configure-slideshow-screensaver    | 111 ++++++++++++++++-----
 1 file changed, 84 insertions(+), 27 deletions(-)

diff --git a/config/includes.chroot/etc/X11/Xsession.d/60x11-spawn-configure-slideshow-screensaver b/config/includes.chroot/etc/X11/Xsession.d/60x11-spawn-configure-slideshow-screensaver
index dca1fe0..1fa1f68 100644
--- a/config/includes.chroot/etc/X11/Xsession.d/60x11-spawn-configure-slideshow-screensaver
+++ b/config/includes.chroot/etc/X11/Xsession.d/60x11-spawn-configure-slideshow-screensaver
@@ -23,32 +23,89 @@ else
 	IDLE_TIME=$(($XSAVERIDLETIME*1000))
 
 	BLACK=false
-	while sleep 1; do
-		idle=$(xprintidle)
-		[ -z "$idle" ] && exit 1
-		if [ $idle -ge $IDLE_TIME ] && ! $BLACK ; then
-			# hide all things nxproxy
-			ps -C nxproxy -opid= | xargs -n 1 --no-run-if-empty -I XXX xdotool search --pid XXX . | xargs --no-run-if-empty -n 1 xdotool windowunmap
-			if [ $(ls $SLIDESDIR 2>/dev/null| wc -l) -gt 0 ] ; then
-				if ! ps -C feh >/dev/null ; then
-					feh -Y -x -F -D $XSAVERIMGTIME -Z -B black -q "$SLIDESDIR" &
-				fi
-			else
-				xsetroot -solid "#000000"
-			fi
-			BLACK=true
-
-		else
-			if [ $idle -lt $IDLE_TIME ] && $BLACK ; then
-				if ps -C feh >/dev/null; then
-					killall feh
+        while sleep 1; do
+                idle=$(xprintidle)
+                [ -z "$idle" ] && exit 1
+                if [ $idle -ge $IDLE_TIME ] && ! $BLACK ; then
+			# idletime has been exceeded and screen isn't black, so let's take action
+
+			xdotool search --name . set_window --class "hideme" %@ # tag all present windows
+			xsetroot -solid "#000000" # set background to black so the next command doesn't "flash" the screen with the background color
+			xdotool search --class "hideme" windowunmap %@ # now move all windows to the background
+			# if we have local images to show, spawn feh, if it isn't already running
+                        if [ $(ls $SLIDESDIR 2>/dev/null| wc -l) -gt 0 ] ; then
+                                if ! ps -C feh >/dev/null ; then
+                                        feh -Y -x -F -D $XSAVERIMGTIME -Z -B black -q "$SLIDESDIR" &
+                                fi
+                        fi
+
+			BLACK=true # set flag showing that we're done
+
+                else
+                        if [ $idle -lt $IDLE_TIME ] && $BLACK ; then
+				# user action detected and screen is black, so let's take action
+
+				# first, kill feh, if it is running
+                                if ps -C feh >/dev/null; then
+                                        killall feh
+                                fi
+
+				# restore all hidden windows to foreground
+				xdotool search --class "hideme" windowmap %@
+
+				if ps -C nxproxy >/dev/null ; then # do we have an nxproxy task running?
+					# if so, keep kicking it into the foreground until it has focus
+					while [ "$(xdotool getwindowfocus)" != "$(xdotool search --classname "X2GoAgent|NXAgent")" ] ; do
+						xdotool search --classname "X2GoAgent|NXAgent" windowmap --sync windowfocus --sync
+					done
+					# wiggle mouse by 11 px to trigger remote screensaver password prompt (10 px is xscreensaver's default hysteresis)
+					xdotool sleep 0.1 mousemove_relative -- 11 0 sleep 0.1 mousemove_relative -- -11 0
+					## Option: toggle NumLock instead
+					# xdotool sleep 0.1 key Num_Lock sleep 0.1 key Num_Lock
+				elif ps -C Xephyr >/dev/null ; then # do we have a Xephyr task running?
+					# if so, keep kicking it into the foreground until it has focus
+					while [ "$(xdotool getwindowfocus)" != "$(xdotool search --classname "Xephyr")" ] ; do
+						xdotool search --classname "Xephyr" windowmap --sync windowfocus --sync
+					done
+					# wiggle mouse by 11 px to trigger remote screensaver password prompt (10 px is xscreensaver's default hysteresis)
+					xdotool sleep 0.1 mousemove_relative -- 11 0 sleep 0.1 mousemove_relative -- -11 0
+					## Option: toggle NumLock instead
+					# xdotool sleep 0.1 key Num_Lock sleep 0.1 key Num_Lock
+				elif ps -C Xnest >/dev/null ; then # do we have an Xnest task running?
+					# if so, keep kicking it into the foreground until it has focus
+					while [ "$(xdotool getwindowfocus)" != "$(xdotool search --name "^Xnest$")" ] ; do
+						xdotool search --name "^Xnest$" windowmap --sync windowfocus --sync
+					done
+					# wiggle mouse by 11 px to trigger remote screensaver password prompt (10 px is xscreensaver's default hysteresis)
+					xdotool sleep 0.1 mousemove_relative -- 11 0 sleep 0.1 mousemove_relative -- -11 0
+					## Option: toggle NumLock instead
+					# xdotool sleep 0.1 key Num_Lock sleep 0.1 key Num_Lock
+				elif ps -C xfreerdp >/dev/null ; then # do we have an xfreerdp task running?
+					# if so, keep kicking it into the foreground until it has focus
+					while [ "$(xdotool getwindowfocus)" != "$(xdotool search --classname "xfreerdp")" ] ; do
+						xdotool search --classname "xfreerdp" windowmap --sync windowfocus --sync
+					done
+					# wiggle mouse by 11 px to trigger remote screensaver password prompt (10 px is xscreensaver's default hysteresis)
+					xdotool sleep 0.1 mousemove_relative -- 11 0 sleep 0.1 mousemove_relative -- -11 0
+					## Option: toggle NumLock instead
+					# xdotool sleep 0.1 key Num_Lock sleep 0.1 key Num_Lock
+				elif ps -C rdesktop >/dev/null ; then # do we have an rdesktop task running?
+					# if so, keep kicking it into the foreground until it has focus
+					while [ "$(xdotool getwindowfocus)" != "$(xdotool search --classname "rdesktop")" ] ; do
+						xdotool search --classname "rdesktop" windowmap --sync windowfocus --sync
+					done
+					# wiggle mouse by 11 px to trigger remote screensaver password prompt (10 px is xscreensaver's default hysteresis)
+					xdotool sleep 0.1 mousemove_relative -- 11 0 sleep 0.1 mousemove_relative -- -11 0
+					## Option: toggle NumLock instead
+					# xdotool sleep 0.1 key Num_Lock sleep 0.1 key Num_Lock
+				else
+					# if there's no nxproxy/Xephyr/Xnest window, we're likely to be in the login screen, so restore fullscreen X2GoClient Login window
+					xdotool search --onlyvisible --classname "X2GoClient" windowsize --sync 100% 100% || echo $?
 				fi
-				# show all things nxproxy
-				ps -C nxproxy -opid= | xargs -n 1 --no-run-if-empty -I XXX xdotool search --pid XXX . | xargs --no-run-if-empty -n 1 xdotool windowmap
-				# wiggle mouse by 1 px to trigger remote screensaver password prompt
-				xdotool mousemove_relative -- 1 0 ; xdotool mousemove_relative -- -1 0
-				BLACK=false
-			fi
-		fi
-	done &
+
+				xsetroot -solid "#$HEXCOLOR" # restore old background color
+                                BLACK=false
+                        fi
+                fi
+        done &
 fi

--
Alioth's /home/x2go-admin/maintenancescripts/git/hooks/post-receive-email on /srv/git/code.x2go.org/live-build-x2go.git


More information about the x2go-commits mailing list