summaryrefslogtreecommitdiffstats
path: root/krebs/2configs
diff options
context:
space:
mode:
authorlassulus <lassulus@lassul.us>2022-10-19 00:30:26 +0200
committerlassulus <lassulus@lassul.us>2022-10-19 00:30:26 +0200
commitc68da76ea1ffab8e012527383047bb3dc718b20f (patch)
treec4a8895d98446822fbd3a6f58215490092005b96 /krebs/2configs
parentfbec9a17fe6a012ce6f794e5a2d73c6dcec19463 (diff)
parentb5f7882fcada26d968b643765f32fd1ac23613ff (diff)
Merge remote-tracking branch 'ni/master'
Diffstat (limited to 'krebs/2configs')
-rw-r--r--krebs/2configs/reaktor2.nix59
1 files changed, 44 insertions, 15 deletions
diff --git a/krebs/2configs/reaktor2.nix b/krebs/2configs/reaktor2.nix
index 2ca84f568..afaac9dae 100644
--- a/krebs/2configs/reaktor2.nix
+++ b/krebs/2configs/reaktor2.nix
@@ -9,6 +9,48 @@ let
hooks = pkgs.reaktor2-plugins.hooks;
commands = pkgs.reaktor2-plugins.commands;
+ # bedger - the bier ledger
+ #
+ # logo: http://c.r/bedger2
+ #
+ bedger-add = {
+ pattern = ''^([\H-]*?):?\s+([+-][1-9][0-9]*)\s+(\S+)$'';
+ activate = "match";
+ arguments = [1 2 3];
+ command = {
+ env = {
+ # TODO; get state as argument
+ state_file = "${stateDir}/ledger";
+ };
+ filename = pkgs.writeDash "bedger-add" ''
+ set -x
+ tonick=$1
+ amt=$2
+ unit=$3
+ printf '%s\n %s %d %s\n %s %d %s\n' "$(date -Id)" "$tonick" "$amt" "$unit" "$_from" "$(expr 0 - "''${amt#+}")" "$unit" >> $state_file
+ ${pkgs.hledger}/bin/hledger -f $state_file bal -N -O csv \
+ | ${pkgs.coreutils}/bin/tail +2 \
+ | ${pkgs.miller}/bin/mlr --icsv --opprint cat \
+ | ${pkgs.gnugrep}/bin/grep "$_from"
+ '';
+ };
+ };
+ bedger-balance = {
+ pattern = "^bier (ballern|bal(an(ce)?)?)$";
+ activate = "match";
+ command = {
+ env = {
+ state_file = "${stateDir}/ledger";
+ };
+ filename = pkgs.writeDash "bedger-balance" ''
+ ${pkgs.hledger}/bin/hledger -f $state_file bal -N -O csv \
+ | ${pkgs.coreutils}/bin/tail +2 \
+ | ${pkgs.miller}/bin/mlr --icsv --opprint cat \
+ | ${pkgs.gnused}/bin/sed 's/^\(.\)/\1‍/'
+ '';
+ };
+ };
+
taskRcFile = builtins.toFile "taskrc" ''
confirmation=no
'';
@@ -93,21 +135,6 @@ let
];
hooks.PRIVMSG = [
{
- pattern = "^bier (ballern|bal(an(ce)?)?)$";
- activate = "match";
- command = {
- env = {
- state_file = "${stateDir}/ledger";
- };
- filename = pkgs.writeDash "bier-balance" ''
- ${pkgs.hledger}/bin/hledger -f $state_file bal -N -O csv \
- | ${pkgs.coreutils}/bin/tail +2 \
- | ${pkgs.miller}/bin/mlr --icsv --opprint cat \
- | ${pkgs.gnused}/bin/sed 's/^\(.\)/\1‍/'
- '';
- };
- }
- {
pattern = "^list-locations";
activate = "match";
command = {
@@ -205,6 +232,8 @@ let
'';
};
}
+ bedger-add
+ bedger-balance
hooks.sed
(generators.command_hook {
inherit (commands) dance random-emoji nixos-version;