Created
August 15, 2015 20:54
-
-
Save ralt/db6c0afe6d61f14ca323 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;; -*- Mode: Lisp -*- | |
(in-package :stumpwm) | |
(ql:quickload 'swank) | |
(ql:quickload :alexandria) | |
(swank-loader:init) | |
(defcommand swank () () | |
(setf stumpwm:*top-level-error-action* :break) | |
(swank:create-server :port 4004 | |
:style swank:*communication-style* | |
:dont-close t)) | |
(swank) | |
;(stumpwm:run-shell-command "set_resolution") | |
(stumpwm:run-shell-command "setkeyboard &") | |
;; how many seconds elapse between each update of the modeline | |
;(setf *mode-line-timeout* 1) ; must be set *before* turning on the modeline | |
;(mode-line) | |
;; Turn on the modeline | |
;(if (not (head-mode-line (current-head))) | |
; (toggle-mode-line (current-screen) (current-head))) | |
(defcommand my/toggle-mode-line () () | |
"toggle the modeline" | |
(toggle-mode-line (current-screen) (current-head))) | |
;; Show time, cpu usage and network traffic in the modeline | |
(setf *screen-mode-line-format* | |
(list '(:eval (run-shell-command "date '+%R, %F %a'|tr -d [:cntrl:]" t)) " [^B%n^b] %W")) | |
(defcommand google-chrome () () | |
"run google chrome" | |
(run-or-raise "google-chrome" '(:class "Google-chrome"))) | |
(defcommand chromium () () | |
"run chromium" | |
(run-or-raise "chromium" '(:class "Chromium"))) | |
(defcommand iceweasel () () | |
"run iceweasel" | |
(run-or-raise "iceweasel" '(:class "Iceweasel"))) | |
(defcommand hipchat () () | |
"run hipchat" | |
(run-or-raise "hipchat" '(:instance "hipchat"))) | |
(defcommand skype () () | |
"run skype" | |
(run-or-raise "skype" '(:instance "skype"))) | |
(defcommand lock () () | |
"lock the screen" | |
(run-shell-command "pyxtrlock")) | |
(defcommand suspend () () | |
"puts the pc in veille" | |
(run-shell-command "suspend")) | |
(defcommand emacs () () | |
"run emacs" | |
(run-or-raise "emacs" '(:title "emacs"))) | |
(defcommand screenshot () () | |
"screenshot" | |
(run-shell-command "gnome-screenshot")) | |
(defcommand screenshot-area () () | |
"screenshot-area" | |
(run-shell-command "gnome-screenshot -a")) | |
(defcommand poweroff () () | |
"poweroff" | |
(run-shell-command "sudo poweroff")) | |
(defcommand reboot () () | |
"reboot" | |
(run-shell-command "sudo reboot")) | |
(defcommand term () () | |
"xterm" | |
(run-shell-command "gnome-terminal")) | |
(define-key *root-map* (kbd "x") "term") | |
(define-key *root-map* (kbd "c") "chromium") | |
(loop for i from 1 to 9 | |
do (define-key | |
*top-map* | |
(kbd (format nil "s-~d" i)) | |
(format nil "select-window-by-number ~d" i))) | |
;; Navigation | |
(define-key *top-map* (kbd "s-ESC") "gother") | |
(define-key *top-map* (kbd "s-n") "next") | |
(define-key *top-map* (kbd "s-#") "screenshot") | |
(define-key *top-map* (kbd "s-$") "screenshot-area") | |
;;; Window Appearance | |
;; The width in pixels given to the borders of regular windows. | |
(setf *normal-border-width* 1) | |
;; The width in pixels given to the borders of windows with maxsize or ratio hints. | |
(setf *maxsize-border-width* 1) | |
;; The width in pixels given to the borders of transient or pop-up windows. | |
(setf *transient-border-width* 1) | |
(setf *mouse-focus-policy* :click) ;; :click, :ignore, :sloppy | |
(setf *window-number-map* "1234567890") | |
(setf *frame-number-map* "1234567890") | |
(define-key *top-map* (kbd "s-`") "other") | |
(defvar *current-lang* "us") | |
(defcommand setkeyboard (lang) ((:string "langcode: ")) | |
"sets the keyboard" | |
(setf *current-lang* lang) | |
(run-shell-command (format nil | |
"setxkbmap -option -option ctrl:nocaps -option layout ~A" | |
lang))) | |
(defcommand toggle-keyboard () () | |
"toggles the keyboard layout" | |
(setf *current-lang* (if (string= *current-lang* "us") "fr" "us")) | |
(setkeyboard *current-lang*) | |
(message "Switched to ~A layout" *current-lang*)) | |
(define-key *root-map* (kbd "C-s") "toggle-keyboard") | |
(defun read-battery-file (file) | |
(let ((fields (make-hash-table :test #'equal))) | |
(with-open-file (f file) | |
(do ((line (read-line f nil nil) (read-line f nil nil))) | |
((null line) fields) | |
(let ((split (cl-ppcre:split ":\\s*" line))) | |
(setf (gethash (string-trim '(#\Space) (car split)) fields) | |
(string-trim '(#\Space) (cadr split)))))) | |
(first (alexandria:hash-table-keys fields)))) | |
(defcommand battery () () | |
"shows battery usage" | |
(message "~A ~A%" | |
(read-battery-file "/sys/class/power_supply/BAT0/status") | |
(read-battery-file "/sys/class/power_supply/BAT0/capacity"))) | |
(defcommand head-windowlist () () | |
"shows the list of windows on a single head" | |
(select-window-from-menu | |
(head-windows (current-group) (current-head)) | |
*window-format*)) | |
(unless (fboundp 'stumpwm::pull-from-windowlist) | |
(defcommand (pull-from-windowlist tile-group) () () | |
"Pulls a window selected from the list of windows. | |
This allows a behavior similar to Emacs' switch-to-buffer | |
when selecting another window." | |
(let ((pulled-window (select-from-menu | |
(current-screen) | |
(mapcar #'(lambda (w) | |
(list (format-expand *window-formatters* | |
*window-format* | |
w) | |
w)) | |
(group-windows (current-group)))))) | |
(when pulled-window | |
(pull-window (second pulled-window)))))) | |
(define-key *root-map* (kbd "C-t") "pull-from-windowlist") | |
(define-key *root-map* (kbd "C-r") "windowlist") | |
(defcommand regularly-show-time () () | |
"Regularly shows the time." | |
(loop | |
do (sleep 60) | |
do (echo-date))) | |
(setf *window-format* "%c - %50t") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment