nix/utils/monitors.nix

33 lines
1.3 KiB
Nix
Raw Normal View History

2024-07-10 19:54:20 +02:00
# fixme: when rebuiling the commands are ran as some nixos builder user probably and autorandr does not use my config
2024-07-10 21:28:29 +02:00
# fixme: main issue here is that xrandr can't open a display as the nixbld user
2024-07-10 19:54:20 +02:00
{ pkgs, ... }: let
autorandr = "${pkgs.autorandr}/bin/autorandr";
rg = "${pkgs.ripgrep}/bin/rg";
rev = "${pkgs.util-linux}/bin/rev";
cut = "${pkgs.coreutils-full}/bin/cut";
2024-07-10 21:28:29 +02:00
xrandr = "${pkgs.xorg.xrandr}/bin/xrandr";
2024-07-10 19:54:20 +02:00
# epically stolen from https://git.jacekpoz.pl/jacekpoz/nte/src/branch/master/stdlib.nix
2024-07-10 21:28:29 +02:00
# and modified
inherit (pkgs) lib runCommandLocal;
inherit (lib.strings) readFile;
run = script: readFile (runCommandLocal "run" {} ''
bash -c '${script}' &> $out || true
2024-07-10 19:54:20 +02:00
'');
in {
# this parses "main: renaming display Left to DisplayPort-2"
# and i am interested in "DisplayPort-2"
# and also it's printed to stderr so 2>&1
2024-07-10 21:28:29 +02:00
# left = run "XDG_CONFIG_HOME=/home/krizej/.config/; ${autorandr} --match-edid 2>&1 | ${rg} Left | ${rev} | ${cut} -d\" \" -f1 | ${rev}";
# right = run "${autorandr} --match-edid 2>&1 | ${rg} Right | ${rev} | ${cut} -d' ' -f1 | ${rev}";
right = run ''
mkdir autorandr
mkdir autorandr/main
touch autorandr/main/config
touch autorandr/main/status
PATH=$PATH:${pkgs.xorg.xrandr}/bin; ${autorandr} --list
'';
left = "";
2024-07-10 19:54:20 +02:00
}