summaryrefslogtreecommitdiff
path: root/bin/isdarktty
diff options
context:
space:
mode:
Diffstat (limited to 'bin/isdarktty')
-rwxr-xr-xbin/isdarktty4
1 files changed, 2 insertions, 2 deletions
diff --git a/bin/isdarktty b/bin/isdarktty
index 334d8a0..779f6c8 100755
--- a/bin/isdarktty
+++ b/bin/isdarktty
@@ -1,6 +1,7 @@
#!/bin/sh
# Check darkness by computing luminance of the current terminal.
+# see https://en.wikipedia.org/wiki/Luma_(video)
trap "stty $(stty -g)" EXIT
stty raw -echo min 0 time 0
@@ -11,6 +12,5 @@ awk -v FS='' -v hex=123456789abcdef '{
r = (16 * index(hex, $10) + index(hex, $11)) / 255
g = (16 * index(hex, $15) + index(hex, $16)) / 255
b = (16 * index(hex, $20) + index(hex, $21)) / 255
- # print 0.33 * r + 0.5 * g + 0.16 * b
- exit (0.33 * r + 0.5 * g + 0.16 * b > 0.5)
+ exit (0.3 * r + 0.6 * g + 0.1 * b > 0.5)
}'