about summary refs log tree commit diff
path: root/users/wpcarro
diff options
context:
space:
mode:
authorWilliam Carroll <wpcarro@gmail.com>2021-12-16T15·27-0500
committerwpcarro <wpcarro@gmail.com>2021-12-16T22·07+0000
commit47830f9d63593cd52f97ebfaf86c630cc0793ad5 (patch)
tree8ac779dbfb07cd060552076e60ed1bee19593106 /users/wpcarro
parent9c9a88de874506383829b4ed4fb0fafc4238da9a (diff)
feat(wpcarro/marcus): Prefer light to xbacklight r/3283
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>
Diffstat (limited to 'users/wpcarro')
-rw-r--r--users/wpcarro/emacs/.emacs.d/wpc/screen-brightness.el23
-rw-r--r--users/wpcarro/nixos/marcus/default.nix10
2 files changed, 24 insertions, 9 deletions
diff --git a/users/wpcarro/emacs/.emacs.d/wpc/screen-brightness.el b/users/wpcarro/emacs/.emacs.d/wpc/screen-brightness.el
index 30973607bb03..48aa5d637fb6 100644
--- a/users/wpcarro/emacs/.emacs.d/wpc/screen-brightness.el
+++ b/users/wpcarro/emacs/.emacs.d/wpc/screen-brightness.el
@@ -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)
diff --git a/users/wpcarro/nixos/marcus/default.nix b/users/wpcarro/nixos/marcus/default.nix
index bfbc392c21e8..f3c76f16c547 100644
--- a/users/wpcarro/nixos/marcus/default.nix
+++ b/users/wpcarro/nixos/marcus/default.nix
@@ -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