aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/habit41
-rwxr-xr-xbin/tagmail2
2 files changed, 42 insertions, 1 deletions
diff --git a/bin/habit b/bin/habit
new file mode 100755
index 0000000..5afb4ce
--- /dev/null
+++ b/bin/habit
@@ -0,0 +1,41 @@
+#!/usr/bin/guile \
+-e main-rofi -s
+!#
+
+(add-to-load-path "/home/titan/dev/dotfiles/lib/guile/")
+
+(use-modules (ice-9 rdelim)
+ (ice-9 popen)
+ (ice-9 ftw)
+ (ice-9 format)
+ (ice-9 and-let-star)
+ (utils))
+
+(define habits-dir (expand-file "~/org/habits/"))
+
+(define (get-habit-files dir)
+ (scandir dir (lambda (file) (string-suffix? ".dat" file))))
+
+(define (prepare-options files)
+ (string-join (map (lambda (name) (string-drop-right name 4)) files) "\n"))
+
+(define (rofi-capture-option options)
+ (let* ((cmd (format #f "echo -e ~s | rofi -dmenu" options))
+ (port (open-input-pipe cmd))
+ (option (read-line port)))
+ (close-pipe port)
+ (if (eof-object? option) #f option)))
+
+(define (rofi-capture-habit-quantity habit)
+ (let* ((cmd (format #f "echo 1 | rofi -dmenu -p 'Add to ~a'" habit))
+ (port (open-input-pipe cmd))
+ (quantity (read-line port)))
+ (close-pipe port)
+ (if (eof-object? quantity) #f quantity)))
+
+(define (main-rofi args)
+ (and-let* ((habit (rofi-capture-option (prepare-options (get-habit-files habits-dir))))
+ (quantity (rofi-capture-habit-quantity habit))
+ (file-out (open-file (string-append habits-dir habit ".dat") "a")))
+ (format file-out "~d:~a\n" (current-time) quantity)
+ (close-port file-out)))
diff --git a/bin/tagmail b/bin/tagmail
index 31a236d..02e5d6e 100755
--- a/bin/tagmail
+++ b/bin/tagmail
@@ -10,7 +10,7 @@ LD_LIBRARY_PATH=$HOME/.guix-profile/lib exec guile -e main -s "$0" "$@"
(add-to-load-path
(string-append
(passwd:dir (getpwuid (geteuid)))
- "/dev/helpful_scripts/guile/" ))
+ "/dev/dotfiles/lib/guile/" ))
(use-modules
(ffi notmuch)