A variety of simple automation scripts and enhancements to Sway and i3.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
843B

  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. my $maxfile = "/sys/class/leds/tpacpi\:\:kbd_backlight/max_brightness";
  5. my $current = "/sys/class/leds/tpacpi\:\:kbd_backlight/brightness";
  6. my ($max, $now, $new);
  7. if (open(my $m, '<', $maxfile)) {
  8. $max = readline($m);
  9. chomp $max;
  10. close($m);
  11. } else {
  12. print "Failed to read $maxfile\n";
  13. exit;
  14. }
  15. print STDERR "max = $max\n";
  16. if (open(my $c, '<', $current)) {
  17. $now = readline($c);
  18. chomp $now;
  19. close($c);
  20. } else {
  21. print "Failed to read $current\n";
  22. exit;
  23. }
  24. print STDERR "now = $now\n";
  25. if (open(my $fh, '>', $current)) {
  26. $new = (($now+1) % ($max+1));
  27. chomp $new;
  28. print $fh $new;
  29. close($fh);
  30. } else {
  31. print "Failed to write $current\n";
  32. exit;
  33. }
  34. print STDERR "new = $new\n";