# fixme: when rebuiling the commands are ran as some nixos builder user probably and autorandr does not use my config # fixme: main issue here is that xrandr can't open a display as the nixbld user { pkgs, ... }: let autorandr = "${pkgs.autorandr}/bin/autorandr"; rg = "${pkgs.ripgrep}/bin/rg"; rev = "${pkgs.util-linux}/bin/rev"; cut = "${pkgs.coreutils-full}/bin/cut"; xrandr = "${pkgs.xorg.xrandr}/bin/xrandr"; # epically stolen from https://git.jacekpoz.pl/jacekpoz/nte/src/branch/master/stdlib.nix # and modified inherit (pkgs) lib runCommandLocal; inherit (lib.strings) readFile; run = script: readFile (runCommandLocal "run" {} '' bash -c '${script}' &> $out || true ''); 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 # 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 = ""; }