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
This commit is contained in:
Vivek R 2019-05-28 23:18:22 +05:30 committed by Pavan Jadhaw
parent 3f5fd23839
commit 643ea70aa7
3 changed files with 25 additions and 1 deletions

View file

@ -123,7 +123,7 @@ Run `betterlockscreen` and point it to either a directory (`betterlockscreen -u
```sh ```sh
usage: betterlockscreen [-u "path/to/img.jpg"] [-l "dim, blur or dimblur"] 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"] [-w "dim, blur, pixel or dimblur"] [-t "custom text"] [-s "lockscreen and suspend"]
[-r "resolution"] [-b "factor"] [-r "resolution"] [-b "factor"] [--off <timeout>]
betterlockscreen - faster and sweet looking lockscreen for linux systems. betterlockscreen - faster and sweet looking lockscreen for linux systems.
@ -147,6 +147,8 @@ usage:
set blur range set blur range
-r, --resolution res -r, --resolution res
uses a custom resolution uses a custom resolution
--off, --off <timeout>
sets custom monitor timeout (<timeout> in seconds)
Usage examples: Usage examples:
@ -165,6 +167,9 @@ betterlockscreen -l pixel -t "custom lockscreen text"
5. Set desktop background 5. Set desktop background
betterlockscreen -w blur # set desktop background with blur effect 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 ### Set desktop background on startup

View file

@ -6,6 +6,7 @@
# find your resolution so images can be resized to match your screen resolution # 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/') 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() { init_filenames() {
#$1 resolution #$1 resolution
@ -70,6 +71,9 @@ init_filenames $res
prelock() { prelock() {
if [ -n lock_timeout ]; then
xset dpms $lock_timeout
fi
if [ ! -z "$(pidof dunst)" ]; then if [ ! -z "$(pidof dunst)" ]; then
pkill -u "$USER" -USR1 dunst pkill -u "$USER" -USR1 dunst
fi fi
@ -96,6 +100,9 @@ lock() {
postlock() { postlock() {
if [ -n lock_timeout ]; then
xset dpms $default_timeout
fi
if [ ! -z "$(pidof dunst)" ] ; then if [ ! -z "$(pidof dunst)" ] ; then
pkill -u "$USER" -USR2 dunst pkill -u "$USER" -USR2 dunst
fi fi
@ -375,6 +382,12 @@ usage() {
echo ' to set custom lockscreen text (max 31 chars)' 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 -l dim -t \"Don't touch my machine!\""
echo ' E.g: betterlockscreen --text "Hi, user!" -s blur' echo ' E.g: betterlockscreen --text "Hi, user!" -s blur'
echo
echo
echo ' --off <timeout>'
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 shift 2
;; ;;
--off)
lock_timeout="$2"
shift 2
;;
-r | --resolution) -r | --resolution)
res="$2" res="$2"
init_filenames $res force init_filenames $res force

View file

@ -15,3 +15,4 @@ datecolor=ffffffff
loginbox=00000066 loginbox=00000066
font="sans-serif" font="sans-serif"
locktext='Type password to unlock...' locktext='Type password to unlock...'
lock_timeout=5