c0a992963f26

Merge.
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Sat, 15 Jun 2019 11:46:53 -0400
parents 06a5d5a71a89 (current diff) df8c563e928a (diff)
children c96819f6677d
branches/tags (none)
files bin/screenshot-area bin/screenshot-screen stumpwmrc

Changes

--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/screenshot	Sat Jun 15 11:46:53 2019 -0400
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+flameshot gui -p ~/screenshots
--- a/bin/screenshot-area	Sat Jun 15 11:46:22 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-#!/usr/bin/env bash
-
-set -euo pipefail
-
-sleep 0.2 ; scrot 'screenshot_%Y-%m-%d_%H-%M-%S.png' -s -e 'mv $f ~/screenshots && echo -n ~/screenshots/$f' | xsel --clipboard --input
--- a/bin/screenshot-screen	Sat Jun 15 11:46:22 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-#!/usr/bin/env bash
-
-set -euo pipefail
-
-sleep 0.2 ; scrot 'screenshot_%Y-%m-%d_%H-%M-%S.png' -m -e 'mv $f ~/screenshots && echo -n ~/screenshots/$f' | xsel --clipboard --input
--- a/stumpwmrc	Sat Jun 15 11:46:22 2019 -0400
+++ b/stumpwmrc	Sat Jun 15 11:46:53 2019 -0400
@@ -1,6 +1,6 @@
 (in-package :stumpwm-user)
 
-(ql:quickload '(:losh :split-sequence :alexandria) :silent t)
+(ql:quickload '(:losh :split-sequence :alexandria :parse-number) :silent t)
 (use-package :losh)
 
 
@@ -95,6 +95,29 @@
   (* hours 60 60))
 
 
+(define-stumpwm-type :integer (input prompt)
+  ;; Annoyingly, StumpWM's built-in :number type isn't actually number, but is
+  ;; actually just integers.  Define a better-named type here.
+  (when-let ((n (or (argument-pop input)
+                    (read-one-line (current-screen) prompt))))
+    (handler-case
+        (parse-integer n)
+      (parse-error (c)
+        (declare (ignore c))
+        (throw 'error "Integer required.")))))
+
+(define-stumpwm-type :real (input prompt)
+  (when-let ((n (or (argument-pop input)
+                    (read-one-line (current-screen) prompt))))
+    (handler-case
+        (let ((result (parse-number:parse-number n)))
+          (assert (typep result 'real))
+          result)
+      (error (c)
+        (declare (ignore c))
+        (throw 'error "Real required.")))))
+
+
 ;;;; Posture ------------------------------------------------------------------
 (defparameter *posture-thread* nil)
 (defparameter *posture-should-stop* nil)
@@ -121,15 +144,13 @@
   (message "Unpausing posture.")
   (setf *posture-paused* nil))
 
-(print *posture-paused*)
-
 (defcommand posture-toggle-pause () ()
   (if (setf *posture-paused* (not *posture-paused*))
     (message "Posture is now paused.")
     (message "Posture is now unpaused.")))
 
 (defcommand posture-snooze (hours)
-    ((:number "Snooze for how many hours? "))
+    ((:real "Snooze for how many hours? "))
   (setf *posture-snooze* (+ (hours->seconds hours) (get-universal-time))))
 
 (defun posture-update (delta)
@@ -141,11 +162,17 @@
 
 (defcommand posture-answer-yes () ()
   (message "Good work.")
-  (posture-update 3/2))
+  (run-shell-command "echo $(epochseconds) 1.0 >> ~/.posture.log")
+  (posture-update 11/10))
+
+(defcommand posture-answer-meh () ()
+  (message "Better than nothing.")
+  (run-shell-command "echo $(epochseconds) 0.5 >> ~/.posture.log"))
 
 (defcommand posture-answer-no () ()
   (message "Try harder.")
-  (posture-update 1/2))
+  (run-shell-command "echo $(epochseconds) 0.0 >> ~/.posture.log")
+  (posture-update 8/10))
 
 (defun posture% ()
   (if *posture-should-stop*
@@ -198,12 +225,8 @@
 (load-module "pass")
 
 ;;;; Screenshotting -----------------------------------------------------------
-(defcommand screenshot-area () ()
-  ;; todo why the hell do these not pick up my fuckin path?
-  (run-shell-command "/home/sjl/src/dotfiles/bin/screenshot-area"))
-
-(defcommand screenshot-screen () ()
-  (run-shell-command "/home/sjl/src/dotfiles/bin/screenshot-screen"))
+(defcommand screenshot () ()
+  (run-shell-command "screenshot"))
 
 
 ;;;; Brightness ---------------------------------------------------------------
@@ -286,7 +309,7 @@
   (load "~/src/dotfiles/vim/bundle/vlime/lisp/start-vlime.lisp")
   (message "Started VLIME"))
 
-(defcommand vlime-port (port) ((:number "Port: "))
+(defcommand vlime-port (port) ((:integer "Port: "))
   "Start VLIME on the given port.
 
   Good for bootstrapping a VLIME connection when you accidentally started a
@@ -304,6 +327,10 @@
         (pass:*pass-notification-message* t))
     (pass:pass-copy)))
 
+(defcommand generate-password () ()
+  (run-shell-command "genpass | pbc")
+  (message "Generated a fresh password and copied it to the clipboard."))
+
 ;; (defcommand pass-work () ()
 ;;   (let ((pass:*password-store* "/home/sjl/.password-store-work/")
 ;;         (pass:*pass* "/home/sjl/src/dotfiles/bin/pass-work"))
@@ -387,13 +414,13 @@
   (pop-timer))
 
 (defcommand set-pop-timer (minutes seconds)
-    ((:number "Minutes: ")
-     (:number "Seconds: "))
+    ((:integer "Minutes: ")
+     (:integer "Seconds: "))
   (setf *pop-timer-minutes* minutes
         *pop-timer-seconds* seconds))
 
 (defcommand tea-timer (seconds)
-    ((:number "Seconds: "))
+    ((:integer "Seconds: "))
   (run-shell-command (format nil "tea ~D" seconds)))
 
 
@@ -421,12 +448,12 @@
   ("H-SunPageDown" "st-font-down")
   ("H-Home" "st-font-reset")
   ("H-\\" "pass-personal")
+  ("H-|" "generate-password")
   ("H-b" "browser")
   ("H-B" "exec firefox")
   ("H-o" "spotify")
   ("H-q" "exec lock-screen")
-  ("H-y" "screenshot-area")
-  ("H-Y" "screenshot-screen")
+  ("H-y" "screenshot")
   ("H-r" "loadrc")
   ("H-V" "vlime"))
 
@@ -492,6 +519,7 @@
   ("s-p"   "posture-start")
   ("s-P"   "posture-stop")
   ("s-y"   "posture-answer-yes")
+  ("s-h"   "posture-answer-meh")
   ("s-n"   "posture-answer-no")
   ("s-\\"  "posture-toggle-pause")
   ("s-o"   "posture-snooze"))