1
0
mirror of https://github.com/kmein/niveum synced 2026-03-22 21:01:07 +01:00

niri: configure for me

This commit is contained in:
2026-03-21 20:14:28 +01:00
parent 1e14296522
commit 99440cbd04
3 changed files with 64 additions and 1 deletions

56
packages/klem/default.nix Normal file
View 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."
''

51
packages/klem/kmein.nix Normal file
View File

@@ -0,0 +1,51 @@
{ pkgs, ... }:
let
inherit (pkgs) lib;
in
{
dmenu = "${lib.getExe pkgs.dmenu} -i -p klem";
scripts = {
"p.r paste" = pkgs.writers.writeDash "p.r" ''
${lib.getExe pkgs.curl} -fSs http://p.r --data-binary @- \
| ${lib.getExe' pkgs.coreutils "tail"} --lines=1 \
| ${lib.getExe pkgs.gnused} 's/\\<r\\>/krebsco.de/'
'';
"envs.sh paste" = pkgs.writers.writeDash "envs-host" ''
${lib.getExe pkgs.curl} -F "file=@-" https://envs.sh
'';
# this segfaults
# "envs.sh mirror" = pkgs.writers.writeDash "envs-mirror" ''
# ${pkgs.curl}/bin/curl -F "url=$(${pkgs.coreutils}/bin/cat)" https://envs.sh
# '';
"envs.sh shorten" = pkgs.writers.writeDash "envs-shorten" ''
${lib.getExe pkgs.curl} -F "shorten=$(${lib.getExe' pkgs.coreutils "cat"})" https://envs.sh
'';
"go.r shorten" = pkgs.writers.writeDash "go.r" ''
${lib.getExe pkgs.curl} -fSs http://go.r -F "uri=$(${lib.getExe' pkgs.coreutils "cat"})"
'';
"4d2.org paste" = pkgs.writers.writeDash "4d2-paste" ''
${lib.getExe pkgs.curl} -F "file=@-" https://depot.4d2.org/
'';
"0x0.st shorten" = pkgs.writers.writeDash "0x0.st" ''
${lib.getExe pkgs.curl} -fSs https://0x0.st -F "shorten=$(${lib.getExe' pkgs.coreutils "cat"})"
'';
"rot13" = pkgs.writers.writeDash "rot13" ''
${lib.getExe' pkgs.coreutils "tr"} '[A-Za-z]' '[N-ZA-Mn-za-m]'
'';
"ipa" = pkgs.writers.writeDash "ipa" ''
${lib.getExe pkgs.ipa}
'';
"betacode" = pkgs.writers.writeDash "betacode" ''
${lib.getExe pkgs.betacode}
'';
"curl" = pkgs.writers.writeDash "curl" ''
${lib.getExe pkgs.curl} -fSs "$(${lib.getExe' pkgs.coreutils "cat"})"
'';
ocr = pkgs.writers.writeDash "ocr" ''
${lib.getExe pkgs.tesseract4} -l eng+deu - stdout
'';
emojai = pkgs.writers.writeDash "emojai" ''
${lib.getExe pkgs.curl} https://www.emojai.app/api/generate -X POST -H 'Content-Type: application/json' --data-raw "$(${lib.getExe pkgs.jq} -sR '{emoji:.}')" | ${lib.getExe pkgs.jq} -r .result
'';
};
}