summaryrefslogtreecommitdiffstats
path: root/local/.bin/hornet/backlight
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2023-10-08 12:09:20 -0400
committerJesse Luehrs <doy@tozt.net>2023-10-08 12:59:10 -0400
commit49570c8dd03448240897b37b68567352b790f16f (patch)
tree6c192a52046d5d0dd1b84a838befd8e777cfeafb /local/.bin/hornet/backlight
parent66939c71da756c1d9e07a88a4a8ea2a018650060 (diff)
downloadconf-49570c8dd03448240897b37b68567352b790f16f.tar.gz
conf-49570c8dd03448240897b37b68567352b790f16f.zip
convert to stow
Diffstat (limited to 'local/.bin/hornet/backlight')
-rwxr-xr-xlocal/.bin/hornet/backlight47
1 files changed, 47 insertions, 0 deletions
diff --git a/local/.bin/hornet/backlight b/local/.bin/hornet/backlight
new file mode 100755
index 0000000..314e874
--- /dev/null
+++ b/local/.bin/hornet/backlight
@@ -0,0 +1,47 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use 5.014;
+
+my @levels = (
+ 1,
+ 2,
+ 4,
+ 8,
+ 16,
+ 31,
+ 63,
+ 125,
+ 250,
+ 500,
+ 1000,
+);
+chomp(my $current = `xbacklight -getf`);
+$current = int($current * 10);
+my $idx;
+for my $i (0..$#levels) {
+ my $level = $levels[$i];
+ $idx = $i;
+ last if $level >= $current;
+}
+
+my $inc;
+if ($ARGV[0] eq 'inc') {
+ $inc = 1;
+}
+elsif ($ARGV[0] eq 'dec') {
+ $inc = -1;
+}
+elsif ($ARGV[0] eq 'get') {
+ say $idx * 10;
+ exit;
+}
+else {
+ die "unknown arg '$ARGV[0]'";
+}
+
+my $new_idx = $idx + $inc;
+if ($new_idx >= 0 && $new_idx <= $#levels) {
+ my $new_level = $levels[$new_idx] * 0.1;
+ system("xbacklight -set $new_level");
+}