]> git.earman.xyz Git - stumpwminit.git/commitdiff
Initial commit
authorrush <rush@Thonkbook.com>
Wed, 27 Aug 2025 01:06:07 +0000 (21:06 -0400)
committerrush <rush@Thonkbook.com>
Wed, 27 Aug 2025 01:06:07 +0000 (21:06 -0400)
.gitignore [new file with mode: 0644]
functions.lisp [new file with mode: 0644]
init.lisp [new file with mode: 0644]
swank-init.lisp [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..92ea99b
--- /dev/null
@@ -0,0 +1,2 @@
+*.log*
+/modules
diff --git a/functions.lisp b/functions.lisp
new file mode 100644 (file)
index 0000000..23c8865
--- /dev/null
@@ -0,0 +1,34 @@
+(defcommand firefox () ()
+  (sb-thread:make-thread (lambda ()
+                          (run-or-raise "firefox" '(:class "Firefox")))))
+
+(defcommand acme () ()
+  "Start Acme or switch to it, if it is already running"
+  (sb-thread:make-thread (lambda() (run-or-raise "9 acme -a" '(:class "Acme")))))
+
+(defcommand delete-window-and-frame () ()
+  "Delete current frame with its window."
+  (delete-window)
+  (remove-split))
+
+(defcommand emacsclient () ()
+  "Run emacsclient, or start it if not running."
+  (sb-thread:make-thread (lambda () (run-or-raise "emacsclient -r" '(:class "Emacs")))))
+
+(defcommand hsplit-and-focus () ()
+  "Create a new frame on the right and focus it."
+  (hsplit)
+  (move-focus :right))
+
+(defcommand vsplit-and-focus () ()
+  "Create a new frame below and move focus to it."
+  (vsplit)
+  (move-focus :down))
+
+(defcommand 9term () ()
+  "Open 9term"
+  (sb-thread:make-thread (lambda () (run-shell-command "9 9term"))))
+
+(defcommand surf () ()
+  "Open surf to my homepage."
+  (sb-thread:make-thread (lambda () (run-shell-command "surf -m /home/rush/lib/bookmarks.html"))))
diff --git a/init.lisp b/init.lisp
new file mode 100644 (file)
index 0000000..06d5c62
--- /dev/null
+++ b/init.lisp
@@ -0,0 +1,99 @@
+(in-package :stumpwm)
+(setf *default-package* :stumpwm)
+
+(defvar *modelineinfo* "")
+(defparameter *threads* '())
+
+;; SWANK
+(load "~/.stumpwm.d/swank-init.lisp")
+
+;; FUNCTIONS
+(load "~/.stumpwm.d/functions.lisp")
+
+(undefine-key *root-map* (kbd "a"))
+(undefine-key *root-map* (kbd "C-a"))
+(undefine-key *root-map* (kbd "C-b"))
+(undefine-key *root-map* (kbd "C-m"))
+
+(define-key *top-map* (kbd "s-l") "exec xscreensaver-command --activate")
+(define-key *top-map* (kbd "s-s") "toggle-swank")
+
+(define-key *root-map* (kbd "\-") "vsplit")
+(define-key *root-map* (kbd "\\") "hsplit")
+(define-key *root-map* (kbd "s") "vsplit-and-focus")
+(define-key *root-map* (kbd "S") "hsplit-and-focus")
+(define-key *root-map* (kbd "C-c") "9term")
+(define-key *root-map* (kbd "C-s") "surf")
+(define-key *root-map* (kbd "C-f") "firefox")
+(define-key *root-map* (kbd "C-a") "acme")
+(define-key *root-map* (kbd "C-e") "emacsclient")
+
+(setf *timeout-wait* 7
+      *ignore-wm-inc-hints* t
+      *window-format* "%n: %20t"
+      *mouse-focus-policy* :click
+      *float-window-modifier* :SUPER
+      *run-or-raise-all-groups* t
+      *message-window-gravity* :top
+      *input-window-gravity* :top
+      *message-window-padding*   5
+      *message-window-y-padding* 5)
+
+(defparameter *comp-group* (gnewbg "Compile"))
+
+(when *initializing* (mode-line))
+
+(let ((module-dir
+       (or (probe-file "/usr/share/stumpwm/contrib")
+           (probe-file "/usr/local/share/stumpwm/contrib")
+           (probe-file (merge-pathnames ".local/share/stumpwm/contrib"
+                                        (user-homedir-pathname)))
+           (probe-file (merge-pathnames ".stumpwm.d/modules"
+                                        (user-homedir-pathname)))
+           (probe-file (merge-pathnames ".config/stumpwm/modules"
+                                        (user-homedir-pathname))))))
+  (set-module-dir module-dir))
+
+(load-module "beckon")
+(load-module "end-session")
+(load-module "pass")
+
+;; MODE LINE
+(setf *mode-line-timeout* 2
+      *time-modeline-string* "%a %d %b %H:%M"
+      *group-format* "%t"
+      *window-format* "%s%n: %30t")
+
+(load-module "battery-portable")
+
+;; Normalize String
+(defun normalize-string (string)
+  "remove weird whitespace or rubbish in strings"
+  (string-trim
+   '(#\Space #\Newline #\Backspace #\Tab #\Linefeed #\Page #\Return #\Rubout)
+   string))
+
+;; Run a shell command and format the output
+(defun run-shell-command-and-format (command)
+  "run a shell command, if output is empty reverse coloring and return string 'nil'"
+  (let ((output (run-shell-command command t)))
+    (if (string= output "")
+       "^Rnil^r"
+       (normalize-string output))))
+
+;; Get the volume
+(defun show-volume ()
+  "show current volume given a (type) argument"
+  (format nil "~,1f%" (* 100 (read-from-string (run-shell-command-and-format "wpctl get-volume @DEFAULT_AUDIO_SINK@ |sed -e 's/Volume//' -e 's/ 0\./ /' -e 's/\.00//'")))))
+
+(setf *screen-mode-line-format* (list "^6[%g]^n "
+                                     "%W"
+                                     "^>"
+                                     "%S"
+                                     "Juice: %B"
+                                     " | "
+                                     '(:eval (show-volume))
+                                     " | "
+                                     "%d"))
+
+(enable-mode-line (current-screen) (current-head) t)
diff --git a/swank-init.lisp b/swank-init.lisp
new file mode 100644 (file)
index 0000000..286500b
--- /dev/null
@@ -0,0 +1,40 @@
+(require :swank)
+(swank-loader:init)
+
+(defparameter *port-number* 4004)
+
+(defvar *swank-server-p* nil)
+
+(defcommand start-swank () ()
+  (if *swank-server-p*
+      (message "Swank server is already active on Port^5 ~a^n" *port-number*)
+      (progn
+       (swank:create-server :port *port-number*
+                            :dont-close t)
+       (setf *swank-server-p* t)
+       (message "Swank server is now active on Port^5 ~a^n.
+Use^4 M-x slime-connect^n in Emacs.
+Type^2 (in-package :stumpwm)^n in Slime REPL." *port-number*))))
+
+(defcommand stop-swank () ()
+  "Stop Swank"
+  (swank:stop-server *port-number*)
+  (setf *swank-server-p* nil)
+  (message "Stopping Swank Server! Closing Port^5 ~a^n." *port-number*))
+
+(defcommand toggle-swank () ()
+  (if *swank-server-p*
+      (run-commands "stop-swank")
+      (run-commands "start-swank")))
+
+;;modeline status
+(defun get-swank-status ()
+  (if *swank-server-p*
+      (setf *swank-ml-status* (format nil "Swank:^2 ~a^n | " *port-number*))
+      (setf *swank-ml-status* "Swank: off | ")))
+
+(defun ml-fmt-swank-status (ml)
+  (declare (ignore ml))
+  (get-swank-status))
+
+(add-screen-mode-line-formatter #\S #'ml-fmt-swank-status)