refactor(hyprland): write lua bind data directly
This commit is contained in:
@@ -7,36 +7,6 @@
|
|||||||
# The Hyprland compositor.
|
# The Hyprland compositor.
|
||||||
let
|
let
|
||||||
cfg = config.modules.desktop.session.hyprland; # NOLINT(let_order)
|
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;
|
cursor = config.stylix.cursor;
|
||||||
user = config.user.name;
|
user = config.user.name;
|
||||||
|
|
||||||
@@ -236,95 +206,257 @@ in
|
|||||||
];
|
];
|
||||||
|
|
||||||
bind = [
|
bind = [
|
||||||
(lua.execBind "SUPER + Return" "ghostty")
|
{
|
||||||
|
_args = [
|
||||||
|
"SUPER + Return"
|
||||||
|
(lib.generators.mkLuaInline "hl.dsp.exec_cmd(${(lib.generators.toLua { }) "ghostty"})")
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
# Move focus.
|
# Move focus.
|
||||||
(lua.bind "SUPER + H" (lua.call "hl.dsp.focus" [ { direction = "left"; } ]))
|
{
|
||||||
(lua.bind "SUPER + J" (lua.call "hl.dsp.focus" [ { direction = "down"; } ]))
|
_args = [
|
||||||
(lua.bind "SUPER + K" (lua.call "hl.dsp.focus" [ { direction = "up"; } ]))
|
"SUPER + H"
|
||||||
(lua.bind "SUPER + L" (lua.call "hl.dsp.focus" [ { direction = "right"; } ]))
|
(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.
|
# 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"; } ]))
|
_args = [
|
||||||
(lua.bind "SUPER + SHIFT + K" (lua.call "hl.dsp.window.move" [ { direction = "up"; } ]))
|
"SUPER + SHIFT + H"
|
||||||
(lua.bind "SUPER + SHIFT + L" (lua.call "hl.dsp.window.move" [ { direction = "right"; } ]))
|
(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.
|
# Resize the active window.
|
||||||
(lua.bind "SUPER + ALT + H" (
|
{
|
||||||
lua.call "hl.dsp.window.resize" [
|
_args = [
|
||||||
{
|
"SUPER + ALT + H"
|
||||||
x = -40;
|
(lib.generators.mkLuaInline "hl.dsp.window.resize(${
|
||||||
y = 0;
|
(lib.generators.toLua { }) {
|
||||||
relative = true;
|
x = -40;
|
||||||
}
|
y = 0;
|
||||||
]
|
relative = true;
|
||||||
))
|
}
|
||||||
(lua.bind "SUPER + ALT + J" (
|
})")
|
||||||
lua.call "hl.dsp.window.resize" [
|
];
|
||||||
{
|
}
|
||||||
x = 0;
|
{
|
||||||
y = 40;
|
_args = [
|
||||||
relative = true;
|
"SUPER + ALT + J"
|
||||||
}
|
(lib.generators.mkLuaInline "hl.dsp.window.resize(${
|
||||||
]
|
(lib.generators.toLua { }) {
|
||||||
))
|
x = 0;
|
||||||
(lua.bind "SUPER + ALT + K" (
|
y = 40;
|
||||||
lua.call "hl.dsp.window.resize" [
|
relative = true;
|
||||||
{
|
}
|
||||||
x = 0;
|
})")
|
||||||
y = -40;
|
];
|
||||||
relative = true;
|
}
|
||||||
}
|
{
|
||||||
]
|
_args = [
|
||||||
))
|
"SUPER + ALT + K"
|
||||||
(lua.bind "SUPER + ALT + L" (
|
(lib.generators.mkLuaInline "hl.dsp.window.resize(${
|
||||||
lua.call "hl.dsp.window.resize" [
|
(lib.generators.toLua { }) {
|
||||||
{
|
x = 0;
|
||||||
x = 40;
|
y = -40;
|
||||||
y = 0;
|
relative = true;
|
||||||
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.
|
# 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}")
|
_args = [
|
||||||
(lua.bind "SUPER + SHIFT + Q" (lua.call "hl.dsp.window.close" [ ]))
|
"SUPER + T"
|
||||||
(lua.bind "SUPER + CTRL + Q" (lua.call "hl.dsp.window.kill" [ ]))
|
(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
|
# Volume and brightness keys repeat while held, each raising a popup
|
||||||
# through the OSD client.
|
# through the OSD client.
|
||||||
# Volume is capped at 100 percent.
|
# Volume is capped at 100 percent.
|
||||||
# The client floors brightness so a full hold cannot black the screen out.
|
# 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"
|
_args = [
|
||||||
{ repeating = true; }
|
"XF86AudioRaiseVolume"
|
||||||
)
|
(lib.generators.mkLuaInline "hl.dsp.exec_cmd(${
|
||||||
(lua.execBindWith "XF86AudioLowerVolume" "${pkgs.swayosd}/bin/swayosd-client --output-volume lower"
|
(lib.generators.toLua { })
|
||||||
{
|
"${pkgs.swayosd}/bin/swayosd-client --output-volume raise --max-volume 100"
|
||||||
repeating = true;
|
})")
|
||||||
}
|
{ repeating = true; }
|
||||||
)
|
];
|
||||||
(lua.execBindWith "XF86MonBrightnessUp" "${pkgs.swayosd}/bin/swayosd-client --brightness raise" {
|
}
|
||||||
repeating = true;
|
{
|
||||||
})
|
_args = [
|
||||||
(lua.execBindWith "XF86MonBrightnessDown" "${pkgs.swayosd}/bin/swayosd-client --brightness lower" {
|
"XF86AudioLowerVolume"
|
||||||
repeating = true;
|
(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.
|
# 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;
|
_args = [
|
||||||
})
|
"XF86AudioMute"
|
||||||
(lua.execBindWith "XF86AudioPlay" "${pkgs.playerctl}/bin/playerctl play-pause" { locked = true; })
|
(lib.generators.mkLuaInline "hl.dsp.exec_cmd(${
|
||||||
(lua.execBindWith "XF86AudioNext" "${pkgs.playerctl}/bin/playerctl next" { locked = true; })
|
(lib.generators.toLua { }) "${pkgs.swayosd}/bin/swayosd-client --output-volume mute-toggle"
|
||||||
(lua.execBindWith "XF86AudioPrev" "${pkgs.playerctl}/bin/playerctl previous" { locked = true; })
|
})")
|
||||||
|
{ 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