refactor: ponytail audit

This commit is contained in:
kiri committed 2026-09-06 04:03:54 +02:00
1 parent de8b59ec16
commit f080ebe36e
57 files changed
+566 -2137

No files matched your search

+26 -58
View File
@@ -1,9 +1,19 @@
{
browser,
launcher,
shortcutCommands,
swapMonitorWorkspaces,
terminal,
}:
let
spawnLocked = command: {
spawn-sh = command;
_props.allow-when-locked = true;
};
withCooldown = action: {
${action} = { };
_props.cooldown-ms = 150;
};
in
{
# Application and utility launchers
"Mod+Return" = {
@@ -25,46 +35,16 @@
};
# Hardware media, volume, and brightness keys
"XF86AudioPlay" = {
spawn-sh = "playerctl play-pause";
_props.allow-when-locked = true;
};
"XF86AudioStop" = {
spawn-sh = "playerctl stop";
_props.allow-when-locked = true;
};
"XF86AudioPrev" = {
spawn-sh = "playerctl previous";
_props.allow-when-locked = true;
};
"XF86AudioNext" = {
spawn-sh = "playerctl next";
_props.allow-when-locked = true;
};
"XF86AudioRaiseVolume" = {
spawn-sh = "wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+";
_props.allow-when-locked = true;
};
"XF86AudioLowerVolume" = {
spawn-sh = "wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-";
_props.allow-when-locked = true;
};
"XF86AudioMute" = {
spawn-sh = "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle";
_props.allow-when-locked = true;
};
"XF86AudioMicMute" = {
spawn-sh = "wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle";
_props.allow-when-locked = true;
};
"XF86MonBrightnessUp" = {
spawn-sh = "brightnessctl s 5%+";
_props.allow-when-locked = true;
};
"XF86MonBrightnessDown" = {
spawn-sh = "brightnessctl s 5%-";
_props.allow-when-locked = true;
};
"XF86AudioPlay" = spawnLocked "playerctl play-pause";
"XF86AudioStop" = spawnLocked "playerctl stop";
"XF86AudioPrev" = spawnLocked "playerctl previous";
"XF86AudioNext" = spawnLocked "playerctl next";
"XF86AudioRaiseVolume" = spawnLocked "wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+";
"XF86AudioLowerVolume" = spawnLocked "wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-";
"XF86AudioMute" = spawnLocked "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle";
"XF86AudioMicMute" = spawnLocked "wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle";
"XF86MonBrightnessUp" = spawnLocked "brightnessctl s 5%+";
"XF86MonBrightnessDown" = spawnLocked "brightnessctl s 5%-";
# Screenshots
"Mod+S".screenshot = { };
@@ -105,7 +85,7 @@
"Mod+Tab".focus-monitor-next = { };
"Mod+A" = {
_props.repeat = false;
spawn = shortcutCommands.swapMonitorWorkspaces;
spawn = swapMonitorWorkspaces;
_props.hotkey-overlay-title = "Swap Monitor Workspaces";
};
"Mod+Alt+Tab".move-column-to-monitor-next = { };
@@ -124,22 +104,10 @@
"Mod+Shift+I".move-workspace-up = { };
# Mouse workspace navigation
"Mod+WheelScrollDown" = {
focus-workspace-down = { };
_props.cooldown-ms = 150;
};
"Mod+WheelScrollUp" = {
focus-workspace-up = { };
_props.cooldown-ms = 150;
};
"Mod+Alt+WheelScrollDown" = {
move-column-to-workspace-down = { };
_props.cooldown-ms = 150;
};
"Mod+Alt+WheelScrollUp" = {
move-column-to-workspace-up = { };
_props.cooldown-ms = 150;
};
"Mod+WheelScrollDown" = withCooldown "focus-workspace-down";
"Mod+WheelScrollUp" = withCooldown "focus-workspace-up";
"Mod+Alt+WheelScrollDown" = withCooldown "move-column-to-workspace-down";
"Mod+Alt+WheelScrollUp" = withCooldown "move-column-to-workspace-up";
# Mouse column navigation and movement
"Mod+WheelScrollRight".focus-column-or-monitor-right = { };
+32 -41
View File
@@ -1,46 +1,37 @@
{
lib,
pkgs,
}:
rec {
scripts = {
swapMonitorWorkspaces = pkgs.writeShellApplication {
name = "niri-shortcut-swap-monitor-workspaces";
runtimeInputs = [
pkgs.jq
pkgs.niri
];
text = ''
focused_output="$(niri msg --json focused-output | jq -r '.name // empty')"
if [ -z "$focused_output" ]; then
exit 0
fi
{ pkgs }:
pkgs.writeShellApplication {
name = "niri-shortcut-swap-monitor-workspaces";
runtimeInputs = [
pkgs.jq
pkgs.niri
];
text = ''
focused_output="$(niri msg --json focused-output | jq -r '.name // empty')"
if [ -z "$focused_output" ]; then
exit 0
fi
niri msg action focus-monitor-next
niri msg action focus-monitor-next
target_output="$(niri msg --json focused-output | jq -r '.name // empty')"
if [ -z "$target_output" ] || [ "$target_output" = "$focused_output" ]; then
exit 0
fi
target_output="$(niri msg --json focused-output | jq -r '.name // empty')"
if [ -z "$target_output" ] || [ "$target_output" = "$focused_output" ]; then
exit 0
fi
target_workspace_idx="$(
niri msg --json workspaces \
| jq -r --arg output "$target_output" '
first(.[] | select(.output == $output and .is_active) | .idx) // empty
'
)"
if [ -z "$target_workspace_idx" ]; then
niri msg action focus-monitor "$focused_output"
exit 0
fi
target_workspace_idx="$(
niri msg --json workspaces \
| jq -r --arg output "$target_output" '
first(.[] | select(.output == $output and .is_active) | .idx) // empty
'
)"
if [ -z "$target_workspace_idx" ]; then
niri msg action focus-monitor "$focused_output"
exit 0
fi
niri msg action focus-monitor "$focused_output"
niri msg action move-workspace-to-monitor "$target_output"
niri msg action focus-workspace "$target_workspace_idx"
niri msg action move-workspace-to-monitor "$focused_output"
'';
};
};
commands = lib.mapAttrs (_: lib.getExe) scripts;
niri msg action focus-monitor "$focused_output"
niri msg action move-workspace-to-monitor "$target_output"
niri msg action focus-workspace "$target_workspace_idx"
niri msg action move-workspace-to-monitor "$focused_output"
'';
}
+3 -8
View File
@@ -29,12 +29,7 @@ in
}:
let
palette = kanagawa.palette;
shortcuts = import ./_shortcuts.nix {
inherit
lib
pkgs
;
};
swapMonitorWorkspaces = import ./_shortcuts.nix { inherit pkgs; };
machine = config.facts.machine;
in
{
@@ -47,7 +42,7 @@ in
brightnessctl
wireplumber
]
++ lib.attrValues shortcuts.scripts;
++ [ swapMonitorWorkspaces ];
};
dconf.settings."org/gnome/desktop/interface".color-scheme = "prefer-dark";
@@ -140,7 +135,7 @@ in
launcher
terminal
;
shortcutCommands = shortcuts.commands;
swapMonitorWorkspaces = lib.getExe swapMonitorWorkspaces;
};
};
};