feat(hyprland): add directional focus binds
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
config = lib.mkIf config.modules.desktop.session.hyprland.enable {
|
config = lib.mkIf config.modules.desktop.session.hyprland.enable {
|
||||||
registry.keybind.${config.networking.hostName} = lib.listToAttrs (
|
registry.keybind.${config.networking.hostName} = lib.listToAttrs (
|
||||||
map (workspace: {
|
(map (workspace: {
|
||||||
name = "hyprland-workspace-${toString workspace}";
|
name = "hyprland-workspace-${toString workspace}";
|
||||||
value = {
|
value = {
|
||||||
keys = "SUPER + ${toString workspace}";
|
keys = "SUPER + ${toString workspace}";
|
||||||
@@ -18,7 +18,40 @@
|
|||||||
inherit workspace;
|
inherit workspace;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}) (lib.range 1 9)
|
}) (lib.range 1 9))
|
||||||
|
++
|
||||||
|
map
|
||||||
|
(
|
||||||
|
{ direction, key }:
|
||||||
|
{
|
||||||
|
name = "hyprland-focus-${direction}";
|
||||||
|
value = {
|
||||||
|
keys = "SUPER + ${key}";
|
||||||
|
action = {
|
||||||
|
kind = "focus-direction";
|
||||||
|
inherit direction;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
)
|
||||||
|
[
|
||||||
|
{
|
||||||
|
key = "H";
|
||||||
|
direction = "left";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
key = "J";
|
||||||
|
direction = "down";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
key = "K";
|
||||||
|
direction = "up";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
key = "L";
|
||||||
|
direction = "right";
|
||||||
|
}
|
||||||
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
# This program integration owns the session, portals, and polkit, launched
|
# This program integration owns the session, portals, and polkit, launched
|
||||||
@@ -53,6 +86,9 @@
|
|||||||
(lib.generators.mkLuaInline (
|
(lib.generators.mkLuaInline (
|
||||||
{
|
{
|
||||||
exec = "hl.dsp.exec_cmd(${lib.generators.toLua { } keybind.action.command})";
|
exec = "hl.dsp.exec_cmd(${lib.generators.toLua { } keybind.action.command})";
|
||||||
|
"focus-direction" = "hl.dsp.focus(${
|
||||||
|
lib.generators.toLua { } { inherit (keybind.action) direction; }
|
||||||
|
})";
|
||||||
"focus-workspace" = "hl.dsp.focus(${
|
"focus-workspace" = "hl.dsp.focus(${
|
||||||
lib.generators.toLua { } { inherit (keybind.action) workspace; }
|
lib.generators.toLua { } { inherit (keybind.action) workspace; }
|
||||||
})";
|
})";
|
||||||
|
|||||||
@@ -9,39 +9,6 @@ let
|
|||||||
user = config.user.name;
|
user = config.user.name;
|
||||||
|
|
||||||
# The hyprlock this module installs, used by the lock keybind below.
|
# The hyprlock this module installs, used by the lock keybind below.
|
||||||
hyprlock = "${config.home-manager.users.${user}.programs.hyprlock.package}/bin/hyprlock";
|
|
||||||
|
|
||||||
sleepIcon = builtins.fromJSON ''"\udb81\udcb2"'';
|
|
||||||
sleepOffIcon = builtins.fromJSON ''"\udb81\udcb3"'';
|
|
||||||
|
|
||||||
idleLockToggle = pkgs.writeShellScript "lockscreen-idle-inhibit-toggle" ''
|
|
||||||
unit=lockscreen-idle-inhibit.service
|
|
||||||
|
|
||||||
refresh_waybar() {
|
|
||||||
${pkgs.procps}/bin/pkill -RTMIN+9 waybar >/dev/null 2>&1 || true
|
|
||||||
}
|
|
||||||
|
|
||||||
if ${pkgs.systemd}/bin/systemctl --user is-active --quiet "$unit"; then
|
|
||||||
${pkgs.systemd}/bin/systemctl --user stop "$unit"
|
|
||||||
refresh_waybar
|
|
||||||
${pkgs.swayosd}/bin/swayosd-client --custom-message "${sleepIcon}"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ${pkgs.systemd}/bin/systemd-run \
|
|
||||||
--user \
|
|
||||||
--collect \
|
|
||||||
--unit=lockscreen-idle-inhibit \
|
|
||||||
--description="Disable idle-triggered screen locking" \
|
|
||||||
${pkgs.systemd}/bin/systemd-inhibit \
|
|
||||||
--what=idle \
|
|
||||||
--who=lockscreen-hotkey \
|
|
||||||
--why="lock screen disabled by hotkey" \
|
|
||||||
${pkgs.coreutils}/bin/sleep infinity >/dev/null; then
|
|
||||||
refresh_waybar
|
|
||||||
${pkgs.swayosd}/bin/swayosd-client --custom-message "${sleepOffIcon}"
|
|
||||||
fi
|
|
||||||
'';
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.modules.desktop.session.hyprland.hyprlock.enable =
|
options.modules.desktop.session.hyprland.hyprlock.enable =
|
||||||
@@ -86,10 +53,10 @@ in
|
|||||||
# The guard drops the keypress when a locker is already up, so a second
|
# The guard drops the keypress when a locker is already up, so a second
|
||||||
# hyprlock never stacks over the first.
|
# hyprlock never stacks over the first.
|
||||||
/*
|
/*
|
||||||
wayland.windowManager.hyprland.settings.bind = [
|
wayland.windowManager.hyprland.settings.bind = [
|
||||||
"$mod, X, exec, ${pkgs.procps}/bin/pidof hyprlock || ${hyprlock}"
|
"$mod, X, exec, ${pkgs.procps}/bin/pidof hyprlock || ${hyprlock}"
|
||||||
"$mod CTRL, X, exec, ${idleLockToggle}"
|
"$mod CTRL, X, exec, ${idleLockToggle}"
|
||||||
];
|
];
|
||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,8 +7,6 @@
|
|||||||
# mako as the notification daemon: toasts, a do-not-disturb mode, and history recall.
|
# mako as the notification daemon: toasts, a do-not-disturb mode, and history recall.
|
||||||
let
|
let
|
||||||
user = config.user.name;
|
user = config.user.name;
|
||||||
|
|
||||||
makoctl = "${pkgs.mako}/bin/makoctl";
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.modules.desktop.session.mako.enable = lib.mkEnableOption "the mako notification daemon";
|
options.modules.desktop.session.mako.enable = lib.mkEnableOption "the mako notification daemon";
|
||||||
@@ -36,9 +34,9 @@ in
|
|||||||
# of the session.
|
# of the session.
|
||||||
# $mod is defined by the compositor config these binds share.
|
# $mod is defined by the compositor config these binds share.
|
||||||
/*
|
/*
|
||||||
wayland.windowManager.hyprland.settings.bind = [
|
wayland.windowManager.hyprland.settings.bind = [
|
||||||
"$mod, N, exec, ${makoctl} restore"
|
"$mod, N, exec, ${makoctl} restore"
|
||||||
];
|
];
|
||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,17 +10,6 @@ let
|
|||||||
|
|
||||||
# A session menu built on the same themed rofi, so the power actions look
|
# A session menu built on the same themed rofi, so the power actions look
|
||||||
# like every other menu the launcher drives.
|
# like every other menu the launcher drives.
|
||||||
powerMenu = pkgs.writeShellScript "rofi-power-menu" ''
|
|
||||||
chosen=$(printf '%s\n' Lock Suspend 'Log out' Reboot 'Shut down' \
|
|
||||||
| ${pkgs.rofi}/bin/rofi -dmenu -i -p Power)
|
|
||||||
case "$chosen" in
|
|
||||||
Lock) ${pkgs.systemd}/bin/loginctl lock-session ;;
|
|
||||||
Suspend) ${pkgs.systemd}/bin/systemctl suspend ;;
|
|
||||||
'Log out') ${pkgs.systemd}/bin/loginctl terminate-session "$XDG_SESSION_ID" ;;
|
|
||||||
Reboot) ${pkgs.systemd}/bin/systemctl reboot ;;
|
|
||||||
'Shut down') ${pkgs.systemd}/bin/systemctl poweroff ;;
|
|
||||||
esac
|
|
||||||
'';
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.modules.desktop.session.rofi.enable = lib.mkEnableOption "the rofi launcher";
|
options.modules.desktop.session.rofi.enable = lib.mkEnableOption "the rofi launcher";
|
||||||
@@ -43,10 +32,10 @@ in
|
|||||||
# The launcher and the session menu, kept next to the tool they drive.
|
# The launcher and the session menu, kept next to the tool they drive.
|
||||||
# $mod is defined by the compositor config these binds share.
|
# $mod is defined by the compositor config these binds share.
|
||||||
/*
|
/*
|
||||||
wayland.windowManager.hyprland.settings.bind = [
|
wayland.windowManager.hyprland.settings.bind = [
|
||||||
"$mod, R, exec, ${pkgs.rofi}/bin/rofi -show drun"
|
"$mod, R, exec, ${pkgs.rofi}/bin/rofi -show drun"
|
||||||
"$mod SHIFT, X, exec, ${powerMenu}"
|
"$mod SHIFT, X, exec, ${powerMenu}"
|
||||||
];
|
];
|
||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,20 +8,10 @@
|
|||||||
let
|
let
|
||||||
user = config.user.name;
|
user = config.user.name;
|
||||||
|
|
||||||
cliphist = "${pkgs.cliphist}/bin/cliphist";
|
|
||||||
rofi = "${pkgs.rofi}/bin/rofi";
|
|
||||||
wl-copy = "${pkgs.wl-clipboard}/bin/wl-copy";
|
|
||||||
|
|
||||||
# The picker reuses the themed rofi, so history looks like every other menu
|
# The picker reuses the themed rofi, so history looks like every other menu
|
||||||
# the launcher drives.
|
# the launcher drives.
|
||||||
# decode is needed because list emits id-prefixed lines rather than the copied
|
# decode is needed because list emits id-prefixed lines rather than the copied
|
||||||
# bytes, so the chosen id has to be resolved back before it can be re-copied.
|
# bytes, so the chosen id has to be resolved back before it can be re-copied.
|
||||||
picker = pkgs.writeShellScript "clipboard-picker" ''
|
|
||||||
${cliphist} list \
|
|
||||||
| ${rofi} -dmenu -i -p Clipboard \
|
|
||||||
| ${cliphist} decode \
|
|
||||||
| ${wl-copy}
|
|
||||||
'';
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.modules.desktop.utilities.clipboard.enable =
|
options.modules.desktop.utilities.clipboard.enable =
|
||||||
@@ -41,9 +31,9 @@ in
|
|||||||
|
|
||||||
# $mod is defined by the compositor config these binds share.
|
# $mod is defined by the compositor config these binds share.
|
||||||
/*
|
/*
|
||||||
wayland.windowManager.hyprland.settings.bind = [
|
wayland.windowManager.hyprland.settings.bind = [
|
||||||
"$mod SHIFT, V, exec, ${picker}"
|
"$mod SHIFT, V, exec, ${picker}"
|
||||||
];
|
];
|
||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,36 +8,12 @@
|
|||||||
let
|
let
|
||||||
user = config.user.name;
|
user = config.user.name;
|
||||||
|
|
||||||
slurp = "${pkgs.slurp}/bin/slurp";
|
|
||||||
wf-recorder = "${pkgs.wf-recorder}/bin/wf-recorder";
|
|
||||||
notify-send = "${pkgs.libnotify}/bin/notify-send";
|
|
||||||
pgrep = "${pkgs.procps}/bin/pgrep";
|
|
||||||
pkill = "${pkgs.procps}/bin/pkill";
|
|
||||||
date = "${pkgs.coreutils}/bin/date";
|
|
||||||
mkdir = "${pkgs.coreutils}/bin/mkdir";
|
|
||||||
xdgUserDir = "${pkgs.xdg-user-dirs}/bin/xdg-user-dir";
|
|
||||||
|
|
||||||
# A single key both starts and stops.
|
# A single key both starts and stops.
|
||||||
# A running wf-recorder is stopped with SIGINT so it finalises the file.
|
# A running wf-recorder is stopped with SIGINT so it finalises the file.
|
||||||
# Otherwise slurp picks a region and wf-recorder runs in the foreground until
|
# Otherwise slurp picks a region and wf-recorder runs in the foreground until
|
||||||
# that stop arrives, so this instance lives for the whole recording and then
|
# that stop arrives, so this instance lives for the whole recording and then
|
||||||
# reports it saved.
|
# reports it saved.
|
||||||
# No -a means no audio is captured.
|
# No -a means no audio is captured.
|
||||||
toggle = pkgs.writeShellScript "screen-record-toggle" ''
|
|
||||||
if ${pgrep} -x wf-recorder >/dev/null; then
|
|
||||||
${pkill} -INT -x wf-recorder
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
region=$(${slurp}) || exit 0
|
|
||||||
dir="$(${xdgUserDir} VIDEOS)/Recordings"
|
|
||||||
${mkdir} -p "$dir"
|
|
||||||
file="$dir/recording-$(${date} +%Y%m%d-%H%M%S).mp4"
|
|
||||||
|
|
||||||
${notify-send} -a "Screen recording" "Recording started" "Region capture, no audio."
|
|
||||||
${wf-recorder} -g "$region" -f "$file"
|
|
||||||
${notify-send} -a "Screen recording" "Recording saved" "$file"
|
|
||||||
'';
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.modules.desktop.utilities.recording.enable =
|
options.modules.desktop.utilities.recording.enable =
|
||||||
@@ -47,9 +23,9 @@ in
|
|||||||
home-manager.users.${user} = {
|
home-manager.users.${user} = {
|
||||||
# $mod is defined by the compositor config these binds share.
|
# $mod is defined by the compositor config these binds share.
|
||||||
/*
|
/*
|
||||||
wayland.windowManager.hyprland.settings.bind = [
|
wayland.windowManager.hyprland.settings.bind = [
|
||||||
"$mod SHIFT, R, exec, ${toggle}"
|
"$mod SHIFT, R, exec, ${toggle}"
|
||||||
];
|
];
|
||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,28 +9,8 @@
|
|||||||
let
|
let
|
||||||
user = config.user.name;
|
user = config.user.name;
|
||||||
|
|
||||||
grimblast = "${pkgs.grimblast}/bin/grimblast";
|
|
||||||
satty = "${pkgs.satty}/bin/satty";
|
|
||||||
tee = "${pkgs.coreutils}/bin/tee";
|
|
||||||
wl-copy = "${pkgs.wl-clipboard}/bin/wl-copy";
|
|
||||||
xdgUserDir = "${pkgs.xdg-user-dirs}/bin/xdg-user-dir";
|
|
||||||
|
|
||||||
# Copy the original screenshot before Satty opens.
|
# Copy the original screenshot before Satty opens.
|
||||||
# Satty copies and saves annotated screenshots when the user presses Enter.
|
# Satty copies and saves annotated screenshots when the user presses Enter.
|
||||||
capture =
|
|
||||||
target:
|
|
||||||
pkgs.writeShellScript "screenshot-${target}" ''
|
|
||||||
dir="$(${xdgUserDir} PICTURES)/Screenshots"
|
|
||||||
mkdir -p "$dir"
|
|
||||||
${grimblast} save ${target} - \
|
|
||||||
| ${tee} >(${wl-copy}) \
|
|
||||||
| ${satty} --filename - \
|
|
||||||
--output-filename "$dir/screenshot-%Y%m%d-%H%M%S.png" \
|
|
||||||
--copy-command ${wl-copy} \
|
|
||||||
--save-after-copy \
|
|
||||||
--early-exit \
|
|
||||||
--actions-on-enter save-to-clipboard
|
|
||||||
'';
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.modules.desktop.utilities.screenshot.enable =
|
options.modules.desktop.utilities.screenshot.enable =
|
||||||
@@ -43,20 +23,20 @@ in
|
|||||||
# windowrule v3 syntax: space-separated field/value tokens, comma
|
# windowrule v3 syntax: space-separated field/value tokens, comma
|
||||||
# separated, with matchers under a match: prefix and effects bare.
|
# separated, with matchers under a match: prefix and effects bare.
|
||||||
/*
|
/*
|
||||||
wayland.windowManager.hyprland.settings.windowrule = [
|
wayland.windowManager.hyprland.settings.windowrule = [
|
||||||
"float 1, match:class ^(com\\.gabm\\.satty)$"
|
"float 1, match:class ^(com\\.gabm\\.satty)$"
|
||||||
];
|
];
|
||||||
*/
|
*/
|
||||||
|
|
||||||
# Print with plain/Shift/Ctrl for region/window/full.
|
# Print with plain/Shift/Ctrl for region/window/full.
|
||||||
# Super+L is already the hjkl focus and movement bind, so screenshots take
|
# Super+L is already the hjkl focus and movement bind, so screenshots take
|
||||||
# the Print key instead.
|
# the Print key instead.
|
||||||
/*
|
/*
|
||||||
wayland.windowManager.hyprland.settings.bind = [
|
wayland.windowManager.hyprland.settings.bind = [
|
||||||
", Print, exec, ${capture "area"}"
|
", Print, exec, ${capture "area"}"
|
||||||
"SHIFT, Print, exec, ${capture "active"}"
|
"SHIFT, Print, exec, ${capture "active"}"
|
||||||
"CTRL, Print, exec, ${capture "screen"}"
|
"CTRL, Print, exec, ${capture "screen"}"
|
||||||
];
|
];
|
||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
lib.all (
|
lib.all (
|
||||||
entry:
|
entry:
|
||||||
(entry.value.action.kind == "exec" && entry.value.action.command != null)
|
(entry.value.action.kind == "exec" && entry.value.action.command != null)
|
||||||
|
|| (entry.value.action.kind == "focus-direction" && entry.value.action.direction != null)
|
||||||
|| (entry.value.action.kind == "focus-workspace" && entry.value.action.workspace != null)
|
|| (entry.value.action.kind == "focus-workspace" && entry.value.action.workspace != null)
|
||||||
) entries;
|
) entries;
|
||||||
message = "Desktop keybind actions must set the fields their kind requires.";
|
message = "Desktop keybind actions must set the fields their kind requires.";
|
||||||
@@ -33,6 +34,7 @@
|
|||||||
description = "Selects the keybind action kind.";
|
description = "Selects the keybind action kind.";
|
||||||
type = lib.types.enum [
|
type = lib.types.enum [
|
||||||
"exec"
|
"exec"
|
||||||
|
"focus-direction"
|
||||||
"focus-workspace"
|
"focus-workspace"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
@@ -44,6 +46,20 @@
|
|||||||
example = "ghostty";
|
example = "ghostty";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
direction = lib.mkOption {
|
||||||
|
description = "Direction focused by a focus-direction keybind.";
|
||||||
|
type = lib.types.nullOr (
|
||||||
|
lib.types.enum [
|
||||||
|
"down"
|
||||||
|
"left"
|
||||||
|
"right"
|
||||||
|
"up"
|
||||||
|
]
|
||||||
|
);
|
||||||
|
default = null;
|
||||||
|
example = "left";
|
||||||
|
};
|
||||||
|
|
||||||
workspace = lib.mkOption {
|
workspace = lib.mkOption {
|
||||||
description = "Workspace focused by a focus-workspace keybind.";
|
description = "Workspace focused by a focus-workspace keybind.";
|
||||||
type = lib.types.nullOr lib.types.int;
|
type = lib.types.nullOr lib.types.int;
|
||||||
|
|||||||
Reference in New Issue
Block a user