Skip to content

Instantly share code, notes, and snippets.

@YellowApple
Created October 28, 2015 14:37
Show Gist options
  • Save YellowApple/3ddac133d36c44c5c037 to your computer and use it in GitHub Desktop.
Save YellowApple/3ddac133d36c44c5c037 to your computer and use it in GitHub Desktop.
.stumpwmrc and friends
(in-package :stumpwm)
; fucking hackery
;; fucking swank
(require :swank)
(swank-loader:init)
(swank:create-server :port 4004
:style swank:*communication-style*
:dont-close t)
;; fucking contrib shit
(require 'clx-truetype) ; I hope this is right
;;-----BEGIN HACKERY-----
(export '(font-exists-p open-font close-font font-ascent font-descent text-line-width draw-image-glyphs))
;;; "ttf-fonts" goes here. Hacks and glory await!
;;;; TTF fonts
(defmethod font-exists-p ((font xft:font))
;; if we can list the font then it exists
t)
(defmethod open-font ((display xlib:display) (font xft:font))
font)
(defmethod close-font ((font xft:font)))
(defmethod font-ascent ((font xft:font))
(xft:font-ascent (screen-number (current-screen)) font))
(defmethod font-descent ((font xft:font))
(xft:font-descent (screen-number (current-screen)) font))
(defmethod font-height ((font xft:font))
(+ (font-ascent font)
(- (font-descent font))))
(defmethod text-line-width ((font xft:font) text &rest keys &key (start 0) end translate)
(declare (ignorable start end translate))
(apply 'xft:text-line-width (screen-number (current-screen)) font text
:allow-other-keys t keys))
(defmethod draw-image-glyphs (drawable
gcontext
(font xft:font)
x y
sequence &rest keys &key (start 0) end translate width size)
(declare (ignorable start end translate width size))
(apply 'xft:draw-text-line
drawable
gcontext
font
sequence
x y
:draw-background-p t
:allow-other-keys t
keys))
;;-----END HACKERY-----
;; fucking colon1 from the fucking sample
(defcommand colon1 (&optional (initial "")) (:rest)
(let ((cmd (read-one-line (current-screen) ": " :initial-input initial)))
(when cmd
(eval-command cmd t))))
;; fucking smart-splitting functionality
(defcommand smart-split () ()
(let ((win (current-window)))
(if (> (window-width win) (window-height win))
(eval-command "hsplit") (eval-command "vsplit"))))
; fucking appearance
;; fucking message window font
;;
;; too bad this doesn't bloody work
(set-font (make-instance 'xft:font
:family "Courier New"
:subfamily "Bold"
:size 10))
;; (set-font "Courier")
;; fucking modeline
;; (if (not (head-mode-line (current-head)))
;; (toggle-mode-line (current-screen) (current-head)))
(loop for h in (screen-heads (current-screen))
do (if (not (head-mode-line h))
(toggle-mode-line (current-screen) h)))
;; fucking borders
(setf *window-border-style* :tight)
;; fucking window gaps
(load "~/.stumpwm.d/gaps.lisp")
(setf *window-gap* 8)
; fucking keybindings
;; fucking prefix key
(set-prefix-key (kbd "Menu"))
;; override fucking xterm as default shell
;;
;; I mean, I have fucking urxvt installed; stumpwm should be smart
;; enough to use that, but *no*, apparently that's too much to fucking
;; ask.
(define-key *root-map* (kbd "c") "exec urxvt")
(define-key *root-map* (kbd "C-c") "exec urxvt")
;; fucking super-key bindings
;;
;; Because I'm sick and fucking tired of using a prefix key for
;; literally fucking everything
;;; fucking window/frame focusing
(define-key *top-map* (kbd "s-Up") "move-focus up")
(define-key *top-map* (kbd "s-Down") "move-focus down")
(define-key *top-map* (kbd "s-Left") "move-focus left")
(define-key *top-map* (kbd "s-Right") "move-focus right")
(define-key *top-map* (kbd "s-p") "prev")
(define-key *top-map* (kbd "s-n") "next")
(define-key *top-map* (kbd "s-b") "prev-in-frame")
(define-key *top-map* (kbd "s-f") "next-in-frame")
;;; fucking window/frame moving
(define-key *top-map* (kbd "C-s-Up") "move-window up")
(define-key *top-map* (kbd "C-s-Down") "move-window down")
(define-key *top-map* (kbd "C-s-Left") "move-window left")
(define-key *top-map* (kbd "C-s-Right") "move-window right")
;;; fucking window/frame creating/deleting
(defvar *pane-split-map*
(let ((m (make-sparse-keymap)))
(define-key m (kbd "h") "hsplit")
(define-key m (kbd "v") "vsplit")
m))
(define-key *top-map* (kbd "s-s") '*pane-split-map*)
(define-key *top-map* (kbd "s-S") "smart-split")
(define-key *top-map* (kbd "s-r") "remove-split")
(define-key *top-map* (kbd "s-k") "delete-window")
(define-key *top-map* (kbd "s-K") "kill-window")
;;; fucking group focusing
(define-key *top-map* (kbd "M-s-Up") "gprev")
(define-key *top-map* (kbd "M-s-Down") "gnext")
;;; fucking group moving
(define-key *top-map* (kbd "C-M-s-Up") "gprev-with-window")
(define-key *top-map* (kbd "C-M-s-Down") "gnext-with-window")
(in-package :stumpwm)
;; Let's start by specifying the fucking gap in a fucking variable or
;; some shit.
(defvar *window-gap* 0)
;; I have no fucking idea if this is really the right way to go about
;; this. Please pray for my fucking soul.
(defun maximize-window (win)
"Maximize the window."
(multiple-value-bind (x y wx wy width height border stick)
(geometry-hints win)
(dformat 4 "maximize window ~a x: ~d y: ~d width: ~d height: ~d border: ~d stick: ~s~%"
win x y width height border stick)
;; This is the only place a window's geometry should change
(set-window-geometry win
:x wx
:y wy
:width (- width (* 2
(if (or (window-transient-p win) (window-modal-p win))
0 *window-gap*)))
:height (- height (* 2
(if (or (window-transient-p win) (window-modal-p win))
0 *window-gap*)))
:border-width 0)
(xlib:with-state ((window-parent win))
;; FIXME: updating the border doesn't need to be run everytime
;; the window is maximized, but only when the border style or
;; window type changes. The overhead is probably minimal,
;; though.
(setf (xlib:drawable-x (window-parent win)) (+ x
(if (or (window-transient-p win)
(window-modal-p win))
0 *window-gap*))
(xlib:drawable-y (window-parent win)) (+ y
(if (or (window-transient-p win)
(window-modal-p win))
0 *window-gap*))
(xlib:drawable-border-width (window-parent win)) border)
;; the parent window should stick to the size of the window
;; unless it isn't being maximized to fill the frame.
(if (or stick
(find *window-border-style* '(:tight :none)))
(setf (xlib:drawable-width (window-parent win))
(window-width win)
(xlib:drawable-height (window-parent win))
(window-height win))
(let ((frame (window-frame win)))
(setf (xlib:drawable-width (window-parent win))
(- (frame-width frame)
(* 2 (xlib:drawable-border-width (window-parent win))))
(xlib:drawable-height (window-parent win))
(- (frame-display-height (window-group win) frame)
(* 2 (xlib:drawable-border-width (window-parent win)))))))
;; update the "extents"
(xlib:change-property (window-xwin win) :_NET_FRAME_EXTENTS
(list wx wy
(- (xlib:drawable-width (window-parent win)) width wx)
(- (xlib:drawable-height (window-parent win)) height wy))
:cardinal 32))
(update-configuration win)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment