aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorspv <spv@spv.sh>2025-11-23 13:47:37 -0500
committerspv <spv@spv.sh>2025-11-23 13:48:49 -0500
commitaceb8340357347d68b5b96b778e3a928bcdd3c5e (patch)
tree75cd345d7b5bfd8c09556a52183d4883cb9d6ba0
parenta191ad0247eac24c30d41de1d484d9d60e3acb2a (diff)
add `sb` for summation, fixup ROADMAP
-rw-r--r--Makefile12
-rw-r--r--README2
-rwxr-xr-xsrc/process.py15
-rwxr-xr-xsrc/sb21
4 files changed, 30 insertions, 20 deletions
diff --git a/Makefile b/Makefile
index 895b6e0..d4803f4 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
CC=gcc
-all: bin bin/stroke_buddy
+all: bin bin/stroke_buddy bin/sb
clean:
rm -rf bin
@@ -11,13 +11,17 @@ bin:
bin/stroke_buddy: src/main.c src/key_tracker.c src/report.c
${CC} $^ -o $@
+bin/sb: src/sb
+ cp $^ $@
+
run: all
bin/stroke_buddy
install: all
- cp -p bin/stroke_buddy ~/.local/bin/
- cp -p res/stroke_buddy.service ~/.config/systemd/user/
- ln -s ~/.config/systemd/user/stroke_buddy.service ~/.config/systemd/user/default.target.wants/stroke_buddy.service
+ cp -pf bin/stroke_buddy ~/.local/bin/
+ cp -pf res/stroke_buddy.service ~/.config/systemd/user/
+ cp -p src/sb ~/.local/bin
+ ln -fs ~/.config/systemd/user/stroke_buddy.service ~/.config/systemd/user/default.target.wants/stroke_buddy.service
mkdir -p ~/.local/stroke_buddy
uninstall:
diff --git a/README b/README
index 905b48e..c5a9f02 100644
--- a/README
+++ b/README
@@ -20,7 +20,7 @@ roadmap
( ) per-key statistics
( ) per-keyboard statistics
(~) new report per day
- ( ) report processing
+ (~) report processing
[x?] security
(n/a) drop privs (add user to input group)
(x) where to store reports (~~/var dir?~~ ~/.local/stroke_buddy)
diff --git a/src/process.py b/src/process.py
deleted file mode 100755
index 0b645b8..0000000
--- a/src/process.py
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/usr/bin/env python3
-
-import sys, os
-
-def main(argv):
- homedir = os.getenv("HOME")
- stroke_buddydir = homedir + "/.local/stroke_buddy"
- log_files = os.listdir(stroke_buddydir)
-
- print(log_files)
-
- return 0
-
-if __name__ == "__main__":
- sys.exit(main(sys.argv))
diff --git a/src/sb b/src/sb
new file mode 100755
index 0000000..a3bc968
--- /dev/null
+++ b/src/sb
@@ -0,0 +1,21 @@
+#!/usr/bin/env zsh
+
+STROKE_BUDDY_DIR=~/.local/stroke_buddy
+TODAY=`date -I`
+
+function count_for_date {
+ lines=0
+
+ for hourly_file in $STROKE_BUDDY_DIR/"$1"*; do
+ hourly_presses=$(cat $hourly_file \
+ | grep keypresses \
+ | cut -d',' -f2)
+
+ lines=$(($lines+$hourly_presses))
+# lines=$(($lines+$hourly));
+ done
+
+ echo $lines
+}
+
+echo $(count_for_date $TODAY)