1
0
mirror of https://github.com/kmein/niveum synced 2026-03-16 18:21:07 +01:00
Files
niveum/packages/klem.nix

57 lines
1.3 KiB
Nix
Raw Normal View History

2020-06-09 21:31:58 +02:00
# klem < klemm < klemmbrett ~ clipboard
2022-03-10 21:52:12 +01:00
{
lib,
dmenu,
curl,
gnused,
coreutils,
2026-01-06 22:46:12 +01:00
wl-clipboard,
libnotify,
writers,
options ? { },
2022-03-10 21:52:12 +01:00
...
2025-12-27 22:22:54 +01:00
}:
let
2020-06-09 21:31:58 +02:00
eval = lib.evalModules {
2022-03-10 21:52:12 +01:00
modules = [
{
2025-12-27 22:22:54 +01:00
imports = [ options ];
2022-03-10 21:52:12 +01:00
options = {
dmenu = lib.mkOption {
default = "${dmenu}/bin/dmenu -i -p klem";
2022-03-10 21:52:12 +01:00
type = lib.types.path;
};
scripts = lib.mkOption {
default = {
pastebin = "${curl}/bin/curl -fSs -F 'f:1=<-' ix.io";
2022-03-10 21:52:12 +01:00
shorten = ''
${curl}/bin/curl -fSs -F "shorten=$(${coreutils}/bin/cat)" https://0x0.st
2022-03-10 21:52:12 +01:00
'';
"replace p.r" = "${gnused}/bin/sed 's/\\<r\\>/krebsco.de/'";
2022-03-10 21:52:12 +01:00
};
type = lib.types.attrs;
2020-06-09 21:31:58 +02:00
};
};
2022-03-10 21:52:12 +01:00
}
];
2020-06-09 21:31:58 +02:00
};
cfg = eval.config;
2022-03-10 21:52:12 +01:00
in
2025-12-27 22:22:54 +01:00
writers.writeDashBin "klem" ''
set -efu
2023-03-20 12:23:36 +01:00
2026-01-06 22:46:12 +01:00
${wl-clipboard}/bin/wl-paste \
2025-12-27 22:22:54 +01:00
| case $(echo "${lib.concatStringsSep "\n" (lib.attrNames cfg.scripts)}" | ${cfg.dmenu}) in
${lib.concatStringsSep "\n" (
lib.mapAttrsToList (option: script: ''
'${option}') ${toString script} ;;
2025-12-27 22:22:54 +01:00
'') cfg.scripts
)}
*) ${coreutils}/bin/cat ;;
esac \
2026-01-06 22:46:12 +01:00
| ${wl-clipboard}/bin/wl-copy
2023-03-20 12:23:36 +01:00
2025-12-27 22:22:54 +01:00
${libnotify}/bin/notify-send --app-name="klem" "Result copied to clipboard."
''