diff options
| author | Marc Vertes <mvertes@free.fr> | 2025-08-25 15:39:16 +0200 |
|---|---|---|
| committer | Marc Vertes <mvertes@free.fr> | 2025-08-25 15:39:16 +0200 |
| commit | 5bb833eeea685a660cc9b664420f764ae20a6587 (patch) | |
| tree | 5105a444eedc50ddf658624cc9929c030e47db68 /bin | |
| parent | 0a84f830c6d3cc3a93197902c32f6dfc7a3b8d9b (diff) | |
improve bin/isdarktty
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/isdarktty | 4 |
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) }' |
