You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ublinux-init/ublinux/rc.desktop/all/xss_heartbeat

38 lines
1.1 KiB

#!/bin/sh
# xscreensaver helper scripts
ENABLED=no
[ "$ENABLED" != "yes" ] && exit 0
XSSHBTM=20s
# exit for DE
XSSDEIGNORE="kde,mate"
# exit if process started
XSSEXIT="screensaver"
# stop xss if process started
XSSBLRUNED="kscreenlocker"
# stop xss if process eats resources
XSSBLLOADED="media-play,mplayer,tvtime,firefox,steam,chromium"
/usr/lib/ublinux/functions
. /usr/lib/ublinux/os-config
SOURCE=${SYSCONF}/config; [ -f ${SOURCE} ] && . ${SOURCE} 2>/dev/null
which xscreensaver >/dev/null 2>&1 || exit 0
DE=$(detectDE)
[ "$XSSDEIGNORE" = "all" ] && exit 0
echo " $XSSDEIGNORE " | tr ',;' ' ' | grep -q " $DE " && exit 0
XSSEXIT="$(echo "$XSSEXIT" | tr ',; ' '|' )"
ps -U $(id -un) -o comm | egrep -q "$XSSEXIT" && exit 0
xscreensaver -no-splash &
sleep 1s
while true ;do
XSSBLRUNED="$(echo "$XSSBLRUNED" | tr ',; ' '|' )"
XSSBLLOADED="$(echo "$XSSBLLOADED" | tr ',; ' '|' )"
ps -U $(id -un) -o comm | egrep -q "$XSSBLRUNED" && xscreensaver-command -deactivate >/dev/null 2>&1
top -bn1 -u $(id -un) | awk '{ print $7 FS $NF }' | grep ^[1-9] | egrep -q "$XSSBLLOADED" && xscreensaver-command -deactivate >/dev/null 2>&1
sleep $XSSHBTM
done