refactor default apps and add walker
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
browserCommand,
|
||||
launcherCommands,
|
||||
launcherCommand,
|
||||
shortcutCommands,
|
||||
terminalCommand,
|
||||
}:
|
||||
@@ -16,7 +16,7 @@
|
||||
};
|
||||
"Mod+Space" = {
|
||||
repeat = false;
|
||||
action.spawn = launcherCommands.open;
|
||||
action.spawn = launcherCommand;
|
||||
hotkey-overlay.title = "App Launcher";
|
||||
};
|
||||
"Mod+E" = {
|
||||
@@ -39,16 +39,6 @@
|
||||
action.spawn = shortcutCommands.editSecrets;
|
||||
hotkey-overlay.title = "Edit Secrets";
|
||||
};
|
||||
"Mod+Ctrl+F" = {
|
||||
repeat = false;
|
||||
action.spawn = launcherCommands.files;
|
||||
hotkey-overlay.title = "Find Files";
|
||||
};
|
||||
"Mod+V" = {
|
||||
repeat = false;
|
||||
action.spawn = shortcutCommands.clipboardHistory;
|
||||
hotkey-overlay.title = "Clipboard History";
|
||||
};
|
||||
"Mod+Ctrl+C" = {
|
||||
repeat = false;
|
||||
action.spawn = shortcutCommands.pickColor;
|
||||
|
||||
@@ -6,72 +6,40 @@
|
||||
}:
|
||||
let
|
||||
nixosConfigDir = repo.account.nixosConfigurationPath;
|
||||
launcherDmenuCommand =
|
||||
lib.concatMapStringsSep " " lib.escapeShellArg
|
||||
config.meta.desktop.launcher.commands.dmenu;
|
||||
mkTerminalScript =
|
||||
{
|
||||
name,
|
||||
title,
|
||||
appId ? "niri-shortcut-terminal",
|
||||
workdir ? nixosConfigDir,
|
||||
command ? null,
|
||||
runtimeInputs ? [ ],
|
||||
}:
|
||||
let
|
||||
args =
|
||||
(
|
||||
if config.meta.desktop.terminal.desktopEntryName == "kitty" then
|
||||
[
|
||||
"--class"
|
||||
appId
|
||||
"--title"
|
||||
title
|
||||
"--directory"
|
||||
workdir
|
||||
]
|
||||
else if config.meta.desktop.terminal.desktopEntryName == "foot" then
|
||||
[
|
||||
"--app-id"
|
||||
appId
|
||||
"--title"
|
||||
title
|
||||
"--working-directory"
|
||||
workdir
|
||||
]
|
||||
else
|
||||
[ ]
|
||||
)
|
||||
++ lib.optionals (command != null) [
|
||||
"--"
|
||||
"${pkgs.bash}/bin/bash"
|
||||
"-lc"
|
||||
command
|
||||
];
|
||||
args = lib.optionals (command != null) [
|
||||
"--"
|
||||
"${pkgs.bash}/bin/bash"
|
||||
"-lc"
|
||||
command
|
||||
];
|
||||
argString = lib.concatMapStringsSep " " lib.escapeShellArg args;
|
||||
in
|
||||
pkgs.writeShellApplication {
|
||||
inherit name runtimeInputs;
|
||||
checkPhase = "";
|
||||
text = ''
|
||||
# shellcheck disable=SC2016
|
||||
cd ${lib.escapeShellArg workdir}
|
||||
exec ${lib.escapeShellArg config.meta.desktop.terminal.command} ${
|
||||
lib.concatMapStringsSep " " lib.escapeShellArg args
|
||||
}
|
||||
'';
|
||||
text = lib.concatStringsSep "\n" [
|
||||
"# shellcheck disable=SC2016"
|
||||
"cd ${lib.escapeShellArg workdir}"
|
||||
"exec ${lib.escapeShellArg config.meta.desktop.terminalCommand} ${argString}"
|
||||
];
|
||||
};
|
||||
in
|
||||
rec {
|
||||
scripts = {
|
||||
nixosTerminal = mkTerminalScript {
|
||||
name = "niri-shortcut-nixos-terminal";
|
||||
title = "NixOS Config";
|
||||
};
|
||||
|
||||
nixosSwitch = mkTerminalScript {
|
||||
name = "niri-shortcut-nixos-switch";
|
||||
title = "NixOS Switch";
|
||||
appId = "niri-shortcut-float";
|
||||
runtimeInputs = [
|
||||
pkgs.coreutils
|
||||
pkgs.nh
|
||||
@@ -109,8 +77,6 @@ rec {
|
||||
|
||||
editSecrets = mkTerminalScript {
|
||||
name = "niri-shortcut-edit-secrets";
|
||||
title = "Edit Secrets";
|
||||
appId = "niri-shortcut-float";
|
||||
runtimeInputs = [ pkgs.sops ];
|
||||
command = ''
|
||||
sops edit ${lib.escapeShellArg "${nixosConfigDir}/modules/secrets/secrets.yaml"}
|
||||
@@ -119,29 +85,11 @@ rec {
|
||||
|
||||
neovimProjects = mkTerminalScript {
|
||||
name = "niri-shortcut-neovim-projects";
|
||||
title = "Neovim Projects";
|
||||
command = ''
|
||||
nvim -c 'Telescope projects'
|
||||
'';
|
||||
};
|
||||
|
||||
clipboardHistory = pkgs.writeShellApplication {
|
||||
name = "niri-shortcut-clipboard-history";
|
||||
runtimeInputs = [
|
||||
pkgs.cliphist
|
||||
config.meta.desktop.launcher.package
|
||||
pkgs.wl-clipboard
|
||||
];
|
||||
text = ''
|
||||
selection="$(cliphist list | ${launcherDmenuCommand})"
|
||||
if [ -z "$selection" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
printf '%s' "$selection" | cliphist decode | wl-copy
|
||||
'';
|
||||
};
|
||||
|
||||
pickColor = pkgs.writeShellApplication {
|
||||
name = "niri-shortcut-pick-color";
|
||||
runtimeInputs = [
|
||||
|
||||
@@ -59,9 +59,6 @@ in
|
||||
brightnessctl
|
||||
xwayland-satellite
|
||||
]
|
||||
++ [
|
||||
config.meta.desktop.fileManager.package
|
||||
]
|
||||
++ lib.attrValues shortcuts.scripts;
|
||||
};
|
||||
|
||||
@@ -139,13 +136,6 @@ in
|
||||
};
|
||||
clip-to-geometry = true;
|
||||
}
|
||||
{
|
||||
matches = [
|
||||
{ app-id = "^niri-shortcut-float$"; }
|
||||
];
|
||||
open-floating = true;
|
||||
open-focused = true;
|
||||
}
|
||||
];
|
||||
|
||||
debug.honor-xdg-activation-with-invalid-serial = true;
|
||||
@@ -163,9 +153,9 @@ in
|
||||
};
|
||||
|
||||
binds = import ./_bindings.nix {
|
||||
browserCommand = config.meta.desktop.browser.command;
|
||||
launcherCommands = config.meta.desktop.launcher.commands;
|
||||
terminalCommand = config.meta.desktop.terminal.command;
|
||||
browserCommand = config.meta.desktop.browserCommand;
|
||||
launcherCommand = config.meta.desktop.launcherCommand;
|
||||
terminalCommand = config.meta.desktop.terminalCommand;
|
||||
shortcutCommands = shortcuts.commands;
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user