From a46e7d7bca5d1fd3830997a715f650be03693520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Sat, 16 Dec 2023 22:39:11 +0100 Subject: [PATCH] Fix backlight --- curacao/options.nix | 7 ++- hm/desktop.nix | 6 ++- hm/style.nix | 4 +- options.nix | 9 ++-- pindakaas/options.nix | 7 ++- .../roles/system/files/getty.service | 2 - .../system/files/xorg/intel_backlight.conf | 5 --- .../automatrop/roles/system/tasks/main.yml | 43 ------------------- 8 files changed, 17 insertions(+), 66 deletions(-) delete mode 100644 unprocessed/config/automatrop/roles/system/files/getty.service delete mode 100644 unprocessed/config/automatrop/roles/system/files/xorg/intel_backlight.conf diff --git a/curacao/options.nix b/curacao/options.nix index f07bbbd..45ab31a 100644 --- a/curacao/options.nix +++ b/curacao/options.nix @@ -8,10 +8,9 @@ numlock = true; phasesBrightness = { enable = true; - backlight = "intel_backlight"; - jour = 40000; - crepuscule = 10000; - nuit = 1; + jour = "40000"; + crepuscule = "10000"; + nuit = "1"; }; }; dev = { diff --git a/hm/desktop.nix b/hm/desktop.nix index 82250f0..4a3eb3c 100644 --- a/hm/desktop.nix +++ b/hm/desktop.nix @@ -148,6 +148,9 @@ in "XF86AudioPrev" = "exec ${pkgs.mpc-cli}/bin/mpc prev"; "XF86AudioPlay" = "exec ${pkgs.mpc-cli}/bin/mpc toggle"; "XF86AudioNext" = "exec ${pkgs.mpc-cli}/bin/mpc next"; + # Backlight + "XF86MonBrightnessUp" = "exec ${pkgs.brightnessctl}/bin/brightnessctl set +5%"; + "XF86MonBrightnessDown" = "exec ${pkgs.brightnessctl}/bin/brightnessctl set 5%-"; # Misc "${mod}+F10" = "exec ${ pkgs.writeShellScript "show-keyboard-layout" '' @@ -641,6 +644,8 @@ in home = { packages = with pkgs; [ + pavucontrol # Because can't use Win+F1X on Pinebook 🙃 + # remote tigervnc @@ -677,7 +682,6 @@ in xclip keynav xorg.xinit - xorg.xbacklight # TODO Make this clean. Service? diff --git a/hm/style.nix b/hm/style.nix index a98707b..29a212d 100644 --- a/hm/style.nix +++ b/hm/style.nix @@ -47,12 +47,12 @@ in dconf.enable = false; # Otherwise standalone home-manager complains it can't find /etc/dbus-1/session.conf on Arch. # Symlinking it to /usr/share/dbus-1/session.conf goes further but not much. - # TODO Use xbacklight instead (pindakaas doesn't seem to support it OOTB) home.packages = map (phase: (pkgs.writeShellApplication { name = "${phase.command}"; + runtimeInputs = [ pkgs.brightnessctl ]; text = (lib.optionalString cfg.enable '' - echo ${builtins.toString (builtins.getAttr phase.command cfg)} | sudo tee /sys/class/backlight/${cfg.backlight}/brightness + brightnessctl set ${builtins.getAttr phase.command cfg} '') + '' echo ${phase.polarity} > ${polarityFile} if command -v home-manager diff --git a/options.nix b/options.nix index 4b2a554..11a0552 100644 --- a/options.nix +++ b/options.nix @@ -7,7 +7,7 @@ xorg = lib.mkEnableOption "Enable X11 support"; numlock = lib.mkEnableOption "Auto-enable numlock"; x11_screens = lib.mkOption { - default = ["UNSET1"]; + default = [ "UNSET1" ]; description = "A list of xrandr screen names from left to right."; type = lib.types.listOf lib.types.str; }; @@ -19,10 +19,9 @@ }; phasesBrightness = { enable = lib.mkEnableOption "Set a specific brightness for the screen when running phases commands"; - backlight = lib.mkOption { type = lib.types.str; description = "Name of the backlight device"; }; - jour = lib.mkOption { type = lib.types.int; description = "brightness value for phase: jour"; }; - crepuscule = lib.mkOption { type = lib.types.int; description = "brightness value for phase: crepuscule"; }; - nuit = lib.mkOption { type = lib.types.int; description = "brightness value for phase: nuit"; }; + jour = lib.mkOption { type = lib.types.str; default = "100%"; description = "brightnessctl value for phase: jour"; }; + crepuscule = lib.mkOption { type = lib.types.str; default = "50%"; description = "brightnessctl value for phase: crepuscule"; }; + nuit = lib.mkOption { type = lib.types.str; default = "1%"; description = "brightnessctl value for phase: nuit"; }; }; }; dev = { diff --git a/pindakaas/options.nix b/pindakaas/options.nix index 2f7df32..56b5eba 100644 --- a/pindakaas/options.nix +++ b/pindakaas/options.nix @@ -7,10 +7,9 @@ maxVideoHeight = 720; phasesBrightness = { enable = true; - backlight = "edp-backlight"; - jour = 3500; - crepuscule = 3000; - nuit = 700; + jour = "3500"; + crepuscule = "3000"; + nuit = "700"; }; }; } diff --git a/unprocessed/config/automatrop/roles/system/files/getty.service b/unprocessed/config/automatrop/roles/system/files/getty.service deleted file mode 100644 index 1d6b77a..0000000 --- a/unprocessed/config/automatrop/roles/system/files/getty.service +++ /dev/null @@ -1,2 +0,0 @@ -[Service] -ExecStartPre=/bin/sh -c 'setleds +num < /dev/%I' diff --git a/unprocessed/config/automatrop/roles/system/files/xorg/intel_backlight.conf b/unprocessed/config/automatrop/roles/system/files/xorg/intel_backlight.conf deleted file mode 100644 index 36f6eb5..0000000 --- a/unprocessed/config/automatrop/roles/system/files/xorg/intel_backlight.conf +++ /dev/null @@ -1,5 +0,0 @@ -Section "Device" - Identifier "Intel Graphics" - Driver "intel" - Option "Backlight" "intel_backlight" -EndSection diff --git a/unprocessed/config/automatrop/roles/system/tasks/main.yml b/unprocessed/config/automatrop/roles/system/tasks/main.yml index 002d579..4a012d1 100644 --- a/unprocessed/config/automatrop/roles/system/tasks/main.yml +++ b/unprocessed/config/automatrop/roles/system/tasks/main.yml @@ -1,28 +1,5 @@ # Xorg configuration -- name: Check if there is Intel backlight - ansible.builtin.stat: - path: /sys/class/backlight/intel_backlight - register: intel_backlight - when: display_server == 'x11' - -- name: Install Intel video drivers (Arch based) - community.general.pacman: - name: xf86-video-intel - # state: "{{ intel_backlight.stat.exists }}" - state: present - become: true - when: display_server == 'x11' and intel_backlight.stat.exists and arch_based - # TODO With software role? Would permit other distributions - -- name: Configure Xorg Intel backlight - ansible.builtin.copy: - src: xorg/intel_backlight.conf - dest: "{{ item }}/20-intel_backlight.conf" - become: true - when: display_server == 'x11' and intel_backlight.stat.exists - loop: "{{ xorg_common_config_dirs }}" - - name: Configure Xorg joystick behaviour ansible.builtin.copy: src: xorg/joystick.conf @@ -48,23 +25,3 @@ vars: using_panfrost: "{{ 'panfrost' in (modules.content | b64decode) }}" notify: panfrost config changed - -# Numlock on boot - -- name: Set numlock on boot - ansible.builtin.copy: - src: getty.service - dest: /etc/systemd/system/getty@.service.d/override.conf - become: true - notify: - - systemd changed - when: auto_numlock - -- name: Unset numlock on boot - ansible.builtin.file: - path: /etc/systemd/system/getty@.service.d/override.conf - state: absent - become: true - notify: - - systemd changed - when: not auto_numlock