feat(wpcarro/marcus): Prefer light to xbacklight

TL;DR:
- Enable light (let there be light!)
- Refactor screen-brightness.el

TIL: `nixos-options programs.enable.light` outputs docs from the command-line
Change-Id: Ib60a9b3c9b7f6f96fda29fce1a97ca9995822048
Reviewed-on: https://cl.tvl.fyi/c/depot/+/4385
Tested-by: BuildkiteCI
Reviewed-by: wpcarro <wpcarro@gmail.com>
This commit is contained in:
William Carroll 2021-12-16 10:27:00 -05:00 committed by wpcarro
parent 9c9a88de87
commit 47830f9d63
2 changed files with 24 additions and 9 deletions

View file

@ -6,12 +6,10 @@
;; Package-Requires: ((emacs "24"))
;;; Commentary:
;; Mainly just Elisp wrappers around `xbacklight`.
;; Control your laptop's screen brightness.
;;; Code:
;; TODO: Define some isomorphisms. E.g. int->string, string->int.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Dependencies
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -22,8 +20,19 @@
;; Constants
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defconst screen-brightness-step-size 15
"The size of the increment or decrement step for the screen's brightness.")
(defgroup screen-brightness nil "Configuration for screen-brightness.")
(defcustom screen-brightness-increase-cmd
"light -A 3"
"The shell command to run to increase screen brightness."
:group 'screen-brightness
:type 'string)
(defcustom screen-brightness-decrease-cmd
"light -U 3"
"The shell command to run to decrease screen brightness."
:group 'screen-brightness
:type 'string)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Library
@ -34,7 +43,7 @@
(interactive)
(prelude-start-process
:name "screen-brightness-increase"
:command (string-format "xbacklight -inc %s" screen-brightness-step-size))
:command screen-brightness-increase-cmd)
(message "[screen-brightness.el] Increased screen brightness."))
(defun screen-brightness-decrease ()
@ -42,7 +51,7 @@
(interactive)
(prelude-start-process
:name "screen-brightness-decrease"
:command (string-format "xbacklight -dec %s" screen-brightness-step-size))
:command screen-brightness-decrease-cmd)
(message "[screen-brightness.el] Decreased screen brightness."))
(provide 'screen-brightness)

View file

@ -67,7 +67,10 @@ in {
users.mutableUsers = true;
users.users.wpcarro = {
isNormalUser = true;
extraGroups = [ "wheel" ];
extraGroups = [
"wheel"
"video" # needed to control the screen brightness
];
shell = pkgs.fish;
};
@ -83,7 +86,10 @@ in {
};
};
programs.fish.enable = true;
programs = {
fish.enable = true;
light.enable = true;
};
environment.systemPackages = with pkgs; [
alacritty