;;; bandali-exwm.el --- bandali's EXWM configuration -*- lexical-binding: t; -*- ;; Copyright (C) 2018-2020 Amin Bandali ;; Author: Amin Bandali ;; Keywords: tools ;; This program is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . ;;; Commentary: ;; My EXWM setup. Makes good use of its simulation keys. ;;; Code: (add-to-list 'load-path (b/lisp "xelb")) (add-to-list 'load-path (b/lisp "exwm")) (require 'exwm) ;; make class name the buffer name, truncating beyond 60 characters (defun b/exwm-rename-buffer () (interactive) (exwm-workspace-rename-buffer (concat exwm-class-name ":" (if (<= (length exwm-title) 60) exwm-title (concat (substring exwm-title 0 59) "..."))))) ;; Enable EXWM (exwm-enable) (add-hook 'exwm-update-class-hook #'b/exwm-rename-buffer) (add-hook 'exwm-update-title-hook #'b/exwm-rename-buffer) (require 'exwm-config) (add-hook 'exwm-init-hook #'exwm-config--fix/ido-buffer-window-other-frame) (require 'exwm-input) (defun b/exwm-ws-prev-index () "Return the index for the previous EXWM workspace, wrapping around if needed." (if (= exwm-workspace-current-index 0) (1- exwm-workspace-number) (1- exwm-workspace-current-index))) (defun b/exwm-ws-next-index () "Return the index for the next EXWM workspace, wrapping around if needed." (if (= exwm-workspace-current-index (1- exwm-workspace-number)) 0 (1+ exwm-workspace-current-index))) ;; shorten 'C-c C-q' to 'C-q' (define-key exwm-mode-map [?\C-q] #'exwm-input-send-next-key) (csetq exwm-workspace-number 10 exwm-input-global-keys `(([?\s-R] . exwm-reset) ([?\s-\\] . exwm-workspace-switch) ([?\s-\s] . dmenu) ([?\S-\s-\s] . (lambda (command) (interactive (list (read-shell-command "➜ "))) (start-process-shell-command command nil command))) ([s-return] . (lambda () (interactive) (start-process "" nil "urxvt"))) ([?\C-\s-\s] . counsel-linux-app) ([?\M-\s-\s] . (lambda () (interactive) (start-process-shell-command "rofi-pass" nil "rofi-pass"))) ([?\s-h] . windmove-left) ([?\s-j] . windmove-down) ([?\s-k] . windmove-up) ([?\s-l] . windmove-right) ([?\s-H] . windmove-swap-states-left) ([?\s-J] . windmove-swap-states-down) ([?\s-K] . windmove-swap-states-up) ([?\s-L] . windmove-swap-states-right) ([?\M-\s-h] . shrink-window-horizontally) ([?\M-\s-l] . enlarge-window-horizontally) ([?\M-\s-k] . shrink-window) ([?\M-\s-j] . enlarge-window) ([?\s-\[] . (lambda () (interactive) (exwm-workspace-switch-create (b/exwm-ws-prev-index)))) ([?\s-\]] . (lambda () (interactive) (exwm-workspace-switch-create (b/exwm-ws-next-index)))) ([?\s-{] . (lambda () (interactive) (exwm-workspace-move-window (b/exwm-ws-prev-index)))) ([?\s-}] . (lambda () (interactive) (exwm-workspace-move-window (b/exwm-ws-next-index)))) ,@(mapcar (lambda (i) `(,(kbd (format "s-%d" i)) . (lambda () (interactive) (exwm-workspace-switch-create ,i)))) (number-sequence 0 (1- exwm-workspace-number))) ([?\s-t] . exwm-floating-toggle-floating) ([?\s-f] . exwm-layout-toggle-fullscreen) ([?\s-W] . (lambda () (interactive) (kill-buffer (current-buffer)))) ([?\s-Q] . (lambda () (interactive) (exwm-manage--kill-client))) ([?\s-\'] . (lambda () (interactive) (start-process-shell-command "rofi-light" nil "rofi-light"))) ([XF86AudioMute] . ; borken on my X200 :-( (lambda () (interactive) (start-process "" nil "pamixer" "--toggle-mute"))) ([XF86Launch1] . (lambda () (interactive) (start-process "" nil "pamixer" "--toggle-mute"))) ([\s-XF86Launch1] . ; toggle mic mute (lambda () (interactive) (start-process "" nil "pamixer" "--default-source" "--toggle-mute"))) ([XF86AudioLowerVolume] . (lambda () (interactive) (start-process "" nil "pamixer" "--allow-boost" "--decrease" "5"))) ([XF86AudioRaiseVolume] . (lambda () (interactive) (start-process "" nil "pamixer" "--allow-boost" "--increase" "5"))) ([XF86AudioPlay] . (lambda () (interactive) (start-process "" nil "mpc" "toggle"))) ([XF86AudioPrev] . (lambda () (interactive) (start-process "" nil "mpc" "prev"))) ([XF86AudioNext] . (lambda () (interactive) (start-process "" nil "mpc" "next"))) ([XF86ScreenSaver] . (lambda () (interactive) (start-process "" nil "dm-tool" "lock"))) ([\s-XF86Back] . previous-buffer) ([\s-XF86Forward] . next-buffer))) ;; Line-editing shortcuts (csetq exwm-input-simulation-keys '(;; movement ([?\C-b] . [left]) ([?\M-b] . [C-left]) ([?\C-f] . [right]) ([?\M-f] . [C-right]) ([?\C-p] . [up]) ([?\C-n] . [down]) ([?\C-a] . [home]) ([?\C-e] . [end]) ([?\M-v] . [prior]) ([?\C-v] . [next]) ([?\C-d] . [delete]) ([?\C-k] . [S-end ?\C-x]) ([?\M-<] . C-home) ([?\M->] . C-end) ;; cut/copy/paste ([?\C-w] . [?\C-x]) ([?\M-w] . [?\C-c]) ([?\C-y] . [?\C-v]) ([?\M-d] . [C-S-right ?\C-x]) ([?\M-\d] . [C-S-left ?\C-x]) ;; window ([?\s-w] . [?\C-w]) ([?\s-q] . [?\C-q]) ;; misc ([?\C-s] . [?\C-f]) ([?\s-s] . [?\C-s]) ([?\C-g] . [escape]))) (require 'exwm-manage) (add-hook 'exwm-manage-finish-hook (lambda () (when exwm-class-name (cond ((member exwm-class-name '("IceCat" "Iceweasel")) (exwm-input-set-local-simulation-keys `(,@exwm-input-simulation-keys ([?\C-\S-d] . [?\C-d])))) ((string= exwm-class-name "URxvt") (exwm-input-set-local-simulation-keys '(([?\C-c ?\C-c] . [?\C-c]) ([?\C-c ?\C-u] . [?\C-u])))) ((string= exwm-class-name "Zathura") (exwm-input-set-local-simulation-keys '(([?\C-p] . [C-up]) ([?\C-n] . [C-down])))))))) (require 'exwm-randr) (exwm-randr-enable) (csetq exwm-randr-workspace-monitor-plist '(1 "VGA-1")) (require 'exwm-systemtray) (exwm-systemtray-enable) (add-to-list 'load-path (b/lisp "exwm-edit")) (require 'exwm-edit) (provide 'bandali-exwm) ;;; bandali-exwm.el ends here