From 5bc81f909eb5ce5d0f456c88fea915f4d1e26774 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Madeleine=20Sydney=20=C5=9Alaga?= Date: Fri, 8 Aug 2025 20:52:23 -0600 Subject: [PATCH] feat(niri,xbacklight): Brightness control --- hosts/fruitbook/configuration.nix | 1 + hosts/fruitbook/disks.nix | 73 ------------------------ modules/home/users/crumb/niri.nix | 16 ++++-- modules/nixos/xbacklight-permissions.nix | 35 ++++++++++++ users/crumb/default.nix | 8 ++- 5 files changed, 54 insertions(+), 79 deletions(-) delete mode 100755 hosts/fruitbook/disks.nix create mode 100644 modules/nixos/xbacklight-permissions.nix diff --git a/hosts/fruitbook/configuration.nix b/hosts/fruitbook/configuration.nix index 17f6c4d..d67dd64 100644 --- a/hosts/fruitbook/configuration.nix +++ b/hosts/fruitbook/configuration.nix @@ -11,6 +11,7 @@ wifi.enable = true; stylix.enable = true; niri.enable = true; + xbacklight-permissions.enable = true; users.users = [ "crumb" ]; diff --git a/hosts/fruitbook/disks.nix b/hosts/fruitbook/disks.nix deleted file mode 100755 index 9d4f33a..0000000 --- a/hosts/fruitbook/disks.nix +++ /dev/null @@ -1,73 +0,0 @@ -# sudo nix --experimental-features "nix-command flakes" run github:nix-community/disko/latest -- --mode disko /persist/dots/hosts/nixos-testbed/disko-config.nix -# time sudo nixos-install --flake /persist/dots#nixos-testbed -{ lib, ... }: -{ - # imports = [ disko.nixosModules.disko ]; - boot.initrd.supportedFilesystems.btrfs = true; - boot.supportedFilesystems.btrfs = true; - - # From Impermanence's README: "Important note: Make sure your persistent - # volumes are marked with neededForBoot, otherwise you will run into - # problems." - fileSystems."/persist".neededForBoot = true; - - disko.devices = { - disk = { - bootroot = { - type = "disk"; - device = "/dev/disk/by-id/ata-APPLE_SSD_SM0512G_S29ANYAH526520-part4"; - content = { - type = "gpt"; - partitions = { - ESP = { - size = "512M"; - type = "EF00"; - content = { - type = "filesystem"; - format = "vfat"; - mountpoint = "/boot"; - mountOptions = [ "umask=0077" ]; - }; - }; - root = { - size = "100%"; - content = { - type = "btrfs"; - - mountpoint = "/partition-root"; - swap.swapfile.size = "4G"; - - # Override existing partitions. - extraArgs = [ "-f" ]; - - # Subvolumes must set a mountpoint in order to be mounted, - # *unless their parent is mounted*. - subvolumes = { - # Subvolume names do not necessarily correspond to - # mountpoints, despite the structural resemblance to a file - # path. - "/rootfs" = { - mountpoint = "/"; - }; - "/nix" = { - mountpoint = "/nix"; - }; - "/persist" = { - mountpoint = "/persist"; - }; - "/persist/home" = { - mountpoint = "/persist/home"; - }; - "/swap" = { - mountpoint = "/.swapvol"; - swap.swapfile.size = "4G"; - }; - }; - }; - }; - }; - }; - }; - }; - }; -} diff --git a/modules/home/users/crumb/niri.nix b/modules/home/users/crumb/niri.nix index 972042a..12806ca 100644 --- a/modules/home/users/crumb/niri.nix +++ b/modules/home/users/crumb/niri.nix @@ -73,7 +73,7 @@ in { spawn-at-startup = [{ command = [ "${pkgs.swaynotificationcenter}/bin/swaync" ]; } - { command = [ "${pkgs.gammastep}/bin/gammastep" "-o" "-O" "4000k" + { command = [ (lib.getExe pkgs.gammastep) "-o" "-O" "4000k" "-b" "0.9:0.9" "-l" "0:0"]; }] ++ lib.optional (! builtins.isNull cfg.wallpaper) @@ -175,7 +175,7 @@ in { { title = "Discord.*@"; } ]; excludes = [ - # ... except when explicitly targeting the window. + # ...except when explicitly targeting the window. { is-window-cast-target = true; } ]; block-out-from = "screen-capture"; @@ -226,8 +226,9 @@ in { binds = { "Mod+Q".action.close-window = []; "Mod+Shift+Q".action.quit = []; - "Mod+Ctrl+L".action.spawn = ["${pkgs.swaylock}/bin/swaylock"]; - "Mod+D".action.spawn = ["${pkgs.fuzzel}/bin/fuzzel"]; + "Mod+Ctrl+L".action.spawn = [ (lib.getExe pkgs.swaylock) ]; + "Mod+D".action.spawn = [ (lib.getExe pkgs.fuzzel) ]; + "XF86LaunchB".action.spawn = [ (lib.getExe pkgs.fuzzel) ]; "Mod+Shift+Slash".action.show-hotkey-overlay = []; # Powers off the monitors. They will be powered back on upon any @@ -279,7 +280,12 @@ in { "Mod+Shift+J".action.move-window-down = []; "Mod+Shift+K".action.move-window-up = []; "Mod+Shift+L".action.move-column-right = []; - + + "XF86MonBrightnessDown".action.spawn = + ["${lib.getExe pkgs.acpilight}" "-dec" "10"]; + "XF86MonBrightnessUp".action.spawn = + ["${lib.getExe pkgs.acpilight}" "-inc" "10"]; + "Mod+1".action.focus-workspace = [1]; "Mod+2".action.focus-workspace = [2]; "Mod+3".action.focus-workspace = [3]; diff --git a/modules/nixos/xbacklight-permissions.nix b/modules/nixos/xbacklight-permissions.nix new file mode 100644 index 0000000..7080816 --- /dev/null +++ b/modules/nixos/xbacklight-permissions.nix @@ -0,0 +1,35 @@ +{ config, lib, pkgs, ... }: + +let cfg = config.sydnix.xbacklight-permissions; +in { + options.sydnix.xbacklight-permissions = { + enable = + lib.mkEnableOption "the user group that is allowed to use xbacklight"; + group = lib.mkOption { + type = lib.types.str; + default = "xbacklight"; + }; + paths = lib.mkOption { + type = with lib.types; listOf str; + default = [ + "/sys/class/backlight/intel_backlight/brightness" + ]; + }; + }; + + config = lib.mkIf cfg.enable { + users.groups.${cfg.group} = {}; + + systemd.tmpfiles.settings."50-xbacklight" = + lib.mergeAttrsList + (builtins.map + (path: { + ${path}.z = { + inherit (cfg) group; + mode = "0664"; + user = "root"; + }; + }) + cfg.paths); + }; +} diff --git a/users/crumb/default.nix b/users/crumb/default.nix index 04c99ef..42f3102 100755 --- a/users/crumb/default.nix +++ b/users/crumb/default.nix @@ -3,7 +3,13 @@ isNormalUser = true; # TODO: Don't hard-code `persist`. Use # config.sydnix.impermanence.persistGroupName. - extraGroups = [ "wheel" "persist" "input" "networkmanager" ]; + extraGroups = [ + "wheel" + "persist" + "input" + "networkmanager" + "xbacklight" + ]; initialHashedPassword = "$y$j9T$aEFDDwdTZbAc6VQRXrkBJ0$K8wxTGTWDihyX1wxJ.ZMH//wmQFfrGGUkLkxIU0Lyq8";