Note: This is untested with StumpWM 0.9.3
I’ll get around to upgrading and posting any patches soonish.

; -*-lisp-*-

;;; 0.7

;; 2008/02/13

;; Replaced my MusicPD code with Patzy's as it's far more complete.

;; Using external 'unclutter' again.
;; (run-with-timer 5 5 'banish-pointer) became too annoying.

;; A few cleanups, mostly involving variable names.

;;; 0.6

;; 2008/01/11

;; Renamed (mpc) to (mpd-command).
;; Wrote that custom (current-song-info), and changed its name to (mpd-info).
;; It uses CL-PPCRE but we don't need to :use it, StumpWM already does.
;; And neither of them are likely portable, though it would be trivial to make them so if anyone cared.
;; Would have done it sooner but I was too busy passing my NREMT-B license exam.

;;; 0.5

;; 2008/01/09

;; Moved all the audio commands to un-numlocked keypad. Who uses those keys anyway?
;; Don't need the prefix key this way either, much more efficient.

;; Added Fluxbox-style alt-F# virtual desktop (group in StumpWM speak) switch. Modified from:
;; http://hcl-club.lu/svn/development/lisp/.stumpwmrc

;; Replaced call to (mode-line) with something more intelligent. Found at:
;; http://hcl-club.lu/svn/development/lisp/.stumpwmrc

;;; 0.4

;; 2008/01/09

;; Axed my custom (current-date). Set *format-time-string-default* and call (format-time-string) for the
;; modeline instead. Besides saving the overhead that an external application implies, it keeps it
;; from disappearing now. (current-song-info) will simply call (mpc-status) once it's rewritten.

;; All (mpc-*) functions other than (mpc-status) now use a direct socket connection to MPD instead of
;; using an external client. It could easily enough be made portable but right now it's CLISP specific.
;; Will write a custom (mpc-status) later. Yes, my StumpWM config is now its own MPD client. ;)

;; 2008/01/08

;; Note that CLISP seems to have a problem with my modeline. The exec portions stop getting run
;; seemingly at random, and sometimes comes back. Appears to be related to the fact that they
;; both use (run-shell-command). Attempting to use an MPD-affecting command makes it throw an
;; error regarding no child process and fails to have an effect on MPD, but restores the modeline
;; after which subsequent MPD keybindings work as expected. No, disabling current-song-info
;; doesn't fix it. Yes, it was happening before the previous two changes. No, it doesn't happen
;; with SBCL. May attempt to debug in a couple days.

;; Replace the monstrocity that (current-song-info) had become with its previous version.
;; Add keybinding to display mpc's default output instead.

;; Replace call to external 'unclutter' application with (run-with-timer 5 5 'banish-pointer).
;; Although, it goes off every 5 seconds regardless of mouse activity now. But I'm OK with that.
;; Fixing it would likely require a hook to mouse activity to reset the timer. I may look into it later.

;;; 0.3

;; 2008/01/07

;; Moved all the audio controls to their own keymap.
;; *screen-mode-line-format* now calls functions for its display instead of running the commands right there.
;; (current-song-info) is now a big hairy mess.
;; Enabled click to focus.
;; A couple tiny cleanups.

;;; 0.2

;; 2008/01/03

;; Broke color values out to variables.
;; Added currently playing song info to the modeline.
;; Got rid of the trailing newline from the date in the modeline.
;; Added some keybindings to control music playback. 

;;; 0.1

;; 2008/01/03

;; First release.

(in-package :stumpwm)

;; Include Patzy's MPD code.
(load "~/.stumpwm/contrib/mpd.lisp")

;;; Internal variable definitions.

(defparameter *foreground-color* "darkcyan")
(defparameter *background-color* "black")
(defparameter *border-color* *foreground-color*)

(setf *format-time-string-default* "%a %b %e %k:%M")

(setf *mpd-port* 2100)
(setf *mpd-volume-step* 10)

;;; Internal function definitions.

;; Found at:
;; http://en.wikipedia.org/wiki/User:Gwern/.stumpwmrc
(defun cat (&rest strings) "A shortcut for (concatenate 'string foo bar)."
  (apply 'concatenate 'string strings))

;;; Theme.

;; Window border colors.
(set-focus-color *foreground-color*)
(set-unfocus-color *background-color*)

;; Input box colors.
(set-fg-color *foreground-color*)
(set-bg-color *background-color*)
(set-border-color *border-color*)

;; Modeline colors.
(setf *mode-line-foreground-color* *foreground-color*)
(setf *mode-line-background-color* *background-color*)
(setf *mode-line-border-color* *border-color*)

;; Background.
(run-shell-command (cat "xsetroot -solid " *background-color*))

;;; Init stuff.

;; Make frames and windows 1-indexed.
;; See: http://lists.gnu.org/archive/html/stumpwm-devel/2006-08/msg00002.html
;; Found at: http://en.wikipedia.org/wiki/User:Gwern/.stumpwmrc
(setf *frame-number-map* "1234567890")
(setf *window-number-map* "1234567890") ; This doesn't actually do anything.

;; Rename the first group to Browse and create the other groups.
;; Found at: http://en.wikipedia.org/wiki/User:Gwern/.stumpwmrc
(setf (group-name (first (screen-groups (current-screen)))) "Browse")
(run-commands "gnewbg Edit" "gnewbg Term" "gnewbg Comms" "gnewbg Misc")

;; Change the prefix key
;; keycode 115 = F20 in ~/.xmodmaprc, 115 being the left "windows" key.
(set-prefix-key (kbd "F20"))

;; Set up X cursor and colors.
(run-shell-command (cat "xsetroot -cursor_name left_ptr -fg " *background-color* ; Cursor body
                                                      " -bg " *border-color*)) ; Cursor outline

;; Keep the X cursor out of the way.
(run-shell-command "unclutter -idle 5 -jitter 5 -root")

;; Configure and start the modeline. Colors are handled above.
(setf *mode-line-border-width* 1)
(setf *mode-line-pad-x* 1)
(setf *mode-line-pad-y* 1)
(setf *mode-line-position* :bottom)
(setf *mode-line-timeout* 10) ; Update every 10 seconds if nothing else has triggered it already.
(setf *screen-mode-line-format* (list "((%n %w) (" ; Current group and frames
                                      `(:eval (format-time-string))
                                      ") (%m))")) ; Patzy's MPD code.

;; Switch mode-line on only if needed. Found at:
;; http://hcl-club.lu/svn/development/lisp/.stumpwmrc
(if (not (head-mode-line (current-head)))
     (toggle-mode-line (current-screen) (current-head)))

;; Found this tidbit browsing the source. Defaults to :ignore
(setf *mouse-focus-policy* :click) ; I'm fucking lame.

;;; Keyboard shortcuts.

;; Fluxbox-style Alt-F# virtual desktop (group in StumpWM-speak) switching. Modified from:
;; http://hcl-club.lu/svn/development/lisp/.stumpwmrc
(dotimes (i 13)
  (unless (eq i 0) ; F0 is non-existant and will error.
    (define-key *top-map* (kbd (format nil "M-F~a" i)) (format nil "gselect ~a" i))))

;; Applications.
(define-key *root-map* (kbd "b") "exec firefox ")
(define-key *root-map* (kbd "e") "exec xemacs ")
(define-key *root-map* (kbd "c") (cat "exec urxvt -fg " *foreground-color*
                                                " -bg " *background-color*
                                                " -pr " *foreground-color*
                                                " +sb "))

;; Audio controls, uses un-numlocked keypad.
;; Some keys duplicated, not sure which I prefer yet.
(define-key *top-map* (kbd "KP_Up")       "mpd-volume-up")
(define-key *top-map* (kbd "KP_Add")      "mpd-volume-up") ; Redundant
(define-key *top-map* (kbd "KP_Down")     "mpd-volume-down")
(define-key *top-map* (kbd "KP_Subtract") "mpd-volume-down") ; Redundant
(define-key *top-map* (kbd "KP_Left")     "mpd-prev")
(define-key *top-map* (kbd "KP_Right")    "mpd-next")
(define-key *top-map* (kbd "Num_Lock")    "mpd-toggle-pause") ; The light indicates play/pause ;)


  1. _Thank you_ for posting this. You have saved my skin and made bending stumpwm to my will very easy.


    Comment by Nicholas E. May | March 7, 2008 | Reply

  2. What is new is the toolbox that hybrid organizations draw from. ,

    Comment by Settor50 | October 22, 2009 | Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: