mirror of
https://github.com/kmein/niveum
synced 2026-03-23 05:11:08 +01:00
niri: configure for me
This commit is contained in:
56
packages/klem/default.nix
Normal file
56
packages/klem/default.nix
Normal file
@@ -0,0 +1,56 @@
|
||||
# klem < klemm < klemmbrett ~ clipboard
|
||||
{
|
||||
lib,
|
||||
dmenu,
|
||||
curl,
|
||||
gnused,
|
||||
coreutils,
|
||||
wl-clipboard,
|
||||
libnotify,
|
||||
writers,
|
||||
options ? { },
|
||||
...
|
||||
}:
|
||||
let
|
||||
eval = lib.evalModules {
|
||||
modules = [
|
||||
{
|
||||
imports = [ options ];
|
||||
options = {
|
||||
dmenu = lib.mkOption {
|
||||
default = "${dmenu}/bin/dmenu -i -p klem";
|
||||
type = lib.types.path;
|
||||
};
|
||||
scripts = lib.mkOption {
|
||||
default = {
|
||||
pastebin = "${curl}/bin/curl -fSs -F 'f:1=<-' ix.io";
|
||||
shorten = ''
|
||||
${curl}/bin/curl -fSs -F "shorten=$(${coreutils}/bin/cat)" https://0x0.st
|
||||
'';
|
||||
"replace p.r" = "${gnused}/bin/sed 's/\\<r\\>/krebsco.de/'";
|
||||
};
|
||||
type = lib.types.attrs;
|
||||
};
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
cfg = eval.config;
|
||||
in
|
||||
writers.writeDashBin "klem" ''
|
||||
set -efu
|
||||
|
||||
${wl-clipboard}/bin/wl-paste \
|
||||
| case $(echo "${lib.concatStringsSep "\n" (lib.attrNames cfg.scripts)}" | ${cfg.dmenu}) in
|
||||
${lib.concatStringsSep "\n" (
|
||||
lib.mapAttrsToList (option: script: ''
|
||||
'${option}') ${toString script} ;;
|
||||
'') cfg.scripts
|
||||
)}
|
||||
*) ${coreutils}/bin/cat ;;
|
||||
esac \
|
||||
| ${wl-clipboard}/bin/wl-copy
|
||||
|
||||
${libnotify}/bin/notify-send --app-name="klem" "Result copied to clipboard."
|
||||
''
|
||||
Reference in New Issue
Block a user