This article is about how I tried to notify I was
Please read the article about xautolock
corners from the i3-screensaver-tips series
So here is my xautolock configuration
xautolock -time 5 -locker "~/bin/lockscreen.sh" -detectsleep -corners '++--' -cornerdelay 5 -notify 5 -notifier ~/bin/lockscreen-notify.sh
Here is the content of my ~/bin/lockscreen-notify.sh
#!/bin/sh
set -e
notify-send --urgency=critical --icon preferences-desktop-screensaver --expire-time=5000 "about to lock screen ..." "move or use corners"
I'm using dunst, but this is syntax is compatible with all notifiers.
Alternative #1: progress bar
Please note, you will need dunst
1.7.0
dunst --version
Dunst - A customizable and lightweight notification-daemon 1.8.1 (2022-03-02)
highlight aka progress bar is only available with 1.7.0 , it's the int:value:10
hint in the next command
To test if your dunst or notifier is able to support it, just try this
dunstify -h int:value:42 "Working ..."
if you see a progress bar, you can use this technique.
The following script uses the x-dunst-stack-tag
hint that allows me to reuse an existing message.
To test it, you can try this
notify-send $(date) -h 'string:x-dunst-stack-tag:whatever'
notify-send $(date) -h 'string:x-dunst-stack-tag:whatever'
If you see 2 messages, then it doesn't work.
I'm not sure if other notifier supports such kind tag, but dunst
does.
So here is the script I made, and I'm using right now as a notifier.
#!/bin/bash
set -e
for p in $(seq 0 2 100); do
dunstify --icon preferences-desktop-screensaver \
-h int:value:$p \
-h 'string:hlcolor:#ff4444' \
-h string:x-dunst-stack-tag:progress-lock \
--timeout=500 "about to lock screen ..." "move or use corners"
sleep 0.05
done
The step in seq
and sleep
setting were adapted to render completely in a 5s loop.
Here is the result
Alternative #2: brightness
I initially tried to play with brightness and so my lockscreen-notify.sh
script was like this, creating a wave of brightness to force me to react.
#!/bin/sh
set -e
primary=$(xrandr | grep " primary" | cut -f1 -d " " | head -n 1)
# decreasing brightness
trap "xrandr --output $primary --gamma 1" EXIT
for g in $(LANG=C seq 1 -0.02 0.4) ; do
xrandr --output $primary --brightness $g
sleep 0.01
done
# increasing brightness
for g in $(LANG=C seq 0.4 +0.02 1) ; do
xrandr --output $primary --brightness $g
sleep 0.01
done
Please note the trap
here to reset the brightness even if you CTRL+C the script.
Top comments (3)
Using the xdotool we can detect if our mouse is in one of minus corners and say something "We are not locking your screen for a while" :)
What about adding a mouse move detection to kill the notification?
I am going to try that right now!
Here:
transfer.sh/dlQTnU/lockscreen-noti...
I think we can do the same with keyboard