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;
phasesBrightness = {
enable = true;
backlight = "intel_backlight";
jour = 40000;
crepuscule = 10000;
nuit = 1;
jour = "40000";
crepuscule = "10000";
nuit = "1";
};
};
dev = {

View file

@ -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?

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.
# 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

View file

@ -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 = {

View file

@ -7,10 +7,9 @@
maxVideoHeight = 720;
phasesBrightness = {
enable = true;
backlight = "edp-backlight";
jour = 3500;
crepuscule = 3000;
nuit = 700;
jour = "3500";
crepuscule = "3000";
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
- 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