-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathezz
More file actions
executable file
·44 lines (38 loc) · 1.01 KB
/
ezz
File metadata and controls
executable file
·44 lines (38 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env bash
# ezz - resteazy darker
# Put the pixel brightness to dark after the keyboard & mouse input idled for a given amount of time.
# Helpful if you want to disable the pixels but want to keep the monitor on.
#
# Usage:
#
# ezz [<IDLE-SECONDS>]
#
# Examples:
#
# ezz # Default to 5 seconds idle time
# ezz 90 # Allow 90 seconds idle time
#
# author: andreasl
max_idle_time=${1:-5}
is_dark=false
screen='DisplayPort-0'
xrandr --listactivemonitors | grep --silent --no-messages 'DisplayPort-0' || screen='eDP' # internal screen
# Command to execute affter the idle timeout.
darker() {
is_dark=true
xrandr --output "$screen" --brightness 0.0
}
brighter() {
is_dark=false
xrandr --output "$screen" --brightness 1
}
while true; do
idle_time=$(($(xprintidle) / 1000))
if [ "$idle_time" -ge "$max_idle_time" ]; then
[ "$is_dark" == 'false' ] && darker
else
[ "$is_dark" == 'true' ] && brighter
sleep $((max_idle_time - idle_time))
fi
sleep 0.3
done