Skip to content

Instantly share code, notes, and snippets.



Last active Sep 5, 2020
What would you like to do?
;; -*-lisp-*-
;; Stumpwm user definitions
(in-package :stumpwm)
(defun cat (&rest strings) ; "Concatenates strings, like the Unix command 'cat'. A shortcut for (concatenate 'string foo bar)."
(apply 'concatenate 'string strings))
(set-font "-*-terminus-medium-r-normal-*-12-*-*-*-*-*-iso10646-1")
(set-prefix-key (kbd "C-t"))
;;; Variables
;; suppress the message StumpWM displays when it starts. Set it to NIL
(setf *startup-message* "Never Stop Hacking!"
*mouse-focus-policy* :sloppy ;; :click, :ignore, :sloppy
;;Set the message and input box to the bottom right. This way it overlaps with mode-line.
*message-window-gravity* :bottom-left
*input-window-gravity* :bottom-left
*frame-number-map* "123qwe"
*window-number-map* "123qwe")
;;; Window Appearance
(setf *normal-border-width* 0
*maxsize-border-width* 0
*transient-border-width* 1
*window-border-style* :thick) ; :thick :thin :tight :none
;;;; The Mode Line
(setf *mode-line-background-color* "DarkRed"
*mode-line-foreground-color* "White"
*mode-line-border-color* "White"
*mode-line-timeout* 1
*mode-line-screen-position* :top
*window-format* "^B^8*%n%s%m%30t :: ^7*"
*group-format* "%t")
(setf *screen-mode-line-format*
(list '(" " (:eval (run-shell-command "date '+%R, %F %a'|tr -d [:cntrl:]" t)))))
;; '(" | " (:eval (run-shell-command "sed '/MemTotal/!d; s/\w*:\s*//g' < /proc/meminfo" t)))
;; '(" | " (:eval (run-shell-command "sed '/MemFree/!d; s/\w*:\s*//g' < /proc/meminfo" t)) " | %W")))
(defun update-mode-line () "Update the mode-line sooner than usual."
(let ((screen (current-screen)))
(when (screen-mode-line screen)
(redraw-mode-line-for (screen-mode-line screen) screen))))
;; turn on/off the mode line for the current screen only.
(if (not (head-mode-line (current-head)))
(toggle-mode-line (current-screen) (current-head)))
;; Create groups
(defvar group-names "123qwe")
(dotimes (i 6)
(define-key *top-map* (kbd (format nil "s-~a" (char group-names i)))
(format nil "gselect ~a" (1+ i)))
(define-key *top-map* (kbd (format nil "s-C-~a" (char group-names i)))
(format nil "gmove ~a" (1+ i))))
(defmacro make-groups (&rest names)
(let ((ns (mapcar #'(lambda (n) (cat "gnew " n)) names)))
`(run-commands ,@ns)))
(make-groups "2" "3" "q" "w" "e")
(run-commands "gselect 1" "grename 1")
;; define commands
(defcommand firefox () ()
"Run or switch to firefox."
(run-or-raise "firefox" '(:class "Firefox")))
(defcommand conkeror () ()
"Run or switch to conkeror."
(run-or-raise "conkeror" '(:class "Conkeror")))
(defcommand reinit () ()
(run-commands "reload" "loadrc"))
(defcommand dmenu () ()
(run-shell-command "dmenu_run"))
;; define keys
(defmacro defkey-top (key cmd)
`(define-key *top-map* (kbd ,key) ,cmd))
(defmacro defkeys-top (&rest keys)
(let ((ks (mapcar #'(lambda (k) (cons 'defkey-top k)) keys)))
`(progn ,@ks)))
(defmacro defkey-root (key cmd)
`(define-key *root-map* (kbd ,key) ,cmd))
(defmacro defkeys-root (&rest keys)
(let ((ks (mapcar #'(lambda (k) (cons 'defkey-root k)) keys)))
`(progn ,@ks)))
("f" "firefox")
("c" "conkeror")
("e" "emacs")
("t" "exec thunar")
("k" "exec keepassx")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment