Fix backlight

This commit is contained in:
Geoffrey Frogeye 2023-12-16 22:39:11 +01:00
parent a3552634b6
commit a46e7d7bca
Signed by: geoffrey
GPG key ID: C72403E7F82E6AD8
8 changed files with 17 additions and 66 deletions

View file

@ -8,10 +8,9 @@
numlock = true; numlock = true;
phasesBrightness = { phasesBrightness = {
enable = true; enable = true;
backlight = "intel_backlight"; jour = "40000";
jour = 40000; crepuscule = "10000";
crepuscule = 10000; nuit = "1";
nuit = 1;
}; };
}; };
dev = { dev = {

View file

@ -148,6 +148,9 @@ in
"XF86AudioPrev" = "exec ${pkgs.mpc-cli}/bin/mpc prev"; "XF86AudioPrev" = "exec ${pkgs.mpc-cli}/bin/mpc prev";
"XF86AudioPlay" = "exec ${pkgs.mpc-cli}/bin/mpc toggle"; "XF86AudioPlay" = "exec ${pkgs.mpc-cli}/bin/mpc toggle";
"XF86AudioNext" = "exec ${pkgs.mpc-cli}/bin/mpc next"; "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 # Misc
"${mod}+F10" = "exec ${ pkgs.writeShellScript "show-keyboard-layout" "${mod}+F10" = "exec ${ pkgs.writeShellScript "show-keyboard-layout"
'' ''
@ -641,6 +644,8 @@ in
home = { home = {
packages = with pkgs; [ packages = with pkgs; [
pavucontrol # Because can't use Win+F1X on Pinebook 🙃
# remote # remote
tigervnc tigervnc
@ -677,7 +682,6 @@ in
xclip xclip
keynav keynav
xorg.xinit xorg.xinit
xorg.xbacklight
# TODO Make this clean. Service? # TODO Make this clean. Service?

View file

@ -47,12 +47,12 @@ in
dconf.enable = false; # Otherwise standalone home-manager complains it can't find /etc/dbus-1/session.conf on Arch. 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. # 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 home.packages = map
(phase: (pkgs.writeShellApplication { (phase: (pkgs.writeShellApplication {
name = "${phase.command}"; name = "${phase.command}";
runtimeInputs = [ pkgs.brightnessctl ];
text = (lib.optionalString cfg.enable '' 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} echo ${phase.polarity} > ${polarityFile}
if command -v home-manager if command -v home-manager

View file

@ -7,7 +7,7 @@
xorg = lib.mkEnableOption "Enable X11 support"; xorg = lib.mkEnableOption "Enable X11 support";
numlock = lib.mkEnableOption "Auto-enable numlock"; numlock = lib.mkEnableOption "Auto-enable numlock";
x11_screens = lib.mkOption { x11_screens = lib.mkOption {
default = ["UNSET1"]; default = [ "UNSET1" ];
description = "A list of xrandr screen names from left to right."; description = "A list of xrandr screen names from left to right.";
type = lib.types.listOf lib.types.str; type = lib.types.listOf lib.types.str;
}; };
@ -19,10 +19,9 @@
}; };
phasesBrightness = { phasesBrightness = {
enable = lib.mkEnableOption "Set a specific brightness for the screen when running phases commands"; 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.str; default = "100%"; description = "brightnessctl value for phase: jour"; };
jour = lib.mkOption { type = lib.types.int; description = "brightness value for phase: jour"; }; crepuscule = lib.mkOption { type = lib.types.str; default = "50%"; description = "brightnessctl value for phase: crepuscule"; };
crepuscule = lib.mkOption { type = lib.types.int; description = "brightness value for phase: crepuscule"; }; nuit = lib.mkOption { type = lib.types.str; default = "1%"; description = "brightnessctl value for phase: nuit"; };
nuit = lib.mkOption { type = lib.types.int; description = "brightness value for phase: nuit"; };
}; };
}; };
dev = { dev = {

View file

@ -7,10 +7,9 @@
maxVideoHeight = 720; maxVideoHeight = 720;
phasesBrightness = { phasesBrightness = {
enable = true; enable = true;
backlight = "edp-backlight"; jour = "3500";
jour = 3500; crepuscule = "3000";
crepuscule = 3000; nuit = "700";
nuit = 700;
}; };
}; };
} }

View file

@ -1,2 +0,0 @@
[Service]
ExecStartPre=/bin/sh -c 'setleds +num < /dev/%I'

View file

@ -1,5 +0,0 @@
Section "Device"
Identifier "Intel Graphics"
Driver "intel"
Option "Backlight" "intel_backlight"
EndSection

View file

@ -1,28 +1,5 @@
# Xorg configuration # 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 - name: Configure Xorg joystick behaviour
ansible.builtin.copy: ansible.builtin.copy:
src: xorg/joystick.conf src: xorg/joystick.conf
@ -48,23 +25,3 @@
vars: vars:
using_panfrost: "{{ 'panfrost' in (modules.content | b64decode) }}" using_panfrost: "{{ 'panfrost' in (modules.content | b64decode) }}"
notify: panfrost config changed 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