summaryrefslogtreecommitdiffstats
path: root/.stumpwmrc
diff options
context:
space:
mode:
Diffstat (limited to '.stumpwmrc')
-rw-r--r--.stumpwmrc146
1 files changed, 92 insertions, 54 deletions
diff --git a/.stumpwmrc b/.stumpwmrc
index bdc7395..386da9c 100644
--- a/.stumpwmrc
+++ b/.stumpwmrc
@@ -3,38 +3,29 @@
(in-package :stumpwm)
+(require 'cl-ppcre)
+
+(defmacro elisp (&body body)
+ "Run BODY through emacsclient."
+ `(sb-ext:run-program
+ "/usr/bin/emacsclient"
+ '("-e" ,(string-downcase (format nil "~S" (cons 'progn body))))
+ :wait nil))
+
;; Naquadah
(defun colour (key)
- (let ((colours (list :aluminium-1 #xeeeeec
- :aluminium-2 #xd3d7cf
- :aluminium-3 #xbabdb6
- :aluminium-4 #x888a85
- :aluminium-5 #x555753
- :aluminium-6 #x2e3436
- :butter-1 #xfce94f
- :butter-2 #xedd400
- :butter-3 #xc4a000
- :orange-1 #xfcaf3e
- :orange-2 #xf57900
- :orange-3 #xce5c00
- :chocolate-1 #xe9b96e
- :chocolate-2 #xc17d11
- :chocolate-3 #x9f5902
- :chameleon-1 #x8ae234
- :chameleon-2 #x73d216
- :chameleon-3 #x4e9a06
- :sky-blue-1 #x729fcf
- :sky-blue-2 #x3465a4
- :sky-blue-3 #x204a87
- :plum-1 #xad7fa8
- :plum-2 #x75507b
- :plum-3 #x5c3566
- :scarlet-red-1 #xef2929
- :scarlet-red-2 #xcc0000
- :scarlet-red-3 #xa40000
- :background #x252a2b
- :black #x0c191c
- :cyan "cyan3")))
+ (let ((colours (list :lblack #xeeeeec :dblack #x111113
+ :lwhite #xa5a5a4 :dwhite #x222224
+ :lred #xbf6d6d :dred #x744a4a
+ :lorange #xbfa47d :dorange #x73634a
+ :lyellow #xb2bf6d :dyellow #x6b734a
+ :lgreen #x8abf6d :dgreen #x52734a
+ :lturquoise #x7dbf97 :dturquoise #x4a735b
+ :lcyan #x7dbfbf :dcyan #x4a7373
+ :lblue #x6d97bf :dblue #x4a5b73
+ :lpurple #x8a7dbf :dpurple #x524a73
+ :lmagenta #xb27dbf :dmagenta #x6b4a73
+ :lpink #xbf6da4 :dpink #x734a63)))
(getf colours key)))
(defvar *conkeror-program* "conkeror"
@@ -47,6 +38,12 @@
"The executable to run to start i3lock.")
(defvar *urxvt-program* "urxvt"
"The executable to run to start URxvt.")
+(defvar *lock-screen-hook* nil
+ "Hook run right before the screen gets locked.")
+(defvar *screen-unlocked-hook* nil
+ "Hook run right after the screen is unlocked.")
+(defvar *mpd-was-playing-p* nil
+ "Indicator of whether or not MPD was playing when it was paused.")
(defun get-mail-count (mailbox &optional (inbox "inbox"))
"Check how many new messages there are in MAILBOX."
@@ -55,6 +52,38 @@
(format nil "/home/slash/documents/mail/~A/~A/new/*.*"
mailbox inbox))))
+(defun mpd-playing-p ()
+ "Check if MPD is currently in the playing state."
+ (and (cl-ppcre:scan
+ "\\n\\[playing\\]"
+ (with-output-to-string (status)
+ (sb-ext:run-program "/usr/bin/mpc" '() :output status)))
+ t))
+
+(defun set-jabber-away ()
+ "Tell emacs to set jabber to away presence."
+ (elisp
+ (when (and (fboundp 'jabber-send-away-presence)
+ *jabber-connected*)
+ (jabber-send-away-presence))))
+
+(defun set-jabber-online ()
+ "Tel emacs to set jabber to online presence."
+ (elisp
+ (when (and (fboundp 'jabber-send-default-presence)
+ *jabber-connected*)
+ (jabber-send-default-presence))))
+
+(defun mpd-pause ()
+ "Pause MPD playback."
+ (when (setf *mpd-was-playing-p* (mpd-playing-p))
+ (sb-ext:run-program "/usr/bin/mpc" '("pause") :wait nil)))
+
+(defun mpd-play ()
+ "Resume MPD playback."
+ (when *mpd-was-playing-p*
+ (sb-ext:run-program "/usr/bin/mpc" '("play") :wait nil)))
+
(defcommand run-emacs () ()
"Open Emacs"
(run-shell-command *emacs-program*))
@@ -87,31 +116,38 @@
"Open URxvt"
(run-or-raise *urxvt-program* '(:class "URxvt")))
-(defcommand run-i3lock () ()
- "Lock screen"
- (run-shell-command *i3lock-program*))
-
-(set-bg-color (colour :background))
-(set-border-color (colour :aluminium-6))
-(set-fg-color (colour :aluminium-1))
-(set-float-focus-color (colour :black))
-(set-float-unfocus-color (colour :aluminium-6))
-(set-focus-color (colour :black))
+(defun run-stumpwm-hook-on-exit (process)
+ "Run `*screen-unlocked-hook*' if PROCESS' status is `:exited'."
+ (when (eq (sb-ext:process-status process) :exited)
+ (run-hook *screen-unlocked-hook*)))
+
+(defcommand lock-screen () ()
+ "Lock the screen using i3lock. Run *lock-screen-hook* before locking
+it and run *screen-unlocked-hook* after it has been unlocked."
+ (run-hook *lock-screen-hook*)
+ (sb-ext:run-program
+ "/usr/bin/i3lock" '("-n" "-c" "000000") :wait nil
+ :status-hook #'run-stumpwm-hook-on-exit))
+
+(set-bg-color (colour :dwhite))
+(set-border-color (colour :lwhite))
+(set-fg-color (colour :lblack))
+(set-float-focus-color (colour :dblack))
+(set-float-unfocus-color (colour :dwhite))
+(set-focus-color (colour :dblack))
(set-font "-*-tamsyn-medium-r-normal-*-17-*-*-*-*-0-iso8859-1")
-(set-unfocus-color (colour :aluminium-6))
-(set-win-bg-color (colour :background))
+(set-unfocus-color (colour :dwhite))
+(set-win-bg-color (colour :dwhite))
-(setf *colors* (mapcar #'colour '(:black :scarlet-red-1 :chameleon-1
- :butter-1 :sky-blue-1 :plum-1 :cyan
- :aluminium-1)))
+(setf *colors* (mapcar #'colour '(:lwhite :lred :lgreen :lyellow :lblue
+ :lmagenta :lcyan :lblack)))
(setf *input-window-gravity* :bottom-left)
(setf *message-window-gravity* :top-right)
-(setf *mode-line-background-color* (colour :background))
-(setf *mode-line-border-color* (colour :aluminium-6))
-(setf *mode-line-foreground-color* (colour :aluminium-1))
+(setf *mode-line-background-color* (colour :dwhite))
+(setf *mode-line-border-color* (colour :dwhite))
+(setf *mode-line-foreground-color* (colour :lblack))
(setf *shell-program* (getenv "SHELL"))
(setf *transient-border-width* 1)
-(setf *window-format* "%m%50t")
(setf *window-border-style* :thin)
(setf *screen-mode-line-format*
(list "[%n]"
@@ -120,14 +156,16 @@
(get-mail-count "ryuslash.org")
(get-mail-count "gmail")
(get-mail-count "aethon")
- (get-mail-count "ninthfloor")))
- '(:eval
- (format-expand *window-formatters* *window-format*
- (current-window)))))
+ (get-mail-count "ninthfloor")))))
+
+(add-hook *lock-screen-hook* 'set-jabber-away)
+(add-hook *lock-screen-hook* 'mpd-pause)
+(add-hook *screen-unlocked-hook* 'set-jabber-online)
+(add-hook *screen-unlocked-hook* 'mpd-play)
(set-prefix-key (kbd "C-z"))
-(define-key *top-map* (kbd "C-M-l") "run-i3lock")
+(define-key *top-map* (kbd "C-M-l") "lock-screen")
(define-key *root-map* (kbd "c") "raise-urxvt")
(define-key *root-map* (kbd "C") "run-urxvt")