From 37a826f2e8e0098171d7ebd73078befa8373d709 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Tue, 22 Apr 2025 10:35:28 -0700 Subject: Rename stumpwm/config to stumpwm.lisp --- oni/home/config/pop-os.scm | 2 +- oni/home/config/rincewind.scm | 2 +- oni/home/services/stumpwm.scm | 1 + oni/home/services/stumpwm/config | 162 --------------------------------- oni/home/services/stumpwm/stumpwm.lisp | 161 ++++++++++++++++++++++++++++++++ 5 files changed, 164 insertions(+), 164 deletions(-) delete mode 100644 oni/home/services/stumpwm/config create mode 100644 oni/home/services/stumpwm/stumpwm.lisp diff --git a/oni/home/config/pop-os.scm b/oni/home/config/pop-os.scm index b5d30f9..db3611b 100644 --- a/oni/home/config/pop-os.scm +++ b/oni/home/config/pop-os.scm @@ -181,7 +181,7 @@ (package stumpwm+swank) (locker-program "/usr/bin/i3lock") (configurations - (list (local-file "../services/stumpwm/config") + (list (local-file "../services/stumpwm/stumpwm.lisp") (local-file "../services/stumpwm/pop-os-config.lisp"))))) (service home-stumpwm-stumptray-service-type (home-stumpwm-stumptray-configuration diff --git a/oni/home/config/rincewind.scm b/oni/home/config/rincewind.scm index d22e285..9eb8006 100644 --- a/oni/home/config/rincewind.scm +++ b/oni/home/config/rincewind.scm @@ -516,7 +516,7 @@ (home-stumpwm-configuration (package stumpwm+swank) (configurations - (list (local-file "../services/stumpwm/config"))))) + (list (local-file "../services/stumpwm/stumpwm.lisp"))))) (service home-stumpwm-gaps-service-type (home-stumpwm-gaps-configuration (configurations diff --git a/oni/home/services/stumpwm.scm b/oni/home/services/stumpwm.scm index eabc944..1e221b2 100644 --- a/oni/home/services/stumpwm.scm +++ b/oni/home/services/stumpwm.scm @@ -98,6 +98,7 @@ `(("stumpwm/config" ,(mixed-text-file "config" + ";; -*- mode: lisp; -*-\n" "(setq *locker-program* \"" (home-stumpwm-configuration-locker-program config) "\")\n" (serialize-text-config config (home-stumpwm-configuration-configurations config)))))) diff --git a/oni/home/services/stumpwm/config b/oni/home/services/stumpwm/config deleted file mode 100644 index 36208c5..0000000 --- a/oni/home/services/stumpwm/config +++ /dev/null @@ -1,162 +0,0 @@ -;; -*- mode: lisp; -*- -(in-package :stumpwm-user) - -(require 'swank) - -(set-prefix-key (kbd "s-x")) - -(defvar *screen-locking-hook* nil - "Hook that gets called right before the screen gets locked.") - -(defvar *screen-unlocked-hook* nil - "Hook that gets called right after the screen is unlocked.") - -(defun run-screen-unlocked-hook (process) - "Run `*screen-unlocked-hook* if PROCESS' status is `:exited'." - (when (eq (sb-ext:process-status process) :exited) - (run-hook *screen-unlocked-hook*))) - -(defun vpn-connected-p () - (probe-file "/sys/class/net/vpn")) - -(defcommand lock-screen () () - "Lock the screen using i3lock. -Run `*screen-locking-hook*' before locking it and run `*screen-unlocked-hook*' -after it has been unlocked." - (run-hook *screen-locking-hook*) - (sb-ext:run-program - *shell-program* `("-c" ,(format nil "~a --nofork --color=000000" *locker-program*)) - :wait nil - :status-hook #'run-screen-unlocked-hook)) - -(defcommand raise-browser () () - "Open or show my browser" - (run-or-raise "firefox" '(:class "firefox|zen(-beta)?"))) - -(defcommand raise-emacs () () - "Open or show Emacs" - (run-or-raise "emacsclient -c" '(:class "Emacs"))) - -(defcommand raise-terminal () () - "Open or show my terminal" - (run-or-raise "kitty" '(:class "kitty|org\.wezfurlong\.wezterm"))) - -(define-key *top-map* (kbd "C-M-l") "lock-screen") -(define-key *top-map* (kbd "s-b") "raise-browser") -(define-key *top-map* (kbd "s-e") "raise-emacs") -(define-key *top-map* (kbd "s-t") "raise-terminal") -(define-key *top-map* (kbd "s-!") "exec rofi -show drun") -(define-key *top-map* (kbd "s-w") "exec rofi -show window") - -(define-remapped-keys - `(("teams-for-linux" - ;; Mute microphone in meetings. - ("XF86Launch6" . "C-S-m")) - ("[Ff]irefox" - ;; Generally cancel action. - ("XF86Launch6" . "ESC")) - ("[Ee]macs" - ;; Save document. - ("XF86Launch5" . ("C-x" "C-s")) - ;; Save some documents. - ("S-XF86Launch5" . ("C-x" "s")) - ;; Quit command. - ("XF86Launch6" . "C-g") - ;; Revert (reload) file. - ("XF86Launch7" . ("C-x" "x" "g"))) - ;; Portal: Revolution - ("revolution" - ;; Quick Save - ("XF86Launch5" . "F6") - ;; Quick Load - ("XF86Launch7" . "F7")))) - -(set-bg-color "#222424") -(set-border-color "#3f4242") -(set-fg-color "#bfbfbf") -(set-float-focus-color "#5b6161") -(set-float-unfocus-color "#3f4242") -(set-focus-color "#ff9800") -(set-unfocus-color "#3f4242") - -(setf *mode-line-background-color* "#111414" - *mode-line-foreground-color* "#bfbfbf" - *mode-line-border-width* 0 - *mode-line-pad-x* 10) -(setf *screen-mode-line-format* - (list "[ ^B%n^b ] " - "^[^(:bg \"#f17272\")^(:fg \"#222424\")[ " - '(:eval - (or (ignore-errors (window-title (current-window))) - "Unknown")) - " ]^]^>" - '(:eval - (if (vpn-connected-p) - "^*5^B[ VPN ]^b^n " - "")) - "[ %d ] ")) - -;;; Redefinition of the make mode-line window to add the Dock window type. -(defun stumpwm::make-mode-line-window (screen) - "Create a window suitable for a modeline." - (let ((window (xlib:create-window - :parent (screen-root screen) - :x 0 :y 0 :width 1 :height 1 - :background (stumpwm::alloc-color screen *mode-line-background-color*) - :border (stumpwm::alloc-color screen *mode-line-border-color*) - :border-width *mode-line-border-width* - ;; You can click the modeline - :event-mask (xlib:make-event-mask :button-press :exposure) - ;; these windows are not controlled by the window manager - :override-redirect :on))) - (xlib:change-property - window :_NET_WM_WINDOW_TYPE - (list (xlib:find-atom *display* :_NET_WM_WINDOW_TYPE_DOCK)) - :atom 32) - window)) - -(mode-line) - -;;; Screenshots - -(defvar *screenshot-bindings* - (let ((m (make-sparse-keymap))) - (define-key m (kbd "s") "exec flameshot gui") - (define-key m (kbd "c") "exec flameshot screen") - (define-key m (kbd "f") "exec flameshot full") - m)) - -(defvar *notification-bindings* - (let ((m (make-sparse-keymap))) - (define-key m (kbd "RET") "exec dunstctl action") - (define-key m (kbd "c") "exec dunstctl close") - (define-key m (kbd "S-c") "exec dunstctl close-all") - (define-key m (kbd "SPC") "exec dunstctl context") - (define-key m (kbd ",") "exec dunstctl history-pop") - (define-key m (kbd "p") "exec dunstctl set-paused toggle") - m)) - -(defvar *user-bindings* - (let ((m (make-sparse-keymap))) - (define-key m (kbd "s") '*screenshot-bindings*) - (define-key m (kbd "n") '*notification-bindings*) - m)) - -(define-key *top-map* (kbd "s-c") '*user-bindings*) - -(restore-from-file "default") - -(define-frame-preference "Default" - (0 t nil :class "kitty") - (0 t nil :class "org.wezfurlong.wezterm") - (1 t nil :class "Emacs") - (3 t nil :class "firefox")) - -(define-frame-preference "teams" - (0 t t :class "teams-for-linux" :create t)) - -(sb-ext:run-program *shell-program* '("-c" "feh --bg-center ~/pictures/wallpaper/5120x1440/wallhaven-v9ydgl.jpg")) - -(swank:create-server :dont-close t) - -(which-key-mode) diff --git a/oni/home/services/stumpwm/stumpwm.lisp b/oni/home/services/stumpwm/stumpwm.lisp new file mode 100644 index 0000000..9a74c10 --- /dev/null +++ b/oni/home/services/stumpwm/stumpwm.lisp @@ -0,0 +1,161 @@ +(in-package :stumpwm-user) + +(require 'swank) + +(set-prefix-key (kbd "s-x")) + +(defvar *screen-locking-hook* nil + "Hook that gets called right before the screen gets locked.") + +(defvar *screen-unlocked-hook* nil + "Hook that gets called right after the screen is unlocked.") + +(defun run-screen-unlocked-hook (process) + "Run `*screen-unlocked-hook* if PROCESS' status is `:exited'." + (when (eq (sb-ext:process-status process) :exited) + (run-hook *screen-unlocked-hook*))) + +(defun vpn-connected-p () + (probe-file "/sys/class/net/vpn")) + +(defcommand lock-screen () () + "Lock the screen using i3lock. +Run `*screen-locking-hook*' before locking it and run `*screen-unlocked-hook*' +after it has been unlocked." + (run-hook *screen-locking-hook*) + (sb-ext:run-program + *shell-program* `("-c" ,(format nil "~a --nofork --color=000000" *locker-program*)) + :wait nil + :status-hook #'run-screen-unlocked-hook)) + +(defcommand raise-browser () () + "Open or show my browser" + (run-or-raise "firefox" '(:class "firefox|zen(-beta)?"))) + +(defcommand raise-emacs () () + "Open or show Emacs" + (run-or-raise "emacsclient -c" '(:class "Emacs"))) + +(defcommand raise-terminal () () + "Open or show my terminal" + (run-or-raise "kitty" '(:class "kitty|org\.wezfurlong\.wezterm"))) + +(define-key *top-map* (kbd "C-M-l") "lock-screen") +(define-key *top-map* (kbd "s-b") "raise-browser") +(define-key *top-map* (kbd "s-e") "raise-emacs") +(define-key *top-map* (kbd "s-t") "raise-terminal") +(define-key *top-map* (kbd "s-!") "exec rofi -show drun") +(define-key *top-map* (kbd "s-w") "exec rofi -show window") + +(define-remapped-keys + `(("teams-for-linux" + ;; Mute microphone in meetings. + ("XF86Launch6" . "C-S-m")) + ("[Ff]irefox" + ;; Generally cancel action. + ("XF86Launch6" . "ESC")) + ("[Ee]macs" + ;; Save document. + ("XF86Launch5" . ("C-x" "C-s")) + ;; Save some documents. + ("S-XF86Launch5" . ("C-x" "s")) + ;; Quit command. + ("XF86Launch6" . "C-g") + ;; Revert (reload) file. + ("XF86Launch7" . ("C-x" "x" "g"))) + ;; Portal: Revolution + ("revolution" + ;; Quick Save + ("XF86Launch5" . "F6") + ;; Quick Load + ("XF86Launch7" . "F7")))) + +(set-bg-color "#222424") +(set-border-color "#3f4242") +(set-fg-color "#bfbfbf") +(set-float-focus-color "#5b6161") +(set-float-unfocus-color "#3f4242") +(set-focus-color "#ff9800") +(set-unfocus-color "#3f4242") + +(setf *mode-line-background-color* "#111414" + *mode-line-foreground-color* "#bfbfbf" + *mode-line-border-width* 0 + *mode-line-pad-x* 10) +(setf *screen-mode-line-format* + (list "[ ^B%n^b ] " + "^[^(:bg \"#f17272\")^(:fg \"#222424\")[ " + '(:eval + (or (ignore-errors (window-title (current-window))) + "Unknown")) + " ]^]^>" + '(:eval + (if (vpn-connected-p) + "^*5^B[ VPN ]^b^n " + "")) + "[ %d ] ")) + +;;; Redefinition of the make mode-line window to add the Dock window type. +(defun stumpwm::make-mode-line-window (screen) + "Create a window suitable for a modeline." + (let ((window (xlib:create-window + :parent (screen-root screen) + :x 0 :y 0 :width 1 :height 1 + :background (stumpwm::alloc-color screen *mode-line-background-color*) + :border (stumpwm::alloc-color screen *mode-line-border-color*) + :border-width *mode-line-border-width* + ;; You can click the modeline + :event-mask (xlib:make-event-mask :button-press :exposure) + ;; these windows are not controlled by the window manager + :override-redirect :on))) + (xlib:change-property + window :_NET_WM_WINDOW_TYPE + (list (xlib:find-atom *display* :_NET_WM_WINDOW_TYPE_DOCK)) + :atom 32) + window)) + +(mode-line) + +;;; Screenshots + +(defvar *screenshot-bindings* + (let ((m (make-sparse-keymap))) + (define-key m (kbd "s") "exec flameshot gui") + (define-key m (kbd "c") "exec flameshot screen") + (define-key m (kbd "f") "exec flameshot full") + m)) + +(defvar *notification-bindings* + (let ((m (make-sparse-keymap))) + (define-key m (kbd "RET") "exec dunstctl action") + (define-key m (kbd "c") "exec dunstctl close") + (define-key m (kbd "S-c") "exec dunstctl close-all") + (define-key m (kbd "SPC") "exec dunstctl context") + (define-key m (kbd ",") "exec dunstctl history-pop") + (define-key m (kbd "p") "exec dunstctl set-paused toggle") + m)) + +(defvar *user-bindings* + (let ((m (make-sparse-keymap))) + (define-key m (kbd "s") '*screenshot-bindings*) + (define-key m (kbd "n") '*notification-bindings*) + m)) + +(define-key *top-map* (kbd "s-c") '*user-bindings*) + +(restore-from-file "default") + +(define-frame-preference "Default" + (0 t nil :class "kitty") + (0 t nil :class "org.wezfurlong.wezterm") + (1 t nil :class "Emacs") + (3 t nil :class "firefox")) + +(define-frame-preference "teams" + (0 t t :class "teams-for-linux" :create t)) + +(sb-ext:run-program *shell-program* '("-c" "feh --bg-center ~/pictures/wallpaper/5120x1440/wallhaven-v9ydgl.jpg")) + +(swank:create-server :dont-close t) + +(which-key-mode) -- cgit v1.3-2-g0d8e