From 26e70acb2ffec866a8ec5a2443328ebd1df77a42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Mon, 15 Jan 2024 14:50:02 +0100 Subject: [PATCH] autorandr: Split out --- hm/desktop/autorandr/default.nix | 32 ++++++++++++++++++++++++++++++++ hm/desktop/default.nix | 8 +------- hm/desktop/i3.nix | 24 +----------------------- hm/style.nix | 4 ++++ 4 files changed, 38 insertions(+), 30 deletions(-) create mode 100644 hm/desktop/autorandr/default.nix diff --git a/hm/desktop/autorandr/default.nix b/hm/desktop/autorandr/default.nix new file mode 100644 index 0000000..21cf210 --- /dev/null +++ b/hm/desktop/autorandr/default.nix @@ -0,0 +1,32 @@ +{ pkgs, lib, config, ... }: +let + builtin_configs = [ "off" "common" "clone-largest" "horizontal" "vertical" "horizontal-reverse" "vertical-reverse" ]; + autorandrmenu = { title, option, builtin ? false }: pkgs.writeShellScript "autorandrmenu" + '' + shopt -s nullglob globstar + profiles="${if builtin then lib.strings.concatLines builtin_configs else ""}$(${pkgs.autorandr}/bin/autorandr | ${pkgs.gawk}/bin/awk '{ print $1 }')" + profile="$(echo "$profiles" | ${config.programs.rofi.package}/bin/rofi -dmenu -p "${title}")" + [[ -n "$profile" ]] || exit + ${pkgs.autorandr}/bin/autorandr ${option} "$profile" + ''; +in +{ + config = lib.mkIf config.frogeye.desktop.xorg { + frogeye.desktop.i3.bindmodes = { + "Screen setup [A] Auto [L] Load [S] Save [R] Remove [D] Default" = + { + bindings = { + "a" = "exec ${pkgs.autorandr}/bin/autorandr --change --force, mode default"; + "l" = "exec ${autorandrmenu {title="Load profile"; option="--load"; builtin = true;}}, mode default"; + "s" = "exec ${autorandrmenu {title="Save profile"; option="--save";}}, mode default"; + "r" = "exec ${autorandrmenu {title="Remove profile"; option="--remove";}}, mode default"; + "d" = "exec ${autorandrmenu {title="Default profile"; option="--default"; builtin = true;}}, mode default"; + }; + mod_enter = "t"; + }; + }; + programs.autorandr.enable = true; + services.autorandr.enable = true; + }; +} +# TODO Deterministic configs? diff --git a/hm/desktop/default.nix b/hm/desktop/default.nix index d9b9acd..314ad4e 100644 --- a/hm/desktop/default.nix +++ b/hm/desktop/default.nix @@ -6,6 +6,7 @@ in { imports = [ ./audio + ./autorandr ./frobar ./i3.nix ./lock @@ -113,12 +114,6 @@ in matching = "regex"; }; }; - autorandr = { - enable = true; - hooks.postswitch = { - background = "${pkgs.feh}/bin/feh --no-fehbg --bg-fill ${config.stylix.image}"; - }; - }; mpv = { enable = true; config = { @@ -203,7 +198,6 @@ in }; }; }; - autorandr.enable = true; }; home = { diff --git a/hm/desktop/i3.nix b/hm/desktop/i3.nix index 4633fc8..9c39f6d 100644 --- a/hm/desktop/i3.nix +++ b/hm/desktop/i3.nix @@ -232,7 +232,7 @@ in return_bindings = false; }; "${mode_pres_sec}" = { - mod_enter = "Shift+p+2"; + mod_enter = "Shift+p+2"; # Bogus, just so I don't have to implement no binding bindings = { "b" = "workspace 1, workspace 2, mode ${mode_pres_main}"; "q" = "mode default"; @@ -240,28 +240,6 @@ in }; return_bindings = false; }; - "Screen setup [A] Auto [L] Load [S] Save [R] Remove [D] Default" = - let - builtin_configs = [ "off" "common" "clone-largest" "horizontal" "vertical" "horizontal-reverse" "vertical-reverse" ]; - autorandrmenu = { title, option, builtin ? false }: pkgs.writeShellScript "autorandrmenu" - '' - shopt -s nullglob globstar - profiles="${if builtin then lib.strings.concatLines builtin_configs else ""}$(${pkgs.autorandr}/bin/autorandr | ${pkgs.gawk}/bin/awk '{ print $1 }')" - profile="$(echo "$profiles" | ${config.programs.rofi.package}/bin/rofi -dmenu -p "${title}")" - [[ -n "$profile" ]] || exit - ${pkgs.autorandr}/bin/autorandr ${option} "$profile" - ''; - in - { - bindings = { - "a" = "exec ${pkgs.autorandr}/bin/autorandr --change --force, mode default"; - "l" = "exec ${autorandrmenu {title="Load profile"; option="--load"; builtin = true;}}, mode default"; - "s" = "exec ${autorandrmenu {title="Save profile"; option="--save";}}, mode default"; - "r" = "exec ${autorandrmenu {title="Remove profile"; option="--remove";}}, mode default"; - "d" = "exec ${autorandrmenu {title="Default profile"; option="--default"; builtin = true;}}, mode default"; - }; - mod_enter = "t"; - }; "Temperature [R] Red [D] Dust storm [C] Campfire [O] Normal [A] All nighter [B] Blue" = { bindings = { "r" = "exec ${pkgs.sct}/bin/sct 1000"; diff --git a/hm/style.nix b/hm/style.nix index 28fd0bf..c758b79 100644 --- a/hm/style.nix +++ b/hm/style.nix @@ -28,6 +28,10 @@ in }; }; + programs.autorandr.hooks.postswitch = { + background = "${pkgs.feh}/bin/feh --no-fehbg --bg-fill ${config.stylix.image}"; + }; + # Fix https://nix-community.github.io/home-manager/index.html#_why_do_i_get_an_error_message_about_literal_ca_desrt_dconf_literal_or_literal_dconf_service_literal # home.packages = [ pkgs.dconf ];