From 982308caed9d96176726b6d3df0e8790e87aa5b0 Mon Sep 17 00:00:00 2001 From: Markus Katharina Brechtel Date: Thu, 2 Jul 2020 19:05:54 +0200 Subject: [PATCH] new screensaver config --- tasks/main.yaml | 14 ++++++++++++++ tasks/packages.yaml | 1 + templates/screensaver-disable.sh.j2 | 20 ++++++++++++++++++++ templates/screensaver-enable.sh.j2 | 20 ++++++++++++++++++++ templates/screensaver-lock/i3lock.sh.j2 | 5 +++-- templates/screensaver-settings.sh.j2 | 2 +- 6 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 templates/screensaver-disable.sh.j2 create mode 100644 templates/screensaver-enable.sh.j2 diff --git a/tasks/main.yaml b/tasks/main.yaml index 1ff56e0..6e98f72 100644 --- a/tasks/main.yaml +++ b/tasks/main.yaml @@ -28,3 +28,17 @@ dest: /usr/local/bin/screensaver-lock mode: 0755 when: screensaver != 'none' + +- name: screensaver enable script + template: + src: screensaver-enable.sh.j2 + dest: /usr/local/bin/screensaver-enable + mode: 0755 + when: screensaver != 'none' + +- name: screensaver disable script + template: + src: screensaver-disable.sh.j2 + dest: /usr/local/bin/screensaver-disable + mode: 0755 + when: screensaver != 'none' diff --git a/tasks/packages.yaml b/tasks/packages.yaml index fcc2534..3670c0b 100644 --- a/tasks/packages.yaml +++ b/tasks/packages.yaml @@ -3,4 +3,5 @@ - name: debian packages apt: pkg: + - xss-lock - xssproxy diff --git a/templates/screensaver-disable.sh.j2 b/templates/screensaver-disable.sh.j2 new file mode 100644 index 0000000..cd256bd --- /dev/null +++ b/templates/screensaver-disable.sh.j2 @@ -0,0 +1,20 @@ +#!/bin/sh + +# https://www.reddit.com/r/i3wm/comments/6gznzp/lock_screensaver_and_power_saving_how_to_trigger/ + +xset s on +xset +dpms + +# xset s +# n1: is the time it takes to launch the first signal that the screen will be +# shutdown. Here we generally dim the screen a bit. +# n2: is the time after n1 that we launch the second signal. +# Here we lock the screen. +# With n1 = 60 and n2 = 30 the screen will be dimmed 60 seconds after the last +# time pc was not idle and 30 seconds later (90 seconds from last non-idle +# state) the screen will be locked. +xset s 0 0 + +# xset dpms +# n: is the time from last non-idle state after which the screen will be shutdown. +xset dpms 0 0 0 diff --git a/templates/screensaver-enable.sh.j2 b/templates/screensaver-enable.sh.j2 new file mode 100644 index 0000000..ee0d175 --- /dev/null +++ b/templates/screensaver-enable.sh.j2 @@ -0,0 +1,20 @@ +#!/bin/sh + +# https://www.reddit.com/r/i3wm/comments/6gznzp/lock_screensaver_and_power_saving_how_to_trigger/ + +xset s on +xset +dpms + +# xset s +# n1: is the time it takes to launch the first signal that the screen will be +# shutdown. Here we generally dim the screen a bit. +# n2: is the time after n1 that we launch the second signal. +# Here we lock the screen. +# With n1 = 60 and n2 = 30 the screen will be dimmed 60 seconds after the last +# time pc was not idle and 30 seconds later (90 seconds from last non-idle +# state) the screen will be locked. +xset s {{ screensaver_sleeptime | int * 60 }} {{ screensaver_locktime | int * 60 }} + +# xset dpms +# n: is the time from last non-idle state after which the screen will be shutdown. +xset dpms {{ screensaver_sleeptime | int * 60 }} {{ screensaver_sleeptime | int * 60 }} {{ screensaver_sleeptime | int * 60 }} diff --git a/templates/screensaver-lock/i3lock.sh.j2 b/templates/screensaver-lock/i3lock.sh.j2 index d9042e0..9c8db36 100644 --- a/templates/screensaver-lock/i3lock.sh.j2 +++ b/templates/screensaver-lock/i3lock.sh.j2 @@ -6,16 +6,17 @@ ## CONFIGURATION ############################################################## # Options to pass to i3lock -i3lock_options="-d -c 000000" +i3lock_options="-c 330033 -f" # Run before starting the locker pre_lock() { - #mpc pause + xset dpms force off return } # Run after the locker exits post_lock() { + /usr/local/bin/screensaver-enable return } diff --git a/templates/screensaver-settings.sh.j2 b/templates/screensaver-settings.sh.j2 index ea1eab6..ee0d175 100644 --- a/templates/screensaver-settings.sh.j2 +++ b/templates/screensaver-settings.sh.j2 @@ -17,4 +17,4 @@ xset s {{ screensaver_sleeptime | int * 60 }} {{ screensaver_locktime | int * 60 # xset dpms # n: is the time from last non-idle state after which the screen will be shutdown. -xset dpms {{ screensaver_sleeptime | int * 60 }} +xset dpms {{ screensaver_sleeptime | int * 60 }} {{ screensaver_sleeptime | int * 60 }} {{ screensaver_sleeptime | int * 60 }}