From 7959ca01ba4d406d53f2acbc3c76d656a8791e0a Mon Sep 17 00:00:00 2001 From: inigoortega Date: Thu, 25 Jul 2019 17:49:30 +0200 Subject: [PATCH] Now uses CapsLock to avoid blanking screen on fs --- .mkshrc | 1 + .profile | 1 + .xinitrc | 4 +-- .xscreensaver | 2 +- .zshrc | 1 + scripts/xscreensaverstopper.sh | 56 ++++++++++++++++++++++++++++++++++ 6 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 scripts/xscreensaverstopper.sh diff --git a/.mkshrc b/.mkshrc index 0ba747d..357a3ee 100644 --- a/.mkshrc +++ b/.mkshrc @@ -18,6 +18,7 @@ export ANDROID_MOUNTPOINT="$HOME/Android" export BRIGHTNESS="0.9" export SUDO_ASKPASS="/usr/bin/x11-ssh-askpass" export TRASH="$HOME/.local/trash" +export DEVICES_FOLDER="/media" # custom prompt see http://comments.gmane.org/gmane.os.miros.mksh/126 # USER diff --git a/.profile b/.profile index 2d509e2..ee31796 100644 --- a/.profile +++ b/.profile @@ -19,3 +19,4 @@ export ANDROID_MOUNTPOINT="$HOME/Android" export BRIGHTNESS="0.9" export SUDO_ASKPASS="/usr/bin/x11-ssh-askpass" export TRASH="$HOME/.local/trash" +export DEVICES_FOLDER="/media" diff --git a/.xinitrc b/.xinitrc index 17443c1..d3cc75b 100644 --- a/.xinitrc +++ b/.xinitrc @@ -4,9 +4,9 @@ mksh $SCRIPTS/set-random-wallpaper.sh & redshift & workrave & unclutter --jitter 100 -b -mksh $TSCRIPTS/brightness.sh +# mksh $TSCRIPTS/brightness.sh xscreensaver -no-splash & -mksh $SCRIPTS/xscreensaverstopper.sh & +mksh $SCRIPTS/xscreensaverstopper.sh > $HOME/xscreensaverstopper.log 2>&1 & setxkbmap gb # RUN WM diff --git a/.xscreensaver b/.xscreensaver index 0283ab2..065b13f 100644 --- a/.xscreensaver +++ b/.xscreensaver @@ -1,5 +1,5 @@ # XScreenSaver Preferences File -# Written by xscreensaver-demo 5.42 for initega on Mon Jul 8 14:01:31 2019. +# Written by xscreensaver-demo 5.42 for initega on Thu Jul 25 16:07:00 2019. # https://www.jwz.org/xscreensaver/ timeout: 0:05:00 diff --git a/.zshrc b/.zshrc index 1044284..0327a86 100644 --- a/.zshrc +++ b/.zshrc @@ -100,6 +100,7 @@ export ANDROID_MOUNTPOINT="$HOME/Android" export BRIGHTNESS="0.9" export SUDO_ASKPASS="/usr/bin/x11-ssh-askpass" export TRASH="$HOME/.local/trash" +export DEVICES_FOLDER="/media" # # ALIASES diff --git a/scripts/xscreensaverstopper.sh b/scripts/xscreensaverstopper.sh new file mode 100644 index 0000000..67ab9c7 --- /dev/null +++ b/scripts/xscreensaverstopper.sh @@ -0,0 +1,56 @@ +#!/bin/sh +# xscreensaverstopper.sh + +# This script is licensed under GNU GPL version 2.0 or above + +# Uses elements from lightsOn.sh +# Copyright (c) 2011 iye.cba at gmail com +# url: https://github.com/iye/lightsOn +# This script is licensed under GNU GPL version 2.0 or above + +# Description: Restarts xscreensaver's idle countdown while +# full screen applications are running. +# Checks every 30 seconds to see if a full screen application +# has focus, if so then the xscreensaver is told to restart +# its idle countdown. + + +# enumerate all the attached screens +tmp_file="/tmp/xscreensaverstopper$(date +%s)" +xvinfo | sed -n 's/^screen #\([0-9]\+\)$/\1/p' > $tmp_file +displays="" +while read id +do + displays="$displays $id" +done< $tmp_file + +checkFullscreen() +{ + + # loop through every display looking for a fullscreen window + for display in $displays + do + #get id of active window and clean output + activ_win_id=`DISPLAY=:0.${display} xprop -root _NET_ACTIVE_WINDOW | \ + cut -c 41-49` + # activ_win_id="$(echo "$activ_win_id" | cut -c 41-49 )" + + # Check if Active Window (the foremost window) is in fullscreen state + isActivWinFullscreen=`DISPLAY=:0.${display} xprop -id $activ_win_id | \ + grep _NET_WM_STATE_FULLSCREEN` + if [ -n "$isActivWinFullscreen" -a -z "${isActivWinFullscreen##*NET_WM_STATE_FULLSCREEN*}" ]; then + # xscreensaver-command -deactivate + # xscreensaver-command -exit + # xscreensaver-command -restart + xdotool key Caps_Lock && xdotool key Caps_Lock + # else + # xscreensaver -no-splash & + fi + done +} + +while sleep $(( 30 )); do + checkFullscreen +done + +exit 0