refactor(hyprland): write lua bind data directly
This commit is contained in:
@@ -7,36 +7,6 @@
|
||||
# The Hyprland compositor.
|
||||
let
|
||||
cfg = config.modules.desktop.session.hyprland; # NOLINT(let_order)
|
||||
lua = rec {
|
||||
toLua = lib.generators.toLua { };
|
||||
call =
|
||||
function: args:
|
||||
lib.generators.mkLuaInline "${function}(${lib.concatMapStringsSep ", " toLua args})";
|
||||
bind = key: dispatcher: {
|
||||
_args = [
|
||||
key
|
||||
dispatcher
|
||||
];
|
||||
};
|
||||
bindWith = key: dispatcher: options: {
|
||||
_args = [
|
||||
key
|
||||
dispatcher
|
||||
options
|
||||
];
|
||||
};
|
||||
execBind = key: command: bind key (call "hl.dsp.exec_cmd" [ command ]);
|
||||
execBindWith =
|
||||
key: command: options:
|
||||
bindWith key (call "hl.dsp.exec_cmd" [ command ]) options;
|
||||
|
||||
# Numbered-workspace switch and move for 1..9, the operator's i3 muscle memory.
|
||||
workspaceBinds = lib.concatMap (n: [
|
||||
(bind "SUPER + ${toString n}" (call "hl.dsp.focus" [ { workspace = n; } ]))
|
||||
(bind "SUPER + SHIFT + ${toString n}" (call "hl.dsp.window.move" [ { workspace = n; } ]))
|
||||
]) (lib.range 1 9);
|
||||
};
|
||||
|
||||
cursor = config.stylix.cursor;
|
||||
user = config.user.name;
|
||||
|
||||
@@ -236,95 +206,257 @@ in
|
||||
];
|
||||
|
||||
bind = [
|
||||
(lua.execBind "SUPER + Return" "ghostty")
|
||||
{
|
||||
_args = [
|
||||
"SUPER + Return"
|
||||
(lib.generators.mkLuaInline "hl.dsp.exec_cmd(${(lib.generators.toLua { }) "ghostty"})")
|
||||
];
|
||||
}
|
||||
|
||||
# Move focus.
|
||||
(lua.bind "SUPER + H" (lua.call "hl.dsp.focus" [ { direction = "left"; } ]))
|
||||
(lua.bind "SUPER + J" (lua.call "hl.dsp.focus" [ { direction = "down"; } ]))
|
||||
(lua.bind "SUPER + K" (lua.call "hl.dsp.focus" [ { direction = "up"; } ]))
|
||||
(lua.bind "SUPER + L" (lua.call "hl.dsp.focus" [ { direction = "right"; } ]))
|
||||
{
|
||||
_args = [
|
||||
"SUPER + H"
|
||||
(lib.generators.mkLuaInline "hl.dsp.focus(${(lib.generators.toLua { }) { direction = "left"; }})")
|
||||
];
|
||||
}
|
||||
{
|
||||
_args = [
|
||||
"SUPER + J"
|
||||
(lib.generators.mkLuaInline "hl.dsp.focus(${(lib.generators.toLua { }) { direction = "down"; }})")
|
||||
];
|
||||
}
|
||||
{
|
||||
_args = [
|
||||
"SUPER + K"
|
||||
(lib.generators.mkLuaInline "hl.dsp.focus(${(lib.generators.toLua { }) { direction = "up"; }})")
|
||||
];
|
||||
}
|
||||
{
|
||||
_args = [
|
||||
"SUPER + L"
|
||||
(lib.generators.mkLuaInline "hl.dsp.focus(${(lib.generators.toLua { }) { direction = "right"; }})")
|
||||
];
|
||||
}
|
||||
|
||||
# Move the window within the layout.
|
||||
(lua.bind "SUPER + SHIFT + H" (lua.call "hl.dsp.window.move" [ { direction = "left"; } ]))
|
||||
(lua.bind "SUPER + SHIFT + J" (lua.call "hl.dsp.window.move" [ { direction = "down"; } ]))
|
||||
(lua.bind "SUPER + SHIFT + K" (lua.call "hl.dsp.window.move" [ { direction = "up"; } ]))
|
||||
(lua.bind "SUPER + SHIFT + L" (lua.call "hl.dsp.window.move" [ { direction = "right"; } ]))
|
||||
{
|
||||
_args = [
|
||||
"SUPER + SHIFT + H"
|
||||
(lib.generators.mkLuaInline "hl.dsp.window.move(${
|
||||
(lib.generators.toLua { }) { direction = "left"; }
|
||||
})")
|
||||
];
|
||||
}
|
||||
{
|
||||
_args = [
|
||||
"SUPER + SHIFT + J"
|
||||
(lib.generators.mkLuaInline "hl.dsp.window.move(${
|
||||
(lib.generators.toLua { }) { direction = "down"; }
|
||||
})")
|
||||
];
|
||||
}
|
||||
{
|
||||
_args = [
|
||||
"SUPER + SHIFT + K"
|
||||
(lib.generators.mkLuaInline "hl.dsp.window.move(${
|
||||
(lib.generators.toLua { }) { direction = "up"; }
|
||||
})")
|
||||
];
|
||||
}
|
||||
{
|
||||
_args = [
|
||||
"SUPER + SHIFT + L"
|
||||
(lib.generators.mkLuaInline "hl.dsp.window.move(${
|
||||
(lib.generators.toLua { }) { direction = "right"; }
|
||||
})")
|
||||
];
|
||||
}
|
||||
|
||||
# Resize the active window.
|
||||
(lua.bind "SUPER + ALT + H" (
|
||||
lua.call "hl.dsp.window.resize" [
|
||||
{
|
||||
x = -40;
|
||||
y = 0;
|
||||
relative = true;
|
||||
}
|
||||
]
|
||||
))
|
||||
(lua.bind "SUPER + ALT + J" (
|
||||
lua.call "hl.dsp.window.resize" [
|
||||
{
|
||||
x = 0;
|
||||
y = 40;
|
||||
relative = true;
|
||||
}
|
||||
]
|
||||
))
|
||||
(lua.bind "SUPER + ALT + K" (
|
||||
lua.call "hl.dsp.window.resize" [
|
||||
{
|
||||
x = 0;
|
||||
y = -40;
|
||||
relative = true;
|
||||
}
|
||||
]
|
||||
))
|
||||
(lua.bind "SUPER + ALT + L" (
|
||||
lua.call "hl.dsp.window.resize" [
|
||||
{
|
||||
x = 40;
|
||||
y = 0;
|
||||
relative = true;
|
||||
}
|
||||
]
|
||||
))
|
||||
{
|
||||
_args = [
|
||||
"SUPER + ALT + H"
|
||||
(lib.generators.mkLuaInline "hl.dsp.window.resize(${
|
||||
(lib.generators.toLua { }) {
|
||||
x = -40;
|
||||
y = 0;
|
||||
relative = true;
|
||||
}
|
||||
})")
|
||||
];
|
||||
}
|
||||
{
|
||||
_args = [
|
||||
"SUPER + ALT + J"
|
||||
(lib.generators.mkLuaInline "hl.dsp.window.resize(${
|
||||
(lib.generators.toLua { }) {
|
||||
x = 0;
|
||||
y = 40;
|
||||
relative = true;
|
||||
}
|
||||
})")
|
||||
];
|
||||
}
|
||||
{
|
||||
_args = [
|
||||
"SUPER + ALT + K"
|
||||
(lib.generators.mkLuaInline "hl.dsp.window.resize(${
|
||||
(lib.generators.toLua { }) {
|
||||
x = 0;
|
||||
y = -40;
|
||||
relative = true;
|
||||
}
|
||||
})")
|
||||
];
|
||||
}
|
||||
{
|
||||
_args = [
|
||||
"SUPER + ALT + L"
|
||||
(lib.generators.mkLuaInline "hl.dsp.window.resize(${
|
||||
(lib.generators.toLua { }) {
|
||||
x = 40;
|
||||
y = 0;
|
||||
relative = true;
|
||||
}
|
||||
})")
|
||||
];
|
||||
}
|
||||
|
||||
(lua.bind "SUPER + Space" (lua.call "hl.dsp.window.float" [ { action = "toggle"; } ]))
|
||||
(lua.bind "SUPER + F" (lua.call "hl.dsp.window.fullscreen" [ ]))
|
||||
{
|
||||
_args = [
|
||||
"SUPER + Space"
|
||||
(lib.generators.mkLuaInline "hl.dsp.window.float(${
|
||||
(lib.generators.toLua { }) { action = "toggle"; }
|
||||
})")
|
||||
];
|
||||
}
|
||||
{
|
||||
_args = [
|
||||
"SUPER + F"
|
||||
(lib.generators.mkLuaInline "hl.dsp.window.fullscreen()")
|
||||
];
|
||||
}
|
||||
# togglesplit is a dwindle layout message, reached through layout.
|
||||
(lua.bind "SUPER + T" (lua.call "hl.dsp.layout" [ "togglesplit" ]))
|
||||
(lua.execBind "SUPER + SHIFT + T" "${toggleLayout}")
|
||||
(lua.bind "SUPER + SHIFT + Q" (lua.call "hl.dsp.window.close" [ ]))
|
||||
(lua.bind "SUPER + CTRL + Q" (lua.call "hl.dsp.window.kill" [ ]))
|
||||
{
|
||||
_args = [
|
||||
"SUPER + T"
|
||||
(lib.generators.mkLuaInline "hl.dsp.layout(${(lib.generators.toLua { }) "togglesplit"})")
|
||||
];
|
||||
}
|
||||
{
|
||||
_args = [
|
||||
"SUPER + SHIFT + T"
|
||||
(lib.generators.mkLuaInline "hl.dsp.exec_cmd(${(lib.generators.toLua { }) "${toggleLayout}"})")
|
||||
];
|
||||
}
|
||||
{
|
||||
_args = [
|
||||
"SUPER + SHIFT + Q"
|
||||
(lib.generators.mkLuaInline "hl.dsp.window.close()")
|
||||
];
|
||||
}
|
||||
{
|
||||
_args = [
|
||||
"SUPER + CTRL + Q"
|
||||
(lib.generators.mkLuaInline "hl.dsp.window.kill()")
|
||||
];
|
||||
}
|
||||
|
||||
# Volume and brightness keys repeat while held, each raising a popup
|
||||
# through the OSD client.
|
||||
# Volume is capped at 100 percent.
|
||||
# The client floors brightness so a full hold cannot black the screen out.
|
||||
(lua.execBindWith "XF86AudioRaiseVolume"
|
||||
"${pkgs.swayosd}/bin/swayosd-client --output-volume raise --max-volume 100"
|
||||
{ repeating = true; }
|
||||
)
|
||||
(lua.execBindWith "XF86AudioLowerVolume" "${pkgs.swayosd}/bin/swayosd-client --output-volume lower"
|
||||
{
|
||||
repeating = true;
|
||||
}
|
||||
)
|
||||
(lua.execBindWith "XF86MonBrightnessUp" "${pkgs.swayosd}/bin/swayosd-client --brightness raise" {
|
||||
repeating = true;
|
||||
})
|
||||
(lua.execBindWith "XF86MonBrightnessDown" "${pkgs.swayosd}/bin/swayosd-client --brightness lower" {
|
||||
repeating = true;
|
||||
})
|
||||
{
|
||||
_args = [
|
||||
"XF86AudioRaiseVolume"
|
||||
(lib.generators.mkLuaInline "hl.dsp.exec_cmd(${
|
||||
(lib.generators.toLua { })
|
||||
"${pkgs.swayosd}/bin/swayosd-client --output-volume raise --max-volume 100"
|
||||
})")
|
||||
{ repeating = true; }
|
||||
];
|
||||
}
|
||||
{
|
||||
_args = [
|
||||
"XF86AudioLowerVolume"
|
||||
(lib.generators.mkLuaInline "hl.dsp.exec_cmd(${
|
||||
(lib.generators.toLua { }) "${pkgs.swayosd}/bin/swayosd-client --output-volume lower"
|
||||
})")
|
||||
{ repeating = true; }
|
||||
];
|
||||
}
|
||||
{
|
||||
_args = [
|
||||
"XF86MonBrightnessUp"
|
||||
(lib.generators.mkLuaInline "hl.dsp.exec_cmd(${
|
||||
(lib.generators.toLua { }) "${pkgs.swayosd}/bin/swayosd-client --brightness raise"
|
||||
})")
|
||||
{ repeating = true; }
|
||||
];
|
||||
}
|
||||
{
|
||||
_args = [
|
||||
"XF86MonBrightnessDown"
|
||||
(lib.generators.mkLuaInline "hl.dsp.exec_cmd(${
|
||||
(lib.generators.toLua { }) "${pkgs.swayosd}/bin/swayosd-client --brightness lower"
|
||||
})")
|
||||
{ repeating = true; }
|
||||
];
|
||||
}
|
||||
|
||||
# Mute and media transport still fire while the session is locked.
|
||||
(lua.execBindWith "XF86AudioMute" "${pkgs.swayosd}/bin/swayosd-client --output-volume mute-toggle" {
|
||||
locked = true;
|
||||
})
|
||||
(lua.execBindWith "XF86AudioPlay" "${pkgs.playerctl}/bin/playerctl play-pause" { locked = true; })
|
||||
(lua.execBindWith "XF86AudioNext" "${pkgs.playerctl}/bin/playerctl next" { locked = true; })
|
||||
(lua.execBindWith "XF86AudioPrev" "${pkgs.playerctl}/bin/playerctl previous" { locked = true; })
|
||||
{
|
||||
_args = [
|
||||
"XF86AudioMute"
|
||||
(lib.generators.mkLuaInline "hl.dsp.exec_cmd(${
|
||||
(lib.generators.toLua { }) "${pkgs.swayosd}/bin/swayosd-client --output-volume mute-toggle"
|
||||
})")
|
||||
{ locked = true; }
|
||||
];
|
||||
}
|
||||
{
|
||||
_args = [
|
||||
"XF86AudioPlay"
|
||||
(lib.generators.mkLuaInline "hl.dsp.exec_cmd(${
|
||||
(lib.generators.toLua { }) "${pkgs.playerctl}/bin/playerctl play-pause"
|
||||
})")
|
||||
{ locked = true; }
|
||||
];
|
||||
}
|
||||
{
|
||||
_args = [
|
||||
"XF86AudioNext"
|
||||
(lib.generators.mkLuaInline "hl.dsp.exec_cmd(${
|
||||
(lib.generators.toLua { }) "${pkgs.playerctl}/bin/playerctl next"
|
||||
})")
|
||||
{ locked = true; }
|
||||
];
|
||||
}
|
||||
{
|
||||
_args = [
|
||||
"XF86AudioPrev"
|
||||
(lib.generators.mkLuaInline "hl.dsp.exec_cmd(${
|
||||
(lib.generators.toLua { }) "${pkgs.playerctl}/bin/playerctl previous"
|
||||
})")
|
||||
{ locked = true; }
|
||||
];
|
||||
}
|
||||
]
|
||||
++ lua.workspaceBinds;
|
||||
++ lib.concatMap (n: [
|
||||
{
|
||||
_args = [
|
||||
"SUPER + ${toString n}"
|
||||
(lib.generators.mkLuaInline "hl.dsp.focus(${(lib.generators.toLua { }) { workspace = n; }})")
|
||||
];
|
||||
}
|
||||
{
|
||||
_args = [
|
||||
"SUPER + SHIFT + ${toString n}"
|
||||
(lib.generators.mkLuaInline "hl.dsp.window.move(${(lib.generators.toLua { }) { workspace = n; }})")
|
||||
];
|
||||
}
|
||||
]) (lib.range 1 9);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user