dotfiles/stumpwm/.stumpwm.d/init.lisp

108 lines
3.6 KiB
Common Lisp

(in-package :stumpwm)
;; Start up a swank server for happy SLIME hacking
(require :swank)
(swank-loader:init)
(swank:create-server :port 4004
:style swank:*communication-style*
:dont-close t)
;; StumpWM configs
(setq *message-window-gravity* :center
*input-window-gravity* :center
*window-border-style* :thin
*message-window-padding* 10
*maxsize-border-width* 5
*normal-border-width* 5
*transient-border-width* 2
stumpwm::*float-window-border* 2
stumpwm::*float-window-title-height* 5
*mouse-focus-policy* :click)
;; Sudo
(defcommand stumpwm-password (prompt) ((:string "prompt: "))
"Prompts the user for a password"
(read-one-line (current-screen) prompt :password t))
(defmacro run-sudo-command (cmd &optional collect-output-p)
`(run-shell-command
(format nil "SUDO_ASKPASS=~~/bin/stumpwm-sudo.sh sudo -A ~S" ,cmd)
,collect-output-p))
;; Commands
(defcommand shutdown () ()
(when (y-or-n-p (format nil "~@{~a~^~%~}"
"You are about to shut down the computer."
"Really ^1^Bshutdown^b^n?"
"^B^6Confirm?^n "))
(run-shell-command "shutdown now")))
(defcommand firefox () ()
(run-or-raise "firefox" '(:class "firefox")))
(defcommand lock () ()
(run-shell-command
(concatenate 'string
"i3lockmore "
"--image-fill ~/Pictures/space-background.png "
"-n "
"--lock-icon ~/Pictures/lock.png")))
(defcommand battery () ()
(let ((capacity
(string-trim
'(#\newline)
(run-shell-command
"cat /sys/class/power_supply/BAT0/capacity"
t))))
(echo-string (current-screen)
(format nil "Battery: ~A%" capacity))))
(defcommand caps->escape () ()
(run-shell-command "setxkbmap -option caps:escape"))
(defcommand org-capture () ()
(run-shell-command "emacsclient -a '' -e '(make-orgcapture-frame)'"))
(defcommand background-random () ()
(run-shell-command (concatenate 'string
"feh --bg-scale "
"\"/home/jdormit/Dropbox/pictures/desktop/"
"$(ls /home/jdormit/Dropbox/pictures/desktop | shuf -n 1)\"")))
;; Keybindings
(define-key stumpwm:*root-map* (kbd "C-f") "firefox")
(define-key stumpwm:*root-map* (kbd "d") "exec rofi -show drun")
(define-key stumpwm:*root-map* (kbd "w") "exec rofi -show window")
(define-key stumpwm:*root-map* (kbd "P") "exec passmenu")
(define-key stumpwm:*root-map* (kbd "N") "exec networkmanager_dmenu")
(define-key stumpwm:*root-map* (kbd "M") "exec ~/bin/monitor_layout.sh")
(define-key stumpwm:*root-map* (kbd "L") "lock")
(define-key stumpwm:*root-map* (kbd "b") "battery")
(define-key stumpwm:*root-map* (kbd "C-o") "org-capture")
(define-key stumpwm:*root-map* (kbd "C-q") "quit-confirm")
(define-key *top-map* (kbd "M-TAB") "pull-hidden-next")
(define-key *top-map* (kbd "XF86MonBrightnessDown") "exec light -U 5")
(define-key *top-map* (kbd "XF86MonBrightnessUp") "exec light -A 5")
(define-key *top-map* (kbd "XF86AudioRaiseVolume") "exec pavolume volup")
(define-key *top-map* (kbd "XF86AudioLowerVolume") "exec pavolume voldown")
(define-key *top-map* (kbd "XF86AudioMute") "exec pavolume mutetoggle")
;; X Windows config
(run-shell-command "xsetroot -cursor_name left_ptr")
(run-shell-command "setxkbmap -option caps:escape")
;; UI
(ql:quickload "clx-truetype")
(load-module "ttf-fonts")
(xft:cache-fonts)
(set-font
(make-instance 'xft:font :family "IBM Plex Mono" :subfamily "Regular" :size 12))
(set '*message-window-padding* 4)
;; Desktop background
(run-commands "background-random")
;; Notifications via Dunst
(run-shell-command "/usr/bin/dunst")