dotfiles

shared miscellaneous configuration files between my systems
git clone git://git.eonn.xyz/dotfiles.git
Log | Files | Refs

commit fd6c0d2e6011d42e30532f5d02bcf3e2c9ea6fab
parent 982e4e4d4cd5b84d3b686200c7a83f150953dd84
Author: Ian Ressa <ian@eonn.xyz>
Date:   Sun, 11 Sep 2022 23:10:14 -0400

[stumpwm] move some init functions to other lisp files and add a function to load them

Diffstat:
A.stumpwm.d/binds.lisp | 72++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
M.stumpwm.d/init.lisp | 101++++++++++++-------------------------------------------------------------------
A.stumpwm.d/mode-line.lisp | 17+++++++++++++++++
3 files changed, 104 insertions(+), 86 deletions(-)

diff --git a/.stumpwm.d/binds.lisp b/.stumpwm.d/binds.lisp @@ -0,0 +1,72 @@ +;; -*-lisp-*- + +(in-package :stumpwm) + +(set-prefix-key (kbd "C-t")) + +(defcommand toggle-float () () + (if (typep (current-window) 'float-window) (unfloat-this) (float-this))) + +(defcommand terminal-raise () () + (run-or-raise "xfce4-terminal" '(:class "xfce4-terminal"))) + +(defcommand shutdown () () + "Shutdown the computer via elogind." + (run-shell-command "/home/ian/bin/session-shutdown")) + +(defcommand reboot () () + "Reboot the computer via elogind." + (run-shell-command "/home/ian/bin/session-reboot")) + +(defcommand suspend () () + "Suspend the computer via elogind." + (run-shell-command "/home/ian/bin/session-suspend")) + +(defcommand lock-screen () () + "Lock the screen however I've decided to do that." + (run-shell-command "/home/ian/bin/lockscreen.sh")) + +(defcommand launch-polybar () () + (run-shell-command "/home/ian/bin/polybar-launch.sh")) + +(defcommand shutdown-confirm () () + "Prompt the user to confirm shutdown via elogind." + (if (y-or-n-p (format nil "~@{~a~^~%~}" + "You are about to shutdown the computer." + "Really ^1^Bshutdown^b^n?" + "^B^6Confirm?^n ")) + (shutdown) + (xlib:unmap-window (screen-message-window (current-screen))))) + +(defcommand reboot-confirm () () + "Prompt the user to confirm reboot via elogind." + (if (y-or-n-p (format nil "~@{~a~^~%~}" + "You are about to reboot the computer." + "Really ^1^Breboot^b^n?" + "^B^6Confirm?^n ")) + (reboot) + (xlib:unmap-window (screen-message-window (current-screen))))) + +;;;; Unbind defaults +(undefine-key *root-map* (kbd "C-e")) +(undefine-key *root-map* (kbd "C-c")) + +;;;; Root map +(define-key *root-map* (kbd "c") "exec xfce4-terminal") +(define-key *root-map* (kbd "C-TAB") "exec rofi -show run") +(define-key *root-map* (kbd "C-c") "terminal-raise") +(define-key *root-map* (kbd "l") "toggle-my-mode-line") +(define-key *root-map* (kbd "C-space") "toggle-float") +(define-key *root-map* (kbd "SunPrint_Screen") "exec flameshot gui") +(define-key *root-map* (kbd "End") "lock-screen") +(define-key *root-map* (kbd "C-End") "suspend") +(define-key *root-map* (kbd "ESC") "shutdown-confirm") +(define-key *root-map* (kbd "S-ESC") "reboot-confirm") + +;;;; Brightness and Sound +(define-key *top-map* (kbd "XF86MonBrightnessUp") "exec light -A 10") +(define-key *top-map* (kbd "XF86MonBrightnessDown") "exec light -U 10") +(define-key *top-map* (kbd "XF86AudioMute") "exec pactl set-sink-mute 0 toggle") +(define-key *top-map* (kbd "XF86AudioLowerVolume") "exec pactl set-sink-volume 0 -5%") +(define-key *top-map* (kbd "XF86AudioRaiseVolume") "exec pactl set-sink-volume 0 +5%") +(define-key *top-map* (kbd "XF86AudioMicMute") "exec pactl set-source-mute 1 toggle") diff --git a/.stumpwm.d/init.lisp b/.stumpwm.d/init.lisp @@ -2,68 +2,6 @@ (in-package :stumpwm) -(defun battery-mode-line-string () - (concatenate 'string - (with-open-file (stream "/sys/class/power_supply/BAT0/capacity" :if-does-not-exist nil) - (read-line stream nil)) - "% battery")) - -(setf *screen-mode-line-format* - (list "%v " "^> | " "%d")) - -(setf *mode-line-timeout* '1) - -(dolist (h (screen-heads (current-screen))) - (enable-mode-line (current-screen) h t)) - -(defcommand shutdown-confirm () () - "Prompt the user to confirm shutdown via elogind." - (if (y-or-n-p (format nil "~@{~a~^~%~}" - "You are about to shutdown the computer." - "Really ^1^Bshutdown^b^n?" - "^B^6Confirm?^n ")) - (shutdown) - (xlib:unmap-window (screen-message-window (current-screen))))) - -(defcommand reboot-confirm () () - "Prompt the user to confirm reboot via elogind." - (if (y-or-n-p (format nil "~@{~a~^~%~}" - "You are about to reboot the computer." - "Really ^1^Breboot^b^n?" - "^B^6Confirm?^n ")) - (reboot) - (xlib:unmap-window (screen-message-window (current-screen))))) - -(defcommand shutdown () () - "Shutdown the computer via elogind." - (run-shell-command "/home/ian/bin/session-shutdown")) - -(defcommand reboot () () - "Reboot the computer via elogind." - (run-shell-command "/home/ian/bin/session-reboot")) - -(defcommand suspend () () - "Suspend the computer via elogind." - (run-shell-command "/home/ian/bin/session-suspend")) - -(defcommand lock-screen () () - "Lock the screen however I've decided to do that." - (run-shell-command "/home/ian/bin/lockscreen.sh")) - -(defcommand toggle-my-mode-line () () - (stumpwm:toggle-mode-line (stumpwm:current-screen) - (stumpwm:current-head) - (list "%v " "^> | " "%d"))) - -(defcommand launch-polybar () () - (run-shell-command "/home/ian/bin/polybar-launch.sh")) - -(defcommand toggle-float () () - (if (typep (current-window) 'float-window) (unfloat-this) (float-this))) - -(defcommand terminal-raise () () - (run-or-raise "xfce4-terminal" '(:class "xfce4-terminal"))) - ;; scrolling in GTK3+ applications (setf (getenv "GDK_CORE_DEVICE_EVENTS") "1") @@ -75,31 +13,22 @@ (gnewbg-dynamic "Workspace 4 (dynamic)") (gnewbg-float "Workspace 5 (float)") -(setf *mode-line-timeout* '1) -(toggle-my-mode-line) - (run-shell-command "xsetroot -cursor_name left_ptr") (setf *mouse-focus-policy* :click) -(set-prefix-key (kbd "C-t")) - -(undefine-key *root-map* (kbd "C-e")) -(undefine-key *root-map* (kbd "C-c")) - -(define-key *root-map* (kbd "c") "exec xfce4-terminal") -(define-key *root-map* (kbd "C-TAB") "exec rofi -show run") -(define-key *root-map* (kbd "C-c") "terminal-raise") -(define-key *root-map* (kbd "l") "toggle-my-mode-line") -(define-key *root-map* (kbd "C-space") "toggle-float") -(define-key *root-map* (kbd "SunPrint_Screen") "exec flameshot gui") -(define-key *root-map* (kbd "End") "lock-screen") -(define-key *root-map* (kbd "C-End") "suspend") -(define-key *root-map* (kbd "ESC") "shutdown-confirm") -(define-key *root-map* (kbd "S-ESC") "reboot-confirm") -(define-key *top-map* (kbd "XF86MonBrightnessUp") "exec light -A 10") -(define-key *top-map* (kbd "XF86MonBrightnessDown") "exec light -U 10") -(define-key *top-map* (kbd "XF86AudioMute") "exec pactl set-sink-mute 0 toggle") -(define-key *top-map* (kbd "XF86AudioLowerVolume") "exec pactl set-sink-volume 0 -5%") -(define-key *top-map* (kbd "XF86AudioRaiseVolume") "exec pactl set-sink-volume 0 +5%") -(define-key *top-map* (kbd "XF86AudioMicMute") "exec pactl set-source-mute 1 toggle") +(defvar *init-directory* + (directory-namestring + (truename (merge-pathnames (user-homedir-pathname) + ".stumpwm.d"))) + "A directory with initially loaded files.") + +(defun load-file (filename) + (let ((file (merge-pathnames (concat filename ".lisp") + *init-directory*))) + (if (probe-file file) + (load file) + (format *error-output* "File '~a' doesn't exist." file)))) + +(load-file "binds") +(load-file "mode-line") diff --git a/.stumpwm.d/mode-line.lisp b/.stumpwm.d/mode-line.lisp @@ -0,0 +1,17 @@ +;; -*-lisp-*- + +(in-package :stumpwm) + +(defun battery-mode-line-string () + (concatenate 'string + (with-open-file (stream "/sys/class/power_supply/BAT0/capacity" :if-does-not-exist nil) + (read-line stream nil)) + "% battery")) + +(setf *screen-mode-line-format* + (list "%v " "^> | " "%d")) + +(setf *mode-line-timeout* '1) + +(dolist (h (screen-heads (current-screen))) + (enable-mode-line (current-screen) h t))