From 7774266ee62dfffbe6582ed9c895a4ce7501ba24 Mon Sep 17 00:00:00 2001 From: Aicaya <17915907+Aicaya@users.noreply.github.com> Date: Thu, 23 Jan 2020 16:27:29 -0400 Subject: [PATCH] Restore previous DPMS setting if turned off (#151) * Restore previous DPMS setting if turned off Added the variable 'default_dpms', which reads the last element of line 26 ("DPMS is Enabled/Disabled"). If it's disabled, it restores that setting upon login. This fixes an issue where if the user had manually turned off DPMS, the screen will still turn itself off after a while. * Look for string instead of line number (also use tabs for indents to match code) --- betterlockscreen | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/betterlockscreen b/betterlockscreen index d4ce078..9d2e07a 100755 --- a/betterlockscreen +++ b/betterlockscreen @@ -7,6 +7,7 @@ # find your resolution so images can be resized to match your screen resolution res=$(xdpyinfo | grep dimensions | sed -r 's/^[^0-9]*([0-9]+x[0-9]+).*$/\1/') default_timeout="$(cut -d ' ' -f4 <<< $(xset q | sed -n '25p'))" +default_dpms=$(xset q | awk '/^[[:blank:]]*DPMS is/ {print $(NF)}') init_filenames() { #$1 resolution @@ -103,6 +104,9 @@ lock() { postlock() { if [ ! -z "$lock_timeout" ]; then xset dpms "$default_timeout" + if [ "$default_dpms" = "Disabled" ]; then + xset -dpms + fi fi if [ ! -z "$(pidof dunst)" ] ; then pkill -u "$USER" -USR2 dunst