Skip to content

Commit

Permalink
refac(boar): DDCCI loading (but no cigar yet)
Browse files Browse the repository at this point in the history
  • Loading branch information
workflow committed Oct 16, 2024
1 parent 0e1a06e commit d0a4fba
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 38 deletions.
2 changes: 1 addition & 1 deletion home/i3/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ in {
# See https://discourse.nixos.org/t/brightness-control-of-external-monitors-with-ddcci-backlight/8639/10
# For some reason this has to run from userland, after the xSession is started
{
command = "sudo /home/farlion/code/nixos-config/home/xsession/boar_ddc_fix.sh";
command = "sudo /home/farlion/code/nixos-config/home/xsession/boar_ddcci_fix.sh";
notification = false;
}
];
Expand Down
2 changes: 1 addition & 1 deletion home/i3status-rust.nix
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ in {
# }
{
block = "backlight";
device = "ddcci5";
device = "ddcci0";
click = [
{
button = "left";
Expand Down
28 changes: 0 additions & 28 deletions home/xsession/boar_ddc_fix.sh

This file was deleted.

28 changes: 28 additions & 0 deletions home/xsession/boar_ddcci_fix.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#! /run/current-system/sw/bin/bash
set -euo pipefail

# See https://discourse.nixos.org/t/brightness-control-of-external-monitors-with-ddcci-backlight/8639/10

sleep 5

echo Trying to attach ddcci to i2c-7
counter=10
while [ $counter -gt 0 ]; do
if ddcutil getvcp 10 -b 7; then
echo ddcci 0x37 >/sys/bus/i2c/devices/i2c-7/new_device
break
fi
sleep 1
counter=$((counter - 1))
done

# echo Trying to attach ddcci to i2c-5
# counter=10
# while [ $counter -gt 0 ]; do
# if ddcutil getvcp 10 -b 5; then
# echo ddcci 0x37 >/sys/bus/i2c/devices/i2c-5/new_device
# break
# fi
# sleep 1
# counter=$((counter - 1))
# done
9 changes: 8 additions & 1 deletion machines/boar/system.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
lib,
config,
pkgs,
...
}: {
# Use the systemd-boot EFI boot loader.
Expand All @@ -13,12 +14,18 @@
# External monitors brightness control
# See https://discourse.nixos.org/t/brightness-control-of-external-monitors-with-ddcci-backlight/8639/11
boot.extraModulePackages = with config.boot.kernelPackages; [ddcci-driver];
boot.initrd.kernelModules = ["ddcci_backlight"];
environment.systemPackages = [pkgs.ddcutil];
services.ddccontrol.enable = true;
hardware.i2c.enable = true;
users.users.farlion.extraGroups = ["i2c"];

security.sudo.extraRules = [
{
users = ["farlion"];
commands = [
{
command = "/home/farlion/code/nixos-config/home/xsession/boar_ddc_fix.sh";
command = "/home/farlion/code/nixos-config/home/xsession/boar_ddcci_fix.sh";
options = ["NOPASSWD" "SETENV"];
}
];
Expand Down
1 change: 0 additions & 1 deletion packages/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
cht-sh
cntr # for Nix sandbox breakpointHook debugging
dconf
ddcutil # For external monitor management, used by home/xsession/boar_ddc_fix.sh
delta # Syntax highlighter for git
unstable.devenv
difftastic
Expand Down
7 changes: 1 addition & 6 deletions system/screens.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
{pkgs, ...}: {
# Controlling external screens
services.ddccontrol.enable = true;
hardware.i2c.enable = true;
users.users.farlion.extraGroups = ["i2c"];

{...}: {
# For redshift
services.geoclue2.enable = true;
}

0 comments on commit d0a4fba

Please sign in to comment.