dotfiles/stumpwm/stumpwmrc

359 lines
10 KiB
Text
Raw Normal View History

2016-06-02 21:30:02 +02:00
;; -*-lisp-*-
;;
2018-03-13 16:50:36 +01:00
;; StumpWM configuration file
;; <https://stumpwm.github.io/>
;;
;; 2016 - 2018 (c) Marcel Kapfer <opensource@mmk2410.org>
;; MIT License
2016-06-02 21:30:02 +02:00
(in-package :stumpwm)
(defparameter *key-layout* "us -variant altgr-intl" "Stores the current key layout")
2018-03-13 23:26:13 +01:00
(defconstant browser "firefox" "Constant holding the default browser.")
2016-12-04 23:18:21 +01:00
2017-09-19 16:06:17 +02:00
;; creating or rename groups
2017-11-25 22:54:00 +01:00
(setf (group-name (first (screen-groups (current-screen)))) "web")
2017-09-19 16:06:17 +02:00
(gnewbg "work")
2017-11-25 22:54:00 +01:00
(gnewbg "misc")
2017-09-19 16:06:17 +02:00
(gnewbg "music")
2017-11-25 22:54:00 +01:00
(gnewbg "winkel")
2016-12-04 23:18:21 +01:00
;; border width
2017-09-19 16:06:17 +02:00
(setf *maxsize-border-width* 3)
(setf *transient-border-width* 3)
(setf *normal-border-width* 3)
2016-12-04 23:18:21 +01:00
;; border style
(setf *window-border-style* :tight)
(set-focus-color "#b00045")
2017-09-19 16:06:17 +02:00
(set-win-bg-color "#b00045")
(set-unfocus-color "#333333")
2016-12-04 23:18:21 +01:00
(set-float-focus-color "#b00045")
2017-09-19 16:06:17 +02:00
(set-float-unfocus-color "#333333")
2016-12-04 23:18:21 +01:00
;; window gravity
(set-normal-gravity :center)
(set-maxsize-gravity :center)
(set-transient-gravity :center)
(gravity :center)
2017-09-19 16:06:17 +02:00
;; input bar position
2018-02-23 09:28:35 +01:00
(setf *input-window-gravity* :bottom)
2017-09-19 16:06:17 +02:00
;; message bar position
2018-02-23 09:28:35 +01:00
(setf *message-window-gravity* :bottom)
2017-09-19 16:06:17 +02:00
;; message timeout
(setf *timeout-wait* 3)
;; set the mouse focus
2017-11-25 23:07:00 +01:00
(setf *mouse-focus-policy* :click)
2017-09-19 16:06:17 +02:00
;; set DESKTOP_SESSION variable
(setf (getenv "DESKTOP_SESSION") "stumpwm")
;; bugfix for scrolling doesn't work with an external mouse in GTK+3 Apps
(setf (getenv "GDK_CORE_DEVICE_EVENTS") "1")
2017-09-19 16:06:17 +02:00
;; style message windows
(set-bg-color "#333333")
(set-border-color "#b00045")
;; loading modeline modules
(load-module "battery-portable")
(load-module "hostname")
2017-11-25 23:00:56 +01:00
(load-module "stumptray")
2017-09-19 16:06:17 +02:00
;; mode-line style
(setf *mode-line-background-color* "#333333"
*mode-line-foreground-color* "#cccccc"
*mode-line-border-color* "#b00045"
*mode-line-timeout* 5
*mode-line-border-width* 3
*mode-line-pad-x* 3
*mode-line-pad-y* 3
2017-11-25 23:00:56 +01:00
*screen-mode-line-format* (list "[" '(:eval (RUN-SHELL-COMMAND "date '+%F %H:%M'|tr -d [:cntrl:]" T)) "] [%n] %w ^> [" '(:eval (RUN-SHELL-COMMAND "hostname -I |tr -d [:cntrl:]" T)) "][%B] [marcel@%h] %T"))
2017-09-19 16:06:17 +02:00
;; customize texts
(setf *window-format* "^B %n ^b %20t "
*group-format* "%t")
;; program runners
;;; emacs
(defcommand emacs () ()
"run emacs"
(run-or-raise "es" '(:class "Emacs")))
2016-12-04 23:18:21 +01:00
;; root keybindings
2017-07-21 10:13:45 +02:00
;
;; browser
2018-03-13 23:26:13 +01:00
(define-key *root-map* (kbd "W") (concatenate 'string "exec" " " browser))
(define-key *root-map* (kbd "P") (concatenate 'string "exec" " " browser " " "--private-window"))
2016-12-04 23:18:21 +01:00
;;; terminal
(define-key *root-map* (kbd "c") "exec urxvt")
2016-12-23 22:06:39 +01:00
;;; es as emacs
(define-key *root-map* (kbd "e") "exec es")
2016-12-23 22:06:39 +01:00
2017-08-10 09:46:29 +02:00
;;; ranger
2018-02-03 18:25:29 +01:00
(define-key *root-map* (kbd "C-c") "exec nemo --no-desktop")
2018-02-03 18:25:41 +01:00
;;; spotify
(define-key *root-map* (kbd "m") "exec spotify")
2017-08-10 09:46:29 +02:00
2017-11-25 22:54:00 +01:00
;;; bind keys for changing workspace
(define-key *root-map* (kbd "C-1") "change-workspace web")
(define-key *root-map* (kbd "C-2") "change-workspace work")
(define-key *root-map* (kbd "C-3") "change-workspace misc")
(define-key *root-map* (kbd "C-4") "change-workspace music")
(define-key *root-map* (kbd "C-s") "change-workspace winkel")
;; bind keys for moving the current window to another workspace
(define-key *root-map* (kbd "M-1") "gmove web")
(define-key *root-map* (kbd "M-2") "gmove work")
(define-key *root-map* (kbd "M-3") "gmove misc")
(define-key *root-map* (kbd "M-4") "gmove music")
(define-key *root-map* (kbd "M-s") "gmove winkel")
2016-06-02 21:30:02 +02:00
2017-07-21 10:13:45 +02:00
;;; mode-line key
(define-key *root-map* (kbd "Menu") "mode-line")
2017-09-19 16:06:17 +02:00
;; define volume control keys
(define-key *top-map* (kbd "XF86AudioLowerVolume") "exec amixer set Master 5%-")
(define-key *top-map* (kbd "XF86AudioRaiseVolume") "exec amixer set Master 5%+")
(define-key *top-map* (kbd "XF86AudioMute") "exec amixer set Master toggle")
(define-key *top-map* (kbd "XF86AudioMicMute") "exec amixer set Capture toggle")
;; webjump keys
(defvar *webjump-frame-bindings*
(let ((m (make-sparse-keymap)))
(define-key m (kbd "g") "google")
(define-key m (kbd "G") "googlede")
(define-key m (kbd "d") "duckduckgo")
(define-key m (kbd "D") "packages")
(define-key m (kbd "w") "wikipedia")
(define-key m (kbd "W") "wikipediade")
m))
(define-key *root-map* (kbd "j") '*webjump-frame-bindings*)
;; computer power state keys
(defvar *powerstate-frame-bindings*
(let ((m (make-sparse-keymap)))
(define-key m (kbd "M-s") "system-suspend")
(define-key m (kbd "M-p") "system-poweroff")
(define-key m (kbd "M-r") "system-restart")
(define-key m (kbd "M-h") "system-hibernate")
m))
(define-key *root-map* (kbd "C-F12") '*powerstate-frame-bindings*)
2017-09-19 16:06:17 +02:00
;; lockscreen
2017-11-25 22:55:28 +01:00
(define-key *root-map* (kbd "M-l") "exec blurlock")
2017-09-19 16:06:17 +02:00
;; battery status
(define-key *root-map* (kbd "b") "exec ~/scripts/rat/bat.sh")
2016-06-02 21:30:02 +02:00
;; xserver
2017-07-21 10:13:45 +02:00
2016-06-02 21:30:02 +02:00
(run-shell-command "xrdb -merge ~/.Xresources")
;;; HiDPI stuff.
;;; TODO: Only run if required
2017-03-20 22:48:25 +01:00
;; (run-shell-command "xrdb -merge ~/.Xresources-hidpi")
2016-06-02 21:30:02 +02:00
2016-12-04 23:18:21 +01:00
;; dunst notify server
(run-shell-command "dunst")
;; nitrogen (wallpaper)
2016-06-02 21:30:02 +02:00
(run-shell-command "nitrogen --restore")
2018-03-13 16:53:45 +01:00
;; start compton (compositor)
2018-03-13 21:26:06 +01:00
(run-shell-command "compton --config ~/.config/compton.conf")
2018-03-13 16:53:45 +01:00
2017-09-19 16:06:17 +02:00
;; start mode line
2018-02-03 18:26:11 +01:00
;; (if (not (head-mode-line (current-head)))
;; (toggle-mode-line (current-screen) (current-head)))
2016-12-04 23:18:21 +01:00
;; set backlight
(defcommand set-backlight (value)
((:string "Backlight in %: "))
"Setting a new value for the backlight"
(run-shell-command (concatenate 'string "xbacklight -set " value))
(echo (concatenate 'string "Backlight set to " value)))
(define-key *root-map* (kbd "B") "set-backlight")
;; tweet
(defcommand tweet (tweet)
((:string "Tweet: "))
"Tweet"
(run-shell-command (concatenate 'string "cd ~/programs/dart/learning/twitter && dart main.dart -t \"" tweet "\""))
(echo (concatenate 'string "Tweeted: " tweet)))
(define-key *root-map* (kbd "T") "tweet")
;; switch key layout
(defun switch-layout-to (new-lang)
"Switch the key layout to the given one"
(setq *key-layout* new-lang)
(run-shell-command (concatenate 'string "setxkbmap -layout " new-lang " && xmodmap ~/.Xmodmap"))
(echo (concatenate 'string "Set keyboard layout to " new-lang)))
;; switch key leyout to german
(defcommand layout-de ()
()
"Set the keyboard layout to de (german)"
(switch-layout-to "de"))
;; switch key leyout to american english
(defcommand layout-en ()
()
"Set the keyboard layout to US International AltGr"
(switch-layout-to "us -variant altgr-intl"))
2016-12-04 23:18:21 +01:00
;; switch key layout automatically
(defcommand switch-layout ()
()
"Switch the layout"
(if (string= "us -variant altgr-intl" *key-layout*)
2016-12-04 23:18:21 +01:00
(switch-layout-to "de")
(switch-layout-to "us -variant altgr-intl")))
2016-12-04 23:18:21 +01:00
(define-key *top-map* (kbd "s-SPC" ) "switch-layout")
;; switch workspace with a message
(defcommand change-workspace (n)
((:string n))
"Switch workspace"
(run-commands (concatenate 'string "gselect " n))
(echo (concatenate 'string "Switched to " n)))
2016-12-23 22:06:39 +01:00
;; toggle window floating
(defcommand toggle-float ()
()
"Toggle weather window is floating or not"
(if (typep (current-window) 'STUMPWM::FLOAT-WINDOW)
(unfloat-this)
(float-this)))
;; and the key for it
(define-key *root-map* (kbd "C-f") "toggle-float")
;; key for keeping window always on top
(define-key *root-map* (kbd "C-T") "toggle-always-on-top")
2016-12-23 22:06:39 +01:00
;; working with emacsclient
(defvar *es-win* nil
"to hold the window called emacsclient")
(defun save-es-called-win ()
(setf *es-win* (current-window)))
(defun return-es-called-window (win)
(let* ((group (window-group win))
(frame (window-frame win))
(old-frame (tile-group-current-frame group)))
(frame-raise-window group frame win)
(focus-all win)
(unless (eq frame old-frame)
(show-frame-indicator group))))
2017-03-28 11:59:26 +02:00
2017-09-19 16:06:17 +02:00
;; webjumps
(defmacro make-web-jump (name prefix)
`(defcommand ,(intern name) (search) ((:rest ,(concatenate 'string name " search: ")))
(substitute #\+ #\Space search)
(run-shell-command (concatenate 'string ,prefix search))))
2018-03-13 23:26:13 +01:00
(make-web-jump "google" (concatenate 'string browser " " "http://www.google.com/search?q="))
(make-web-jump "googlede" (concatenate 'string browser " " "http://www.google.de/search?q="))
(make-web-jump "duckduckgo" (concatenate 'string browser " " "https://duckduckgo.com/?q="))
(make-web-jump "packages" (concatenate 'string browser " " "https://packages.debian.org/"))
(make-web-jump "wikipedia" (concatenate 'string browser " " "https://en.wikipedia.org/w/index.php?search="))
(make-web-jump "wikipediade" (concatenate 'string browser " " "https://de.wikipedia.org/w/index.php?search="))
2018-03-13 16:50:36 +01:00
(defun list-screen-layouts ()
"Return an alist of possible screen layouts. Those are the layouts saved in
~/.screenlayout.sh. First is the name of the layout and second the path to the
script."
(loop
for file
in (mapcar 'namestring
(directory "~/.screenlayout/*.sh"))
collect `(,(subseq file
(+ 1 (search "/" file :from-end t))
(- (length file) 3))
,file)))
(defcommand switch-screen-layout ()
()
"Menu to switch the screen layout. Possible options are the scripts saved in
~/.screenlayout/"
(labels
((pick (options)
(let ((selection
(select-from-menu
(current-screen)
options
nil
0)))
(cond
((null selection)
nil)
(t (stringp (second selection))
(run-shell-command (second selection)))))))
(pick (list-screen-layouts))))
(define-key *root-map* (kbd "l") "switch-screen-layout")
2017-07-21 10:13:45 +02:00
2017-07-31 17:58:12 +02:00
;; font configuration
(load-module "ttf-fonts")
2017-08-10 09:48:08 +02:00
(set-font (make-instance 'xft:font :family "Hack" :subfamily "Regular" :size 10))
2017-07-31 17:58:12 +02:00
2017-09-19 16:06:17 +02:00
;; window placement rules
2017-11-25 22:54:00 +01:00
(define-frame-preference "winkel"
2017-09-19 16:06:17 +02:00
(0 nil t :class "keepassxc")
(0 nil t :class "Nextcloud")
(0 nil t :class "de-dal33t-Start") ;; bwSyncAndShare
(0 nil t :class "TelegramDesktop"))
2017-09-19 16:06:17 +02:00
(define-frame-preference "web"
(0 nil t :class "Firefox"))
2017-09-19 16:06:17 +02:00
(define-frame-preference "music"
2017-11-25 22:54:00 +01:00
(0 nil t :class "Spotify"))
2017-09-19 16:06:17 +02:00
;; autostart programs
;; emacs
(run-commands "emacs")
2017-09-19 16:06:17 +02:00
;; keepassxc
(run-shell-command "gpg --textmode -d ~/dotfiles/dotdotfiles/keepassxc/password.gpg | keepassxc --pw-stdin ~/cloud/keys/2017-10.kdbx")
2017-09-19 16:06:17 +02:00
;; owncloud
(run-shell-command "nextcloud")
2017-09-19 16:06:17 +02:00
;; bwSyncAndShare
(run-shell-command "bwsyncandshare")
;; firefox
2018-03-13 23:26:13 +01:00
(run-shell-command browser)
2017-09-19 16:06:17 +02:00
;; telegram
(run-shell-command "telegram-desktop")
2017-09-19 16:06:17 +02:00
;; redshift
(run-shell-command "redshift")
2017-09-19 16:06:17 +02:00
;; last settings
2018-02-03 18:28:40 +01:00
;; (stumptray:stumptray)
2017-09-19 16:06:17 +02:00
2017-07-21 10:13:45 +02:00
(switch-layout-to *key-layout*)
(run-shell-command "xmodmap $HOME/.Xmodmap" t)
2018-02-03 18:28:51 +01:00
;; Local Variables:
;; mode: stumpwm
;; End: