sway: make bindings more readable

This commit is contained in:
Leonardo Eugênio 2023-11-21 18:01:20 -03:00
parent 6528a97d21
commit b8ee69c66b
2 changed files with 45 additions and 35 deletions

View file

@ -9,6 +9,7 @@ let
terminal = "alacritty"; terminal = "alacritty";
_lock = pkgs.writeShellScriptBin "_lock" '' _lock = pkgs.writeShellScriptBin "_lock" ''
${pkgs.sway}/bin/swaymsg mode default
${pkgs.swaylock}/bin/swaylock -f ${pkgs.swaylock}/bin/swaylock -f
systemctl --user start swayidle.service systemctl --user start swayidle.service
''; '';

View file

@ -8,59 +8,68 @@ let
menu = "wlauncher"; menu = "wlauncher";
terminal = "alacritty"; terminal = "alacritty";
locked_binds = locked =
lib.mapAttrs' (k: v: lib.nameValuePair "--locked ${k}" v); lib.mapAttrs' (k: v: lib.nameValuePair "--locked ${k}" v);
code_binds = to-code =
lib.mapAttrs' (k: v: lib.nameValuePair "--to-code ${k}" v); lib.mapAttrs' (k: v: lib.nameValuePair "--to-code ${k}" v);
return_mode = lib.mapAttrs (k: v: "${v}; mode default"); quit-mode = lib.mapAttrs (k: v: "${v}; mode default");
playerctl = "exec ${pkgs.playerctl}/bin/playerctl"; playerctl = "exec ${pkgs.playerctl}/bin/playerctl";
bind_group = opts: binds: lib.pipe binds opts;
in in
{ {
wayland.windowManager.sway.config.modes = { wayland.windowManager.sway.config.modes = {
audio = code_binds audio =
(locked_binds { (bind_group [ to-code locked ] {
${key.tabR} = "exec volumesh -i 10"; ${key.tabR} = "exec volumesh -i 10";
${key.tabL} = "exec volumesh -d 10"; ${key.tabL} = "exec volumesh -d 10";
${key.right} = "exec mpc next"; ${key.right} = "exec mpc next";
${key.left} = "exec mpc prev"; ${key.left} = "exec mpc prev";
${key.up} = "exec volumesh --mpd -i 10"; ${key.up} = "exec volumesh --mpd -i 10";
${key.down} = "exec volumesh --mpd -d 10"; ${key.down} = "exec volumesh --mpd -d 10";
}) // return_mode { }) //
"space" = "exec mpc toggle"; (bind_group [ locked quit-mode ] {
"escape" = ""; "space" = "exec mpc toggle";
"q" = ""; "escape" = "";
"m" = "exec volumesh -t"; "q" = "";
"s" = "exec ${pkgs.pulse_sink}/bin/pulse_sink"; }) //
(bind_group [ quit-mode ] {
"m" = "exec volumesh -t";
"s" = "exec ${pkgs.pulse_sink}/bin/pulse_sink";
"d" = "exec ${pkgs.musmenu}/bin/musmenu delete"; "d" = "exec ${pkgs.musmenu}/bin/musmenu delete";
"f" = "exec ${pkgs.musmenu}/bin/musmenu search"; "f" = "exec ${pkgs.musmenu}/bin/musmenu search";
"a" = "exec ${pkgs.dzadd}/bin/dzadd"; "a" = "exec ${pkgs.dzadd}/bin/dzadd";
"Shift+y" = "exec ${pkgs.musmenu}/bin/musmenu yank"; "Shift+y" = "exec ${pkgs.musmenu}/bin/musmenu yank";
"Ctrl+a" = "exec ${pkgs.musmenu}/bin/musmenu padd"; "Ctrl+a" = "exec ${pkgs.musmenu}/bin/musmenu padd";
"Ctrl+s" = "exec ${pkgs.musmenu}/bin/musmenu psave"; "Ctrl+s" = "exec ${pkgs.musmenu}/bin/musmenu psave";
"Ctrl+o" = "exec ${pkgs.musmenu}/bin/musmenu pload"; "Ctrl+o" = "exec ${pkgs.musmenu}/bin/musmenu pload";
"Ctrl+d" = "exec ${pkgs.musmenu}/bin/musmenu pdelete"; "Ctrl+d" = "exec ${pkgs.musmenu}/bin/musmenu pdelete";
} // { }) //
"p" = "mode playerctl"; {
"Ctrl+c" = "exec musmenu pclear"; "p" = "mode playerctl";
}; "Ctrl+c" = "exec musmenu pclear";
playerctl = code_binds }
((locked_binds ;
{
${key.left} = "${playerctl} previous"; playerctl =
${key.right} = "${playerctl} next"; (bind_group [ to-code locked ] {
${key.up} = "${playerctl} volume 10+"; ${key.left} = "${playerctl} previous";
${key.down} = "${playerctl} volume 10-"; ${key.right} = "${playerctl} next";
${key.tabR} = "${playerctl} volume 10+"; ${key.up} = "${playerctl} volume 10+";
${key.tabL} = "${playerctl} volume 10-"; ${key.down} = "${playerctl} volume 10-";
}) // ${key.tabR} = "${playerctl} volume 10+";
(return_mode { ${key.tabL} = "${playerctl} volume 10-";
}) //
(bind_group [ to-code quit-mode ] {
"space" = "${playerctl} play-pause"; "space" = "${playerctl} play-pause";
"escape" = ""; "escape" = "";
"q" = ""; "q" = "";
})); })
;
passthrough = { passthrough = {
"${mod}+escape" = "mode default;exec notify-send 'Passthrough off'"; "${mod}+escape" = "mode default;exec notify-send 'Passthrough off'";
}; };