Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

.stumpwmrc

By: a guest on Jul 5th, 2012  |  syntax: Lisp  |  size: 11.42 KB  |  hits: 110  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ;;;; -*- Mode: Lisp -*-
  2. ;;
  3. ;; vim: filetype=lisp
  4. ;;
  5. ;; Compiled using ANSI Common Lisp; not SBCL.  
  6.  ;; SBCL just made stumpwm run so slow, so I read that it actually runs
  7.  ;; faster with Clisp, so I immediately undertook the process of compiling
  8.  ;; stumpwm using Clisp.  
  9.  
  10.  
  11.  
  12. (in-package :stumpwm) ;; not sure what this does.  
  13. ;; Emergency Key Bindings
  14. ; key bindings that will be set up in case of a problem in this .*rc file.  
  15.  
  16. (define-key *top-map* (kbd "s-E") ; enables the user to interact with the openbox logout script
  17.             "exec oblogout")
  18. (define-key *top-map* (kbd "s-T") ; enables the user to start up an emergency session of a terminal
  19.             "exec terminator")
  20. (define-key *top-map* (kbd "C-M-F") ; the 'failsafe' method xD
  21.             "exec killall -s KILL stumpwm")
  22.  
  23.  
  24.  
  25.  
  26. ;; Modules
  27.  
  28. ;(load "/home/gm/opt/stumpwm/contrib/battery-portable.lisp")
  29. ;(load "/home/gm/opt/stumpwm/contrib/battery.lisp")
  30. ;(load "/home/gm/opt/stumpwm/contrib/mpd.lisp")
  31. ;(load "/home/gm/opt/stumpwm/contrib/productivity.lisp")
  32. ;(load "/home/gm/opt/stumpwm/contrib/app-menu.lisp")
  33.  
  34.  
  35. ;; Background setup
  36.  
  37. (run-shell-command "feh --bg-max ~/picts/'Washington DC'.jpg")
  38.  
  39. ;; Startup message
  40.  
  41. ;(setf *start-up* nil) (setf *startup-message* "Blarg")
  42.  
  43.  
  44. ;; Modeline
  45.  
  46. ;(setf *mode-line-foreground-color* "White")
  47. ;(setf *mode-line-background-color* "Black")
  48. ;(setf *mode-line-border-color* "Black")
  49. ;(setf *group-format* "%t")
  50. ;(setf *window-name-source* :title)
  51. ;(setf *window-format* "%c")
  52. ;(setf *screen-mode-line-format* (list " ^B^7*((^6*"
  53.  ;                                     '(:eval (run-shell-command "date '+%I:%M%P' |tr -d [:cntrl:]" t))
  54.  ;                                     "^7*) (^6*%B^7*)"
  55.  ;                                     " ^7*(^6%g"
  56.  ;                                     " ^7*(^6*%w^7*)))"))
  57. ;
  58. ;(if (not (head-mode-line (current-head)))
  59. ;  (toggle-mode-line (current-screen) (current-head)))
  60.  
  61. ;; Mouse and Fonts
  62.  
  63. (run-shell-command "xsetroot -cursor_name left_ptr")
  64. (setf *mouse-focus-policy* :click)
  65.  
  66. ;; Mouse Mappings
  67.  
  68. ;(defstruct mouse-event button state root-x root-y)
  69.  
  70. ;;; This is a little bit uggly but this prevent to redefine all the
  71. ;;; interactive-command way.
  72. ;(defvar *current-mouse-event* nil)  
  73.  
  74. ;(defvar *ignore-next-mouse-event* nil)
  75.  
  76. ;(defvar *frame-number-wins* nil)
  77.  
  78. ;;; Little helpers
  79. ;(defun define-mouse (map button command)
  80. ;  (define-key map button command))
  81.  
  82. ;(defun button (buttons)
  83. ;  (kbd buttons))
  84.  
  85. ;(define-key *top-map* (button "1") "der-men")
  86.  
  87. ;;; Default binding
  88. ;(defparameter *mouse-map*
  89. ;  (let ((m (make-sparse-keymap)))
  90. ;    (define-mouse m (button "1") "der-men")
  91. ;    m))
  92.  
  93.  
  94. ;; Windows an' Messages
  95.  
  96. ;None, yet.
  97.  
  98. ;; Taskbar
  99. (run-shell-command "tint2")
  100. ;(run-shell-command "sh :B/ensur-tint2.sh")
  101.  
  102.  
  103.  
  104. ;; Menu
  105.  
  106.     ; an experimental menu that uses plists.  
  107.  
  108. (defvar *exp-Books* (list :Common\ \Lisp\ General\ \Documentation "zathura /home/gm/docs/books/Lisp.pdf" :\On\ \Lisp "zathura /home/gm/docs/books/onlisp.pdf" :\The\ Collected\ Works\ of\ J.R.R.\ Tolkien "zathura /home/gm/docs/books/'The Collected Works of J.R.R. Tolkien.pdf'" :\The\ Tolkien\ Binder "zathura /home/gm/docs/books/Binder1.pdf" :Compaq\ Presario\ CQ60\ Maintenance\ \and\ Service\ Guide "zathura /home/gm/docs/books/maintenance.pdf"))                        
  109.  
  110. (defun *exp-menu* () (setf *exp-Main* (list :Books *exp-Books*)) )
  111.  
  112.     ; the regular app-menu that is all too available and un-explained.  
  113. (defparameter *app-menu* '(("Books"
  114.                             ;; a submenu
  115.                             ("Common Lisp General Documentation" "zathura /home/gm/docs/books/Lisp.pdf")
  116.  
  117.                             ("On Lisp" "zathura /home/gm/docs/books/onlisp.pdf")
  118.  
  119.                             ("The Collected Works of J.R.R. Tolkien" "zathura /home/gm/docs/books/'The Collected Works of J.R.R. Tolkien.pdf'")
  120.                             ("The Tolkien Binder" "zathura /home/gm/docs/books/Binder1.pdf")
  121.                             ("Compaq Presario CQ60 Maintenance and Service Guide" "zathura /home/gm/docs/books/maintenance.pdf"))
  122.                            ("All Programs"
  123.                             ("Accessories"
  124.                              ; the accessories submenu
  125.                              ("Xterm" "xterm")
  126.                              ("gvim" "gvim"))
  127.                             ("Internet"
  128.                              ("Chromium" "chromium"))
  129.                            
  130.                            
  131.                             )))
  132.  
  133. (define-key *top-map* (kbd "s-SPC") "der-men")
  134. ;(define-key
  135.  
  136. (defcommand der-men () ()
  137.             "parses the '*app-menu*' variable allowing users to access a menu."
  138.             (labels ((pick (options)
  139.                        (let ((selection (stumpwm::select-from-menu (current-screen) options "")))
  140.                          (cond
  141.                            ((null selection)
  142.                             (throw 'stumpwm::error "Okay."))
  143.                            ((stringp (second selection))
  144.                             (second selection))
  145.                            (t
  146.                             (pick (cdr selection)) ))) ))
  147.               (let ((choice (pick *app-menu*)))
  148.                 (run-shell-command choice)) ))
  149.  
  150.  
  151.  
  152. ;; Commands
  153.  
  154. ;(defcommand reloadrc () ()
  155. ;            "docstring"
  156. ;            "/bin/sh -c pkill -HUP stumpwm")
  157.  
  158.  
  159. ;(defcommand donothing () ()
  160. ;            "do nothing")
  161.  
  162.  
  163. ;(defcommand reinit ()
  164. ;             "exec sh bin/stump-restart.sh")
  165.  
  166. (defcommand reloadrc () ()
  167.             "docstring"
  168.             (run-commands "loadrc"))
  169.  
  170. ;(defun shift-windows-forward (frames win)
  171. ; (when frames
  172. ;          (let ((frame (car frames)))
  173. ;                 (shift-windows-forward (cdr frames)
  174. ;                                        (frame-window frame))
  175. ;                 (when win
  176. ;                         (pull-window win frame)))))
  177.  
  178. ;(defcommand rotate-windows () ()
  179. ;  (let* ((frames (group-frames (current-group)))
  180. ;           (win (frame-window (car (last frames)))))
  181. ;          (shift-windows-forward frames win)))
  182.  
  183.  
  184. ;(defcommand other-win () ()
  185. ;  (run-commands "other" "windows"))
  186.  
  187. (defcommand next-win () ()
  188.             "docstring"
  189.   (run-commands "next" "windows"))
  190.  
  191. (defcommand prev-win () ()
  192.             "docstring"
  193.   (run-commands "prev" "windows"))
  194.  
  195. ;(defcommand next-in-frame-win () ()
  196. ;  (run-commands "next-in-frame" "windows"))
  197.  
  198. ;(defcommand prev-in-frame-win () ()
  199. ;  (run-commands "prev-in-frame" "windows"))
  200.  
  201. ;; toggle between vertical split and horizontal split
  202. ;(defcommand toggle-split () ()
  203. ;  (let* ((group (current-group))
  204. ;         (cur-frame (tile-group-current-frame group))
  205. ;         (frames (group-frames group)))
  206. ;    (if (eq (length frames) 2)
  207. ;        (progn (if (or (neighbour :left cur-frame frames)
  208. ;                       (neighbour :right cur-frame frames))
  209. ;                   (progn
  210. ;                     (only)
  211. ;                     (vsplit))
  212. ;                 (progn
  213. ;                   (only)
  214. ;                   (hsplit))))
  215. ;      (message "Works only with 2 frames"))))
  216.  
  217.  
  218.  
  219.  
  220. ;(defun pinger-for-pingit (ip-or-fqdn) ; see my comment about pingit below.
  221. ;  (setf command (concatenate 'string "exec xterm -e" "ping" " " ip-or-fqdn "&&" "sh"))
  222. ;  (run-shell-command command)) ; I have no idea if this command even works or not.
  223.  
  224. ;(defcommand pingit (ip-or-fqdn)  
  225. ;            (if (eql nil ip-or-fqdn) (format t "variable is empty; variable must not be empty") (pinger-for-pingit ip-or-fqdn)))
  226. ;
  227. ;(defcommand mk-folder (folder-to-make folder-to-make-in)
  228. ;  (setf command (concatenate 'string "cd" " " folder-to-make-in))
  229. ;  (run-shell-command command)
  230. ;  (setf command (concatenate 'string "mkdir" " " folder-to-make))
  231. ;  (run-shell-command command)
  232. ;  (run-shell-command "send-notify 'folder made'"))
  233.  
  234.  
  235. ;; Groups
  236.  
  237. (grename "0")(gnewbg "1")(gnewbg "2")
  238. (gnewbg "3") (gnewbg "4") ;(gnewbg "4")(gnewbg "5")
  239.  
  240.  
  241.  
  242. ;; display the key sequence in process/progress
  243.  
  244. ;(defun key-press-hook (key-seq cmd)
  245.  ; (declare (ignore key))
  246.   ;(unless (eq *top-map* *resize-map*)
  247.    ; (let ((*message-window-gravity* :bottom-right))
  248.     ;  (message "Key sequence: ~a" (print-key-seq (reverse key-seq))))
  249.      ; (when (stringp cmd)
  250.       ;  ;; give 'em time to read it
  251.        ; (sleep 0.5))))
  252.  
  253. ;(defmacro replace-hook (hook fn)
  254. ;  `(remove-hook ,hook ,fn)
  255.  ; `(add-hook ,hook ,fn))
  256.  
  257. ;(replace-hook *key-press-hook* 'key-press-hook)
  258.  
  259.  
  260. ;; Super_L is supposed to be the windows key.. but it doesn't seem to work.  Oh, duh.  Windows key represented by the M in Meta
  261. ;;
  262.  
  263. ;; width in pixels given to the borders of windows with maxsize or ratio
  264. (setf *maxsize-border-width* 1)
  265.  
  266. ;; width in pixels given to th eborders of transient of pop-up windows
  267. (setf *transient-border-width* 1)
  268.  
  269. ;; width in pixels given to the borders of regular windows
  270. (setf *normal-border-width* 1)
  271.  
  272. ;; set the border color for focused windows
  273. (set-focus-color "black") ; `white' by default
  274.  
  275. (set-unfocus-color "yellow")
  276.  
  277. ;; <!-- Keybindings Section Start -->
  278.  
  279. ; symbolic keybindings
  280.  
  281. ;(define-keysym #xffe3 "Control_L")
  282. ;(define-keysym #xffeb "Super_L")
  283. ;(define-keysym #xff14 "Scroll_Lock")
  284. ;(define-keysym #xffe9 "Alt_L")  ;; I have specified which alt keys are which
  285. ;(define-keysym #xffe7 "Meta_L") ;; so that I can have certain keybindings
  286. ;(define-keysym #xffea "Alt_R")  ;; that will only be triggered if a certain
  287. ;(define-keysym #xffe8 "Meta_R") ;; sequence of modifier keys is used.  
  288. ;(define-keysym #xffe2 "Shift_R");; And so that Ix can have single-key bindings
  289. ;(define-keysym #xffe1 "Shift_L");; that only make use of a single modifier key
  290. ;; something which does not appear to be possible by default.  
  291.  
  292. (define-keysym #x1008ffa9 "XF86TouchpadToggle")
  293. ;(define-keysym #xffab "plus") ; this mapping defaults to "KP_Add")
  294. ;(define-keysym #xffad "minus") ; '' "KP_Subtract")
  295. ;(define-keysym #xffaa "asterisk") ; '' "KP_Multiply")
  296. ;(define-keysym #xffaf "slash") ; '' "KP_Divide")
  297.  
  298.  
  299.  
  300.  
  301. ; dmenu setup
  302.  
  303. (define-key *top-map* (kbd "Menu")
  304.             "exec dmenu_run -p \">_\" -nb '#191919'" );;-sb '#C0CC00' -sf '#000000' -nb '#191919' -nf 'grey' " )
  305. ; dmenfm setup
  306.  
  307. (define-key *top-map* (kbd "M-.")
  308.             "exec dmenfm")
  309.  
  310. ;; <!-- XF86 Function Keys Section Start -->
  311.  
  312. (define-key *top-map* (kbd "XF86Sleep") "exec xterm -e sudo pm-suspend")
  313.  
  314. (define-key *top-map* (kbd "XF86PowerOff")  "exec oblogout")
  315.  
  316. (define-key *top-map* (kbd "XF86AudioMute") "exec amixer set Master toggle")
  317.  
  318. (define-key *top-map* (kbd "XF86AudioLowerVolume") "exec amixer set Master 1%-")
  319.  
  320. (define-key *top-map* (kbd "XF86AudioRaiseVolume") "exec amixer set Master 1%+")
  321.  
  322. (define-key *top-map* (kbd "Print") "exec scrot")
  323.  
  324. ;(define-key *top-map* (kbd "XF86WLAN")
  325.  
  326. (define-key *top-map* (kbd "XF86HomePage") "exec chromium")
  327.  
  328. (define-key *top-map* (kbd "s-F6") "exec xscreensaver")
  329.  
  330. (define-key *top-map* (kbd "XF86TouchpadToggle") "exec sh ~/bin/chkpad.sh")
  331.  
  332.  
  333.  
  334.  
  335. ;; <!-- XF86 Section End -->
  336.  
  337. ;(define-key *top-map* (kbd "M-Tab")
  338. ;          "next-win")
  339.  
  340. ;(define-key *top-map* (kbd "M-ISO_Left_Tab")
  341. ;            "prev-win")
  342.  
  343. ;(define-key *top-map* (kbd "C-M-Delete")
  344. ;            "exec xterm -e htop")
  345.  
  346.  
  347. ;; <!-- Keybindings Section End -->
  348.  
  349.  
  350. ;;** Prefix Key
  351.  
  352. (set-prefix-key (kbd "s-x")) ; sets the prefix key to Windows-key + the letter 'x'.  The prefix key is Ctrl-t, by default. (it's a rather awkward key-binding, imo.)
  353.  
  354.  ;; EOF