ea681bd9c52d

Tweak stump
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Tue, 19 Mar 2024 16:09:11 -0400
parents dedc81b8510c
children e6e13bf8dad4
branches/tags (none)
files stumpwm/clipboard.lisp stumpwm/key-mapping.lisp stumpwm/modeline.lisp stumpwm/modules.lisp stumpwm/sensors.lisp stumpwm/sound.lisp stumpwm/stumpwmrc stumpwm/utils.lisp

Changes

--- a/stumpwm/clipboard.lisp	Tue Mar 19 14:06:36 2024 -0400
+++ b/stumpwm/clipboard.lisp	Tue Mar 19 16:09:11 2024 -0400
@@ -1,7 +1,5 @@
 (in-package :stumpwm-user)
 
-(load-module "clipboard-history")
-(clipboard-history:start-clipboard-manager)
 
 (defcommand generate-random-uuid () ()
   (run-shell-command "uuidgen | tr -d '\\n' | ~/src/dotfiles/bin/pbcopy")
--- a/stumpwm/key-mapping.lisp	Tue Mar 19 14:06:36 2024 -0400
+++ b/stumpwm/key-mapping.lisp	Tue Mar 19 16:09:11 2024 -0400
@@ -19,7 +19,6 @@
                               ,(second form)))))
 
 
-
 (define-top-keys ;; miscellaneous
   ("H-m" "terminal")
   ("H-M" "mark")
@@ -34,6 +33,7 @@
   ("H-b" "browser")
   ("H-O" "spotify")
   ("H-o" "files")
+  ("H-P" "papers")
   ("H-z" "zoom")
   ("H-Z" "toggle-zoom-mute")
   ("C-H-Z" "end-zoom")
@@ -41,22 +41,19 @@
   ("S-F26" "next")
   ("H-q" "exec lock-screen")
   ("H-y" "screenshot")
-  ("H-g" "gcontrol")
   ("H-f" "save-fucked-screenshot")
   ("H-F" "delete-fucked-screenshot")
   ("H-r" "rain")
   ("H-V" "vlc")
   ("H-e" "budget")
   ("H-E" "spend")
-  ("C-BackSpace" "clear-notifications")
-  )
+  ("C-BackSpace" "clear-notifications"))
 
 (define-top-keys ;; clipboard
   ("H-c" "show-clipboard-history")
   ("H-C" "clear-clipboard-history")
   ("H-u" "generate-random-uuid")
-  ("H-B" "bee-movie-script")
-  ("M-H-u" "urlize-jira-issue"))
+  ("H-B" "bee-movie-script"))
 
 (define-top-keys ;; movement
   ("H-h" "move-focus* left")
@@ -103,8 +100,6 @@
   ("H-n" "next-in-frame")
   ("H-p" "prev-in-frame")
   ("H-N" "pull-hidden-next")
-  ("H-P" "papers")
-
   ("H-," "pull-from-windowlist"))
 
 
@@ -119,11 +114,6 @@
   ("H-BackSpace" "remove")
   ("S-H-BackSpace" "kill-and-remove"))
 
-;; (define-top-keys ;; broken thinkpad keys
-;;   ("s-m" "thinkpad-ret")
-;;   ("s-Delete" "thinkpad-bs"))
-
-
 (define-top-keys ;; naming
   ("H-'" "title"))
 
--- a/stumpwm/modeline.lisp	Tue Mar 19 14:06:36 2024 -0400
+++ b/stumpwm/modeline.lisp	Tue Mar 19 16:09:11 2024 -0400
@@ -17,7 +17,7 @@
     "[%c] [%f]"
 
     mem::*mem-modeline-fmt*
-    "%b"
+    "%p"
 
     *screen-mode-line-format*
     (append
@@ -25,22 +25,21 @@
             '(:eval (princ-to-string (group-number (current-group))))
             ":%n^b@%h] %W^>")
 
-      #+todo-some-day (list ;; "(V "
-                            ;; ;; '(:eval (volume))
-                            ;; ")"
-                            " ")
+      (list "(V %V) ")
 
       ;; battery and brightness for laptops
       (hostcase
         ((:gro :juss)
-         '("(B %B)"
-           " (BR "
-           (:eval (princ-to-string (brightness)))
-           "%)")))
+         (list "(B %B)"
+               " (BR "
+               '(:eval (princ-to-string (brightness)))
+               "%) ")))
 
-      ;; temp, cpu, mem, time, tray
-      #+no (list "(TEMP %S) (CPU %C) (MEM %M) %d %T")
-      (list "(CPU %C) (MEM %M) %d %T")
+      ;; temperature
+      (list "(TEMP %S) ")
+
+      ;; cpu, mem, time, tray
+      (list "(CPU %C) (MEM%M) %d %T")
       ))
 
   (setf *mode-line-timeout* 10)
--- a/stumpwm/modules.lisp	Tue Mar 19 14:06:36 2024 -0400
+++ b/stumpwm/modules.lisp	Tue Mar 19 16:09:11 2024 -0400
@@ -6,3 +6,4 @@
 (load-module "hostname")
 (load-module "mem")
 (load-module "stumptray")
+(load-module "clipboard-history")
--- a/stumpwm/sensors.lisp	Tue Mar 19 14:06:36 2024 -0400
+++ b/stumpwm/sensors.lisp	Tue Mar 19 16:09:11 2024 -0400
@@ -23,10 +23,6 @@
     (loop :while (char= #\E (peek-char nil s)) :do (read-line s))
     (jarl:read t s)))
 
-(defparameter *sensors-refresh-delay* 5.0 "How long between sensor refreshes (in seconds).")
-(defparameter *sensors-next-refresh* nil)
-(defparameter *sensors-cache* nil)
-
 (defun sensors% (&aux (sensors (parse-sensors)))
   (hostcase
     (:ouroboros (format nil "[CPU ~D°C] [GPU ~D°C ~D°C ~D°C]"
@@ -36,18 +32,17 @@
                         (round (? sensors "amdgpu-pci-4500"  "mem"      "temp3_input"))))
     ((:gro :juss) (format nil "[CPU ~D°C] [GPU ~D°C]"
                         (round (? sensors "thinkpad-isa-0000" "CPU"  "temp1_input"))
-                        (round (? sensors "amdgpu-pci-0600"   "edge" "temp1_input"))))
+                        (round (? sensors "amdgpu-pci-0400"   "edge" "temp1_input"))))
     (t "?")))
 
-(defun sensors (&aux (now (get-internal-real-time)))
-  (if (or (null *sensors-next-refresh*)
-          (>= now *sensors-next-refresh*))
-      (setf *sensors-next-refresh* (+ now (* internal-time-units-per-second *sensors-refresh-delay*))
-            *sensors-cache* (sensors%))
-      *sensors-cache*))
+(defcached (sensors :seconds 5.0)
+  (sensors%))
 
 (defun sensors-modeline (ml)
   (declare (ignore ml))
   (sensors))
 
 (add-screen-mode-line-formatter #\S #'sensors-modeline)
+
+#; Scratch --------------------------------------------------------------------
+
--- a/stumpwm/sound.lisp	Tue Mar 19 14:06:36 2024 -0400
+++ b/stumpwm/sound.lisp	Tue Mar 19 16:09:11 2024 -0400
@@ -1,14 +1,35 @@
 (in-package :stumpwm-user)
 
+(defun volume% ()
+  (_ (run-shell-command "amixer sget Master" t)
+    (string-grep "Front Left:" _ :first-only t)
+    (string-split "[]" _)
+    second
+    (string-trim "%" _)
+    parse-integer))
+
+(defcached (volume :seconds 30)
+  (volume%))
+
 (defcommand mute () ()
   (run-shell-command "mute")
   (echo "Muted."))
 
 (defcommand volume-up () ()
   (run-shell-command "amixer -q sset Master 5%+")
+  (volume/uncache)
   (message "Volume: ~D%" (volume)))
 
 (defcommand volume-down () ()
   (run-shell-command "amixer -q sset Master 5%-")
+  (volume/uncache)
   (message "Volume: ~D%" (volume)))
 
+(defun volume-modeline (ml)
+  (declare (ignore ml))
+  (format nil "~D%" (volume)))
+
+(add-screen-mode-line-formatter #\V #'volume-modeline)
+
+#; Scratch --------------------------------------------------------------------
+(volume)
--- a/stumpwm/stumpwmrc	Tue Mar 19 14:06:36 2024 -0400
+++ b/stumpwm/stumpwmrc	Tue Mar 19 16:09:11 2024 -0400
@@ -8,5 +8,8 @@
 (defvar *dunst*
   (run-shell-command "/usr/bin/dunst -conf ~/.dunstrc"))
 
+(defvar *clip*
+  (clipboard-history:start-clipboard-manager))
+
 (when (probe-file "/home/sjl/.stumpwmrc.local")
   (load "/home/sjl/.stumpwmrc.local"))
--- a/stumpwm/utils.lisp	Tue Mar 19 14:06:36 2024 -0400
+++ b/stumpwm/utils.lisp	Tue Mar 19 16:09:11 2024 -0400
@@ -24,13 +24,21 @@
   (mod (+ n increment) modulo))
 
 
-(defun volume ()
-  (_ (run-shell-command "amixer sget Master" t)
-    (string-grep "Front Left:" _ :first-only t)
-    (string-split "[]" _)
-    second
-    (string-trim "%" _)
-    parse-integer))
+(defmacro defcached ((name &key seconds) &body body)
+  (with-gensyms (ttl next value)
+    `(progn
+       (let ((,ttl ,seconds)
+             (,next nil)
+             (,value nil))
+         (defun ,name ()
+           (when (or (null ,next)
+                     (>= (get-internal-real-time) ,next))
+             (setf ,next (+ (get-internal-real-time)
+                            (* internal-time-units-per-second ,ttl))
+                   ,value (progn ,@body)))
+           ,value)
+         (defun ,(symb name '/uncache) ()
+           (setf ,next nil ,value nil))))))
 
 
 (defun current-frame ()