7b9e9599fe0e

More
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sat, 04 Dec 2021 22:49:41 -0500
parents 96b9cf7e7a90
children 958358268b7e
branches/tags (none)
files bin/ecl-vlime bin/external-ip stumpwmrc

Changes

--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/ecl-vlime	Sat Dec 04 22:49:41 2021 -0500
@@ -0,0 +1,4 @@
+#!/usr/bin/env bash
+
+set -e
+ecl --eval "(load \"~/src/dotfiles/vim/bundle/vlime/lisp/start-vlime.lisp\")" "$@"
--- a/bin/external-ip	Fri Sep 03 12:53:26 2021 -0400
+++ b/bin/external-ip	Sat Dec 04 22:49:41 2021 -0500
@@ -2,5 +2,7 @@
 
 set -euo pipefail
 
-dig @resolver1.opendns.com ANY myip.opendns.com +short
 
+#dig @resolver1.opendns.com ANY myip.opendns.com +short
+curl whatismyip.stevelosh.com
+
--- a/stumpwmrc	Fri Sep 03 12:53:26 2021 -0400
+++ b/stumpwmrc	Sat Dec 04 22:49:41 2021 -0500
@@ -1,6 +1,6 @@
 (in-package :stumpwm-user)
 
-(ql:quickload '(:losh :split-sequence :alexandria :parse-number :str :cl-ppcre :bordeaux-threads) :silent t)
+(ql:quickload '(:losh :split-sequence :alexandria :parse-number :str :cl-ppcre :bordeaux-threads :jarl) :silent t)
 (use-package :losh)
 
 
@@ -378,23 +378,6 @@
 (defcommand describe-window () ()
   (show-window-properties))
 
-(defcommand unfuck-zoom-link () ()
-  (let ((url (pbpaste)))
-    (ppcre:register-groups-bind
-        (meeting-id meeting-pass)
-        ("^https://[a-zA-Z0-9]+[.]zoom[.]us/j/(\\d+)[?]pwd=([A-Za-z0-9]+)$" url)
-      (pbcopy meeting-id)
-      (message "Zoom meeting ID copied.")
-      (bt:make-thread (lambda ()
-                        (sleep 3)
-                        (pbcopy meeting-pass)
-                        (message "Zoom meeting password copied.")
-                        (sleep 5)
-                        (pbcopy ""))
-                      :name "Zoom Link Defuckulator")
-      (return-from unfuck-zoom-link))
-    (message "Clipboard doesn't seem to be a Zoom link.")))
-
 (defcommand rain () ()
   (message (run-shell-command "weather -H 36" t)))
 
@@ -576,8 +559,7 @@
   ("H-C" "clear-clipboard-history")
   ("H-u" "generate-random-uuid")
   ("H-U" "bee-movie-script")
-  ("M-H-u" "urlize-jira-issue")
-  ("H-Z" "unfuck-zoom-link"))
+  ("M-H-u" "urlize-jira-issue"))
 
 (define-top-keys ;; movement
   ("H-h" "move-focus* left")
@@ -700,6 +682,57 @@
      ("s-v" . "C-v"))))
 
 
+;;;; Sensors ------------------------------------------------------------------
+(defun ? (obj &rest keys)
+  (if (null keys)
+      obj
+      (apply #'? (etypecase obj
+                   (hash-table (gethash (first keys) obj)))
+             (rest keys))))
+
+(defun parse-sensors ()
+  ;; sensors -j is stupid and will output errors before the actual output on
+  ;; standard out, instead of putting them on standard err like a reasonable
+  ;; program, e.g.:
+  ;;
+  ;;     ERROR: Can't get value of subfeature temp1_input: Can't read
+  ;;     {
+  ;;        "iwlwifi_1-virtual-0":{ … },
+  ;;        …
+  ;;
+  ;; So we'll have to drop the `ERROR` lines before we can get to the actual
+  ;; goddamn JSON.  UNIX programs are so great.
+  (let ((s (losh:sh '("sensors" "-j") :result-type 'stream)))
+    (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]"
+                        (round (? sensors "nct6779-isa-0290" "CPUTIN" "temp2_input"))
+                        (round (? sensors "amdgpu-pci-4500"  "edge"     "temp1_input"))
+                        (round (? sensors "amdgpu-pci-4500"  "junction" "temp2_input"))
+                        (round (? sensors "amdgpu-pci-4500"  "mem"      "temp3_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*))
+
+(defun sensors-modeline (ml)
+  (declare (ignore ml))
+  (sensors))
+
+(add-screen-mode-line-formatter #\S #'sensors-modeline)
+
+
 ;;;; Modeline -----------------------------------------------------------------
 (load-module "battery-portable")
 (load-module "cpu")
@@ -720,7 +753,7 @@
     "^[~A~3D%^]"
 
     cpu::*cpu-modeline-fmt*
-    "[%c] [%t] [%f]"
+    "[%c] [%f]"
 
     mem::*mem-modeline-fmt*
     "%b"
@@ -742,8 +775,8 @@
            (:eval (princ-to-string (brightness)))
            "%)")))
 
-      ;; cpu, time, tray
-      (list " (CPU %C) (MEM %M) %d %T")))
+      ;; temp, cpu, mem, time, tray
+      (list "(TEMP %S) (CPU %C) (MEM %M) %d %T")))
 
   (setf *mode-line-timeout* 10)
   (setf *mode-line-background-color* "#111111")