#!/bin/bash TIMEOUT_STRG=5 # Zeit in Sekunden die bleibt, um STRG zu drücken USER=$(who | awk '/tty7|:0/ {print $1; exit 0}') [ -n "$USER" ] || exit 0 export DISPLAY=:0 export XAUTHORITY=/home/$USER/.Xauthority case $1 in pre) logger -t "SmartSleep" "Das System wechselt in den Energiesparmodus" [ -n "$(pgrep smartsleepd)" ] || logger -t "SmartSleep" -p "user.warning" "Der Daemon läuft nicht!" ;; post) LID_STATUS="$( awk '{print $2}' < /proc/acpi/button/lid/LID0/state )" # open|closed DOCK_STATUS="$( lsusb | grep -iq "Dell dock" && echo "yes" || echo "no" )" if [ "$LID_STATUS" = "open" ] || [ "$DOCK_STATUS" = "yes" ]; then timeout $TIMEOUT_STRG bash -c ' while true; do for n in $( xinput --list | grep keyboard | grep -Po "id=[0-9]+" | cut -c4- ); do if xinput --query-state $n 2> /dev/null | grep down | grep -Eq "(\[37\]|\[105\])"; then exit 1 fi done done' fi if [ "$?" -eq 1 ]; then logger -t "SmartSleep" "Benutzerinteraktion (STRG-Taste)" kill -USR2 $(pgrep -f smartsleepd) else logger -t "SmartSleep" -p "user.warning" "Keine Benutzerinteraktion (STRG-Taste)." kill -USR1 $(pgrep -f smartsleepd) fi ;; esac