refactor default apps and add walker
This commit is contained in:
@@ -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 = [
|
||||
|
||||
Reference in New Issue
Block a user