diff --git a/README.md b/README.md index c30aced..9b3f720 100644 --- a/README.md +++ b/README.md @@ -30,9 +30,11 @@ Here some of the things you may be interested in: the wallpaper per screen and therefore, the script may seem a bit useless but I keep it. - - I am using `xautolock` + `i3lock` as a screensaver. Nothing fancy - but I reuse the wallpaper built above. A notification is sent 10 - seconds before starting. + - I am using `xss-lock` with `i3lock` as a screensaver. It relies on + standard X screensaver handling (and therefore is easy for + application to disable) and also supports systemd + inhibitors. Nothing fancy but I reuse the wallpaper built above. A + notification is sent 10 seconds before starting. - In `rc/apparance.lua`, you may be interested by the way I configure GTK2 and GTK3 to have an unified look. It works and it does not diff --git a/bin/locker b/bin/locker deleted file mode 100755 index 0c8fc5c..0000000 --- a/bin/locker +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -exec i3lock -e -n -i $HOME/.cache/awesome/current-wallpaper.png diff --git a/bin/notify-lock b/bin/notify-lock deleted file mode 100755 index 68f0309..0000000 --- a/bin/notify-lock +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -icon="$1" - -exec notify-send "Lock screen" \ - ${icon:+-i $icon} \ - -t 10000 \ - "Lock screen will be started in 10 seconds..." diff --git a/bin/xautolock b/bin/xautolock deleted file mode 100755 index 21e4f1d..0000000 --- a/bin/xautolock +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -icon="$1" -notify=$(dirname $(readlink -f "$0"))/notify-lock -locker=$(dirname $(readlink -f "$0"))/locker - -exec xautolock \ - -time 4 \ - -locker "$locker" \ - -notify 10 \ - -notifier "$notify $icon" diff --git a/bin/xss-lock b/bin/xss-lock new file mode 100755 index 0000000..e39af78 --- /dev/null +++ b/bin/xss-lock @@ -0,0 +1,37 @@ +#!/bin/bash + +me="$(readlink -f "$0")" +timeout=240 +notify=5 + +case "$1" in + start) + xset s $timeout $notify + xset dpms $(($timeout * 2 + $notify)) $(($timeout * 3 + $notify)) $(($timeout * 4 + $notify)) + exec xss-lock -n "$me dim" -l $me lock + ;; + dim) + trap 'exit 0' TERM INT + trap "xbacklight -steps 1 -set $(xbacklight -get); kill %%" EXIT + min_brightness=0 + fade_time=$(($notify * 1000)) + fade_steps=20 + fade_step_time=0.05 + xbacklight -time $fade_time -steps $fade_steps -set $min_brightness + sleep 2147483647 & + wait + ;; + lock) + i3lock_options="-e -i $HOME/.cache/awesome/current-wallpaper.png" + if [ -e /proc/self/fd/${XSS_SLEEP_LOCK_FD:--1} ]; then + trap 'kill %%' TERM INT + i3lock -n $i3lock_options {XSS_SLEEP_LOCK_FD}<&- & + exec {XSS_SLEEP_LOCK_FD}<&- + wait + else + trap 'kill %%' TERM INT + i3lock -n $i3lock_options & + wait + fi + ;; +esac diff --git a/rc/xlock.lua b/rc/xlock.lua index 48b6271..5fecdfb 100644 --- a/rc/xlock.lua +++ b/rc/xlock.lua @@ -1,15 +1,7 @@ -- Lockscreen -local icons = loadrc("icons", "vbe/icons") - -xrun("xautolock", - awful.util.getdir("config") .. - "/bin/xautolock " .. - icons.lookup({name = "system-lock-screen", type = "actions" })) - local lock = function() - awful.util.spawn(awful.util.getdir("config") .. - "/bin/locker", false) + os.execute("xset s activate") end config.keys.global = awful.util.table.join( @@ -17,5 +9,6 @@ config.keys.global = awful.util.table.join( awful.key({}, "XF86ScreenSaver", lock), awful.key({ modkey, }, "Delete", lock)) --- Configure DPMS -os.execute("xset dpms 360 720 1200") +-- Configure xss-lock +os.execute(awful.util.spawn(awful.util.getdir("config") .. + "/bin/xss-lock start")) diff --git a/requirements.txt b/requirements.txt index d43ba20..e29ee6d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,8 @@ awesome awesome-extra i3lock -xautolock +xss-lock +xbacklight libnotify-bin xfonts-terminus ttf-dejavu