;-*-lisp-*- ;; Start SWANK (require 'swank) (swank:create-server :dont-close t) (in-package :stumpwm) ;;;; Custom Stumpwm commands (defun shell-command (command) "Run a shell command and display output to screen. This must be used in a functional side-effects-free style! If a program does not exit, Stumpwm might hang!" (check-type command string) (echo-string (current-screen) (run-shell-command command t))) (define-stumpwm-command "top" () "Display a single 'top' frame." (shell-command "top -b -n 1 -c -d 1")) (defcommand firefox () () "Start/Switchto Firefox." (run-or-raise "firefox" '(:class "Firefox"))) (defcommand conkeror () () "Start/Switchto Conkeror." (run-or-raise "conkeror" '(:class "Conkeror"))) (define-stumpwm-command "toggle-touchpad" () "Toggle the laptop touchpad on/off. Need to have set 'Option SHMConfig' for Synaptics Touchpad device in xorg.conf." (let ((state (run-shell-command "synclient -l | grep TouchpadOff | awk '{ print $3 }'" t))) (case (string= (subseq state 0 1) "1") (t (shell-command "synclient TouchpadOff=0")) (otherwise (shell-command "synclient TouchpadOff=1") (banish-pointer))))) (define-stumpwm-command "refocus-conkeror" () "Re-focus the conkeror buffer. Useful when you want to escape Flash without a mouse." (shell-command "conkeror -batch -e 'if (w=window_watcher.activeWindow) { unfocus(w.buffers.current); w.minibuffer.message(\"focus regained\"); }'")) (define-key *root-map* (kbd "f") "firefox") (define-key *root-map* (kbd "x") "conkeror") (define-key *root-map* (kbd "^") "top") (define-key *root-map* (kbd "T") "toggle-touchpad") (define-key *root-map* (kbd "X") "refocus-conkeror") ;;;; Custom display setup ;; Background - SBCL's SAVE-Lisp-AND-DIE (run-shell-command "xsetbg -border black -fullscreen ~/docs/images/slad.gif") ;; Turn off Touchpad initially (shell-command "synclient TouchpadOff=1") ;; Get rid of cursor (banish-pointer) ;; Display class in windows list ("C-t w") (setf stumpwm:*window-format* "%n%s%t %c") ;; Mode line at bottom with battery, windows, groups, date/time ;; (but only when "C-t" pressed) (load "/home/bc/lisp/battery.lisp") (setf *mode-line-background-color* "grey20" *mode-line-foreground-color* "grey80" *mode-line-border-color* "grey80" *mode-line-timeout* 1 *mode-line-position* :bottom *window-format* "<%n%s%m%30c>" *screen-mode-line-format* (list "%b | [%W] | {%g} | " '(:eval (run-shell-command "date +\"%T %Y-%m-%d\" | tr -d '[:cntrl:]'" t)))) ;; Also, set the message and input box to the bottom right so it will ;; overlap the mode-line. (setf *message-window-gravity* :bottom-right) (setf *input-window-gravity* :bottom-right) ;; Change the Stumpwm escape key (run-shell-command "xmodmap -e \'keycode 115 = F20\'") (set-prefix-key (kbd "F20")) ;;;; Hooks (defun toggle-mode-line-hook (key key-seq cmd) (declare (ignore key key-seq cmd)) (mode-line)) (defun show-key-pressed-hook (key key-seq cmd) (declare (ignore key)) (unless (eq *top-map* *resize-map*) (let ((*message-window-gravity* :bottom-right)) (message "Key sequence: ~A~%==> ~A" (print-key-seq (reverse key-seq)) cmd)))) (defmacro replace-hook (hook fn) `(remove-hook ,hook ,fn) `(add-hook ,hook ,fn)) (replace-hook *key-press-hook* 'toggle-mode-line-hook) ;(replace-hook *key-press-hook* 'show-key-pressed-hook)