This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

1{ 2 self, 3 config, 4 lib, 5 pkgs, 6 ... 7}: 8with lib; 9let 10 cfg = config.lass.klem; 11 slib = self.inputs.stockholm.lib; 12in 13{ 14 options.lass.klem = mkOption { 15 default = { }; 16 type = types.attrsOf ( 17 types.submodule ( 18 { config, ... }: 19 { 20 options = { 21 target = mkOption { 22 default = ".*"; 23 description = '' 24 regex of valid targets 25 can be shown with xclip -selection clipboard -t TARGETS 26 the first hit is taken as target argument 27 ''; 28 type = types.str; 29 }; 30 script = mkOption { 31 description = '' 32 file to run if entry is selected 33 ''; 34 type = types.path; 35 }; 36 label = mkOption { 37 default = config._module.args.name; 38 description = '' 39 label to show in dmenu for this script 40 ''; 41 type = types.str; 42 }; 43 }; 44 } 45 ) 46 ); 47 }; 48 config = 49 let 50 klem = pkgs.writers.writeDashBin "klem" '' 51 set -x 52 53 labels="" 54 # match filetype against patterns 55 ${concatMapStringsSep "\n" (script: '' 56 ${pkgs.xclip}/bin/xclip -selection clipboard -target TARGETS -out \ 57 | ${pkgs.gnugrep}/bin/grep -q '${script.target}' 58 if [ $? -eq 0 ]; then 59 labels="$labels:${script.label}" 60 fi 61 '') (attrValues cfg)} 62 63 #remove empty line, feed into dmenu 64 script=$(echo "$labels" \ 65 | ${pkgs.gnused}/bin/sed 's/^://;s/:/\n/g' \ 66 | ${pkgs.dmenu}/bin/dmenu) 67 68 #run the chosen script 69 case $script in 70 ${ 71 concatMapStringsSep "\n" ( 72 script: 73 slib.indent '' 74 ${script.label}) 75 target=$(${pkgs.xclip}/bin/xclip -selection clipboard -target TARGETS -out \ 76 | ${pkgs.gnugrep}/bin/grep '${script.target}' \ 77 | ${pkgs.gnugrep}/bin/grep -v TARGETS \ 78 | ${pkgs.coreutils}/bin/head -1) 79 ${pkgs.xclip}/bin/xclip -selection clipboard -target "$target" -out \ 80 | ${script.script} \ 81 | ${pkgs.xclip}/bin/xclip -selection clipboard -in 82 ;; 83 '' 84 ) (attrValues cfg) 85 } 86 esac 87 ''; 88 in 89 mkIf (cfg != { }) { 90 environment.systemPackages = [ klem ]; 91 nixpkgs.overlays = [ 92 (_self: _super: { 93 klem = klem; 94 }) 95 ]; 96 }; 97}