nix: i3: add autorandr

This commit is contained in:
Geoffrey Frogeye 2023-11-03 21:28:29 +01:00
parent ae9893fc08
commit c51aeacd03
Signed by: geoffrey
GPG key ID: C72403E7F82E6AD8
7 changed files with 23 additions and 59 deletions

View file

@ -1,2 +0,0 @@
theme.yml
alacritty.yml

View file

@ -1,10 +0,0 @@
#!/usr/bin/env bash
shopt -s nullglob globstar
profile=$(echo -e "$(autorandr 2>&1 | cut -d' ' -f1)" | rofi -dmenu -p "Default profile" "$@")
[[ -n $profile ]] || exit
autorandr --default "$profile"

View file

@ -1,10 +0,0 @@
#!/usr/bin/env bash
shopt -s nullglob globstar
profile=$(echo -e "common\nclone-largest\nhorizontal\nvertical\n$(autorandr 2>&1 | cut -d' ' -f1)" | rofi -dmenu -p "Load profile" "$@")
[[ -n $profile ]] || exit
autorandr --load "$profile"

View file

@ -1,10 +0,0 @@
#!/usr/bin/env bash
shopt -s nullglob globstar
profile=$(echo -e "$(autorandr 2>&1 | cut -d' ' -f1)" | rofi -dmenu -p "Remove profile" "$@")
[[ -n $profile ]] || exit
autorandr --remove "$profile"

View file

@ -1,10 +0,0 @@
#!/usr/bin/env bash
shopt -s nullglob globstar
profile=$(echo -e "$(autorandr 2>&1 | cut -d' ' -f1)" | rofi -dmenu -p "Save profile" "$@")
[[ -n $profile ]] || exit
autorandr --save "$profile"

View file

@ -65,20 +65,6 @@ for_window [urgent=latest] focus
# Set shut down, restart and locking features
set $locker $HOME/.config/i3/lock
set $mode_screen Screen setup [A] Auto [L] Load [S] Save [R] Remove [D] Default
"$mod+t" = "mode "$mode_screen"";
mode "$mode_screen" {
"a" = "exec autorandr --change --force, mode "default"";
"l" = "exec ~/.config/i3/autorandrloadmenu, mode "default"";
"s" = "exec ~/.config/i3/autorandrsavemenu, mode "default"";
"r" = "exec ~/.config/i3/autorandrremovemenu, mode "default"";
"d" = "exec ~/.config/i3/autorandrdefaultmenu, mode "default"";
# back to normal: Enter or Escape
"Return" = "mode "default"";
"Escape" = "mode "default"";
}
# Screen temperature ("redness") setting
"$mod+y" = "mode "$mode_temp"";
set $mode_temp Temperature [R] Red [D] Dust storm [C] Campfire [O] Normal [A] All nighter [B] Blue

View file

@ -48,6 +48,7 @@
mode_resize = "Resize";
mode_pres_main = "Presentation (main display)";
mode_pres_sec = "Presentation (secondary display)";
mode_screen = "Screen setup [A] Auto [L] Load [S] Save [R] Remove [D] Default";
in
{
terminal = "alacritty";
@ -206,6 +207,7 @@
"${mod}+Escape" = "mode ${mode_system}";
"${mod}+r" = "mode ${mode_resize}";
"${mod}+Shift+p" = "mode ${mode_pres_main}";
"${mod}+t" = "mode ${mode_screen}";
};
modes = let return_bindings = {
"Return" = "mode default";
@ -227,15 +229,34 @@
"l" = "resize grow width 10 px or 10 ppt; ${focus}";
} // return_bindings;
"${mode_pres_main}" = {
"b" = "workspace 3, workspace 4, mode $mode_pres_sec";
"b" = "workspace 3, workspace 4, mode ${mode_pres_sec}";
"q" = "mode default";
"Return" = "mode default";
};
"${mode_pres_sec}" = {
"b" = "workspace 1, workspace 2, mode $mode_pres_main";
"b" = "workspace 1, workspace 2, mode ${mode_pres_main}";
"q" = "mode default";
"Return" = "mode default";
};
"${mode_screen}" =
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
{
"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";
} // return_bindings;
};
};
};
@ -339,7 +360,6 @@
xautolock
xclip
lemonbar-xft
autorandr
keynav
sct
xorg.xinit