From def13f722646b06926201415ac152f80d3b11a44 Mon Sep 17 00:00:00 2001 From: krizej <60076189+krizej@users.noreply.github.com> Date: Wed, 10 Jul 2024 21:28:29 +0200 Subject: [PATCH] agony --- utils/monitors.nix | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/utils/monitors.nix b/utils/monitors.nix index 4002557..3e9ba7e 100644 --- a/utils/monitors.nix +++ b/utils/monitors.nix @@ -1,20 +1,32 @@ # 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 - # but i changed lib.strings.readFile to lib.fileContents - inherit (pkgs) lib runCommand; - inherit (lib) fileContents; - run = script: builtins.toString (runCommand "run" {} '' - echo $(${script}) > $out + # 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 "${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}"; +# 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 = ""; }