summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-03-02 18:21:31 -0500
committerJesse Luehrs <doy@tozt.net>2021-03-02 18:21:31 -0500
commit0411b4b9948aaae795d732ba56698e0e399c6560 (patch)
tree4f0cc22a2ba21cb5f7eefce4ae108be2dec277e1
parent214733346f2c585fdc266a3a2acfe13d434f833b (diff)
downloadconf-0411b4b9948aaae795d732ba56698e0e399c6560.tar.gz
conf-0411b4b9948aaae795d732ba56698e0e399c6560.zip
use log scale for brightness controls
-rwxr-xr-xbin/hornet/backlight42
-rw-r--r--xbindkeysrc4
2 files changed, 44 insertions, 2 deletions
diff --git a/bin/hornet/backlight b/bin/hornet/backlight
new file mode 100755
index 0000000..b98d1bd
--- /dev/null
+++ b/bin/hornet/backlight
@@ -0,0 +1,42 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use 5.014;
+
+my $inc;
+if ($ARGV[0] eq 'inc') {
+ $inc = 1;
+}
+elsif ($ARGV[0] eq 'dec') {
+ $inc = -1;
+}
+else {
+ die "unknown arg '$ARGV[0]'";
+}
+
+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 $new_idx = $idx + $inc;
+if ($new_idx >= 0 && $new_idx <= $#levels) {
+ my $new_level = $levels[$new_idx] * 0.1;
+ system("xbacklight -set $new_level");
+}
diff --git a/xbindkeysrc b/xbindkeysrc
index 5aeba86..1ed4496 100644
--- a/xbindkeysrc
+++ b/xbindkeysrc
@@ -31,10 +31,10 @@
"pactl set-source-mute 5 toggle"
XF86AudioMicMute
-"xbacklight -dec 10"
+"backlight dec"
XF86MonBrightnessDown
-"xbacklight -inc 10"
+"backlight inc"
XF86MonBrightnessUp
"tv"