--- a/bin/e Tue Jul 19 12:41:40 2022 -0400
+++ b/bin/e Thu Jul 28 20:42:21 2022 -0400
@@ -2,4 +2,8 @@
set -euo pipefail
-"$EDITOR" "$@"
+if test "$#" -eq 0; then
+ "$EDITOR" .
+else
+ "$EDITOR" "$@"
+fi
--- a/bin/ee Tue Jul 19 12:41:40 2022 -0400
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-#!/usr/bin/env bash
-
-set -euo pipefail
-
-e .
--- a/stumpwmrc Tue Jul 19 12:41:40 2022 -0400
+++ b/stumpwmrc Thu Jul 28 20:42:21 2022 -0400
@@ -1,12 +1,14 @@
(in-package :stumpwm-user)
(shadow :window)
-(ql:quickload '(:losh :split-sequence :alexandria :parse-number :str :cl-ppcre :bordeaux-threads :jarl) :silent t)
+(ql:quickload '(:losh :split-sequence :alexandria :parse-number :str :cl-ppcre :bordeaux-threads :jarl :local-time)
+ :silent t)
+
(use-package :losh)
-
;;;; Config -------------------------------------------------------------------
(set-prefix-key (kbd "C-space"))
+(local-time:reread-timezone-repository)
(defvar *redirected* (redirect-all-output (data-dir-file "debug" "log")))
@@ -234,6 +236,52 @@
:name "Posture thread"))))
+;;;; Budget ------------------------------------------------------------------
+(defparameter *budget/per-day*
+ (first (losh:read-all-from-file "/home/sjl/Dropbox/budget/per-day")))
+
+(defparameter *tz/eastern*
+ (local-time:find-timezone-by-location-name "US/Eastern"))
+
+(defparameter *budget/start*
+ (local-time:encode-timestamp 0 0 0 0 26 7 2022 :timezone *tz/eastern*))
+
+(defun budget/elapsed ()
+ (local-time:timestamp-difference (local-time:now) *budget/start*))
+
+(defun budget/days-elapsed ()
+ (floor (/ (budget/elapsed) (* 60 60 24))))
+
+(defun budget/in ()
+ (* (budget/days-elapsed) *budget/per-day*))
+
+(defun budget/out ()
+ (loop :for path :in (directory "/home/sjl/Dropbox/budget/hosts/*/total")
+ :summing (print (first (read-all-from-file (print path))))))
+
+(defun budget/current ()
+ (- (budget/in) (budget/out)))
+
+(defcommand budget () ()
+ (message "$~D" (budget/current)))
+
+(defmacro with-budget-file ((f file &rest open-args) &body body)
+ `(with-open-file
+ (,f (format nil "/home/sjl/Dropbox/budget/hosts/~(~A~)/~A" *host* ,file)
+ ,@open-args)
+ ,@body))
+
+(defcommand spend (amount what) ((:integer "Amount: $") (:string "For: "))
+ (let ((current (with-budget-file (total "total")
+ (first (read-all-from-file total))))
+ (timestamp (local-time:to-rfc3339-timestring (local-time:now))))
+ (with-budget-file (total "total" :direction :output :if-exists :supersede)
+ (print (+ current amount) total))
+ (with-budget-file (records "records" :direction :output :if-exists :append :if-does-not-exist :create)
+ (print (list timestamp amount what) records))
+ (message "Spent $~D for ~A at ~A" amount what timestamp)))
+
+
;;;; Load ---------------------------------------------------------------------
(load-module "pass")
@@ -580,7 +628,6 @@
(isk-u-Æ "M-H" "AE"))
-
;;;; Key Mapping --------------------------------------------------------------
;;; Conventions:
;;;
@@ -621,7 +668,10 @@
("H-F" "delete-fucked-screenshot")
("H-R" "loadrc")
("H-r" "rain")
- ("H-V" "vlc"))
+ ("H-V" "vlc")
+ ("H-4" "budget")
+ ("H-$" "spend")
+ )
(define-top-keys ;; clipboard
("H-c" "show-clipboard-history")
@@ -644,9 +694,6 @@
("H-1" "gmove 1")
("H-2" "gmove 2")
("H-3" "gmove 3")
- ("H-4" "gmove 4")
- ("H-5" "gmove 5")
- ("H-6" "gmove 6")
("C-H-H" "exchange-direction left")
("C-H-J" "exchange-direction down")
@@ -712,7 +759,6 @@
("H-F12" "refresh-heads"))
-
;; (stumpwm::unbind-remapped-keys)
(define-remapped-keys
'(("st-256color"
@@ -869,9 +915,6 @@
;;;; Startup ------------------------------------------------------------------
-;; (defvar *network-manager*
- ;; (run-shell-command "nm-applet --sm-disable"))
-
;; (defvar *dropbox*
;; (run-shell-command "~/.dropbox-dist/dropboxd"))