summaryrefslogtreecommitdiff
path: root/x11-misc/myi3lock/files/mylock-notifier-fade.sh
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2020-10-14 10:33:55 +0200
committerKarel Kočí <cynerd@email.cz>2020-10-14 10:33:55 +0200
commitbf020acd0fd4ca511ac479f537d41661a2ae708f (patch)
tree19641e5d355bd0d1b4e0a3c88469f93381c635fe /x11-misc/myi3lock/files/mylock-notifier-fade.sh
parentade8d22e3957bef209997b71fd95bfcacab68f9e (diff)
downloadgentoo-personal-overlay-bf020acd0fd4ca511ac479f537d41661a2ae708f.tar.gz
gentoo-personal-overlay-bf020acd0fd4ca511ac479f537d41661a2ae708f.tar.bz2
gentoo-personal-overlay-bf020acd0fd4ca511ac479f537d41661a2ae708f.zip
x11-misc/myi3lock: fixed keyboard layout and screen fade on inactivity
Diffstat (limited to 'x11-misc/myi3lock/files/mylock-notifier-fade.sh')
-rwxr-xr-xx11-misc/myi3lock/files/mylock-notifier-fade.sh65
1 files changed, 65 insertions, 0 deletions
diff --git a/x11-misc/myi3lock/files/mylock-notifier-fade.sh b/x11-misc/myi3lock/files/mylock-notifier-fade.sh
new file mode 100755
index 0000000..d983aee
--- /dev/null
+++ b/x11-misc/myi3lock/files/mylock-notifier-fade.sh
@@ -0,0 +1,65 @@
+#!/bin/bash
+
+# Example notifier script -- lowers screen brightness, then waits to be killed
+# and restores previous brightness on exit.
+
+## CONFIGURATION ##############################################################
+
+# Brightness will be lowered to this value.
+min_brightness=0
+
+# If your video driver works with xbacklight, set -time and -steps for fading
+# to $min_brightness here. Setting steps to 1 disables fading.
+fade_time=200
+fade_steps=20
+
+# If you have a driver without RandR backlight property (e.g. radeon), set this
+# to use the sysfs interface and create a .conf file in /etc/tmpfiles.d/
+# containing the following line to make the sysfs file writable for group
+# "users":
+#
+# m /sys/class/backlight/acpi_video0/brightness 0664 root users - -
+#
+#sysfs_path=/sys/class/backlight/acpi_video0/brightness
+
+# Time to sleep (in seconds) between increments when using sysfs. If unset or
+# empty, fading is disabled.
+fade_step_time=0.05
+
+###############################################################################
+
+get_brightness() {
+ if [[ -z $sysfs_path ]]; then
+ xbacklight -get
+ else
+ cat $sysfs_path
+ fi
+}
+
+set_brightness() {
+ if [[ -z $sysfs_path ]]; then
+ xbacklight -steps 1 -set $1
+ else
+ echo $1 > $sysfs_path
+ fi
+}
+
+fade_brightness() {
+ if [[ -z $sysfs_path ]]; then
+ xbacklight -time $fade_time -steps $fade_steps -set $1
+ elif [[ -z $fade_step_time ]]; then
+ set_brightness $1
+ else
+ local level
+ for level in $(eval echo {$(get_brightness)..$1}); do
+ set_brightness $level
+ sleep $fade_step_time
+ done
+ fi
+}
+
+trap 'exit 0' TERM INT
+trap "set_brightness $(get_brightness); kill %%" EXIT
+fade_brightness $min_brightness
+sleep 2147483647 &
+wait