From 643ea70aa77686ebe84889943a258b890dffe2fb Mon Sep 17 00:00:00 2001 From: Vivek R <123vivekr@gmail.com> Date: Tue, 28 May 2019 23:18:22 +0530 Subject: [PATCH] Add Timeout Option (#119) This adds an opton to set custom monitor timeout in seconds. Timeout only applicable during lockscreen. Reverts back to normal timeout after logging back in. Closes https://github.com/pavanjadhaw/betterlockscreen/issues/116 --- README.md | 7 ++++++- betterlockscreen | 18 ++++++++++++++++++ examples/betterlockscreenrc | 1 + 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9088117..33529ec 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,7 @@ Run `betterlockscreen` and point it to either a directory (`betterlockscreen -u ```sh usage: betterlockscreen [-u "path/to/img.jpg"] [-l "dim, blur or dimblur"] [-w "dim, blur, pixel or dimblur"] [-t "custom text"] [-s "lockscreen and suspend"] - [-r "resolution"] [-b "factor"] + [-r "resolution"] [-b "factor"] [--off ] betterlockscreen - faster and sweet looking lockscreen for linux systems. @@ -147,6 +147,8 @@ usage: set blur range -r, --resolution res uses a custom resolution + --off, --off + sets custom monitor timeout ( in seconds) Usage examples: @@ -165,6 +167,9 @@ betterlockscreen -l pixel -t "custom lockscreen text" 5. Set desktop background betterlockscreen -w blur # set desktop background with blur effect + +6. Lockscreeen with custom monitor off timeout +betterlockscreen --off 5 -l blur # set monitor off lockscreen timeout (5 seconds) ``` ### Set desktop background on startup diff --git a/betterlockscreen b/betterlockscreen index 8f98f7f..8177415 100755 --- a/betterlockscreen +++ b/betterlockscreen @@ -6,6 +6,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')` init_filenames() { #$1 resolution @@ -70,6 +71,9 @@ init_filenames $res prelock() { + if [ -n lock_timeout ]; then + xset dpms $lock_timeout + fi if [ ! -z "$(pidof dunst)" ]; then pkill -u "$USER" -USR1 dunst fi @@ -96,6 +100,9 @@ lock() { postlock() { + if [ -n lock_timeout ]; then + xset dpms $default_timeout + fi if [ ! -z "$(pidof dunst)" ] ; then pkill -u "$USER" -USR2 dunst fi @@ -375,6 +382,12 @@ usage() { echo ' to set custom lockscreen text (max 31 chars)' echo " E.g: betterlockscreen -l dim -t \"Don't touch my machine!\"" echo ' E.g: betterlockscreen --text "Hi, user!" -s blur' + echo + echo + echo ' --off ' + echo ' to set custom monitor turn off timeout for lockscreen' + echo ' timeout is in seconds' + echo ' E.g: betterlockscreen -l dim --off 5' } @@ -416,6 +429,11 @@ for arg in "$@"; do shift 2 ;; + --off) + lock_timeout="$2" + shift 2 + ;; + -r | --resolution) res="$2" init_filenames $res force diff --git a/examples/betterlockscreenrc b/examples/betterlockscreenrc index 4f4dc0c..0f9c503 100644 --- a/examples/betterlockscreenrc +++ b/examples/betterlockscreenrc @@ -15,3 +15,4 @@ datecolor=ffffffff loginbox=00000066 font="sans-serif" locktext='Type password to unlock...' +lock_timeout=5