Advertisement
alldigital

exwm config

Dec 14th, 2017
657
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 7.96 KB | None | 0 0
  1.   ;; EXWM stuff
  2.  
  3.   (add-to-list 'load-path "~/.emacs.local.d/xelb")
  4.   (add-to-list 'load-path "~/.emacs.local.d/exwm")
  5.  
  6.   ;; (when (and window-system (require 'exwm nil t))
  7.   (require 'exwm)
  8.     (require 'exwm-config)
  9.     (exwm-config-default)
  10.  
  11.     ;; exwm vars
  12.  
  13.     (defvar exwm--terminal-command "termite"
  14.       "Terminal command to run.")
  15.  
  16.     (defvar exwm--locking-command "i3lock-fancy"
  17.       "Command to run when locking session")
  18.  
  19.     (defvar exwm-app-launcher--prompt "$ "
  20.       "Prompt for the EXWM application launcher")
  21.  
  22.     (defvar exwm--rofi-command "rofi -modi \"run,ssh\" -show run -font \"Input Mono Compressed 10\""
  23.       "Command to start rofi launcher")
  24.  
  25.     (defvar exwm--hide-tiling-modeline t
  26.       "Whether to hide modeline.")
  27.  
  28.     (defun spacemacs/exwm-bind-command (key command &rest bindings)
  29.       (while key
  30.         (exwm-input-set-key (kbd key)
  31.                             `(lambda ()
  32.                                (interactive)
  33.                                (start-process-shell-command ,command nil ,command)))
  34.         (setq key     (pop bindings)
  35.               command (pop bindings))))
  36.  
  37.     (spacemacs/exwm-bind-command "<s-return>"  exwm--terminal-command)
  38.  
  39.     (spacemacs/exwm-bind-command "s-d"  exwm--rofi-command)
  40.  
  41.     (setq exwm-workspace-number 9
  42.           exwm-workspace-show-all-buffers t
  43.           exwm-layout-show-all-buffers t)
  44.  
  45.     (require 'exwm-systemtray)
  46.     (exwm-systemtray-enable)
  47.     (display-time-mode 1)
  48.     (setq display-time-string-forms '((format-time-string "%H:%M" now)))
  49.  
  50.     ;; + Application launcher ('M-&' also works if the output buffer does not
  51.     ;;   bother you). Note that there is no need for processes to be created by
  52.     ;;   Emacs.
  53.     (defun spacemacs/exwm-application-launcher (command)
  54.       "Launches an application in your PATH.
  55. Can show completions at point for COMMAND using helm or ido"
  56.       (interactive (list (read-shell-command exwm-app-launcher--prompt)))
  57.       (start-process-shell-command command nil command))
  58.  
  59.     (exwm-input-set-key (kbd "s-SPC") #'spacemacs/exwm-application-launcher)
  60.     (exwm-input-set-key (kbd "s-p") #'spacemacs/exwm-application-launcher)
  61.  
  62.     ;; lock screen
  63.     (exwm-input-set-key (kbd "<s-escape>")
  64.                         (lambda () (interactive) (start-process "" nil exwm--locking-command)))
  65.  
  66.     ;; Workspace helpers
  67.  
  68.     (defvar exwm-workspace-switch-wrap t
  69.       "Whether `spacemacs/exwm-workspace-next' and `spacemacs/exwm-workspace-prev' should wrap.")
  70.  
  71.     (defun spacemacs/exwm-workspace-next ()
  72.       "Switch to next exwm-workspaceective (to the right)."
  73.       (interactive)
  74.       (let* ((only-workspace? (equal exwm-workspace-number 1))
  75.              (overflow? (= exwm-workspace-current-index
  76.                            (1- exwm-workspace-number))))
  77.         (cond
  78.          (only-workspace? nil)
  79.          (overflow?
  80.           (when exwm-workspace-switch-wrap
  81.             (exwm-workspace-switch 0)))
  82.          (t (exwm-workspace-switch  (1+ exwm-workspace-current-index))))))
  83.     (defun spacemacs/exwm-workspace-prev ()
  84.       "Switch to next exwm-workspaceective (to the right)."
  85.       (interactive)
  86.       (let* ((only-workspace? (equal exwm-workspace-number 1))
  87.              (overflow? (= exwm-workspace-current-index 0)))
  88.         (cond
  89.          (only-workspace? nil)
  90.          (overflow?
  91.           (when exwm-workspace-switch-wrap
  92.             (exwm-workspace-switch (1- exwm-workspace-number))))
  93.          (t (exwm-workspace-switch  (1- exwm-workspace-current-index))))))
  94.  
  95.     ;; Quick swtiching between workspaces
  96.     (defvar exwm-toggle-workspace 0
  97.       "Previously selected workspace. Used with `exwm-jump-to-last-exwm'.")
  98.     (defun exwm-jump-to-last-exwm ()
  99.       (interactive)
  100.       (exwm-workspace-switch exwm-toggle-workspace))
  101.     (defadvice exwm-workspace-switch (before save-toggle-workspace activate)
  102.       (setq exwm-toggle-workspace exwm-workspace-current-index))
  103.  
  104.     ;; Rename buffer to window title
  105.     (defun exwm-rename-buffer-to-title () (exwm-workspace-rename-buffer exwm-title))
  106.     (add-hook 'exwm-update-title-hook 'exwm-rename-buffer-to-title)
  107.  
  108.     ;; no mode line for floating windows
  109.     (add-hook 'exwm-floating-setup-hook 'exwm-layout-hide-mode-line)
  110.     (add-hook 'exwm-floating-exit-hook 'exwm-layout-show-mode-line)
  111.  
  112.     ;; per app settings
  113.  
  114.     ;; (defun exwm-start-in-char-mode ()
  115.     ;;   (when (or (string= exwm-instance-name "emacs")
  116.     ;;             (string= exwm-class-name "Termite")
  117.     ;;             (string= exwm-class-name "URxvt")
  118.     ;;             (string= exwm-class-name "XTerm")
  119.     ;;             (string= exwm-class-name "libreoffice-startcenter"))
  120.     ;;     (exwm-input-release-keyboard (exwm--buffer->id (window-buffer)))))
  121.  
  122.     ;; (add-hook 'exwm-manage-finish-hook 'exwm-start-in-char-mode)
  123.  
  124.     ;;make exwm windows default to char instead of line mode
  125.  
  126.     (add-hook 'exwm-manage-finish-hook
  127.               (lambda () (call-interactively #'exwm-input-release-keyboard)
  128.                 (exwm-layout-hide-mode-line)))
  129.  
  130.                                         ;send all keypresses to emacs in line mode
  131.     (setq exwm-input-line-mode-passthrough t)
  132.  
  133.  
  134.  
  135.     (defun exwm-input-line-mode ()
  136.       "Set exwm window to line-mode and show mode line"
  137.       (call-interactively #'exwm-input-grab-keyboard)
  138.       (exwm-layout-show-mode-line))
  139.  
  140.     (defun exwm-input-char-mode ()
  141.       "Set exwm window to char-mode and hide mode line"
  142.       (call-interactively #'exwm-input-release-keyboard)
  143.       (exwm-layout-hide-mode-line))
  144.  
  145.     (defun exwm-input-toggle-mode ()
  146.       "Toggle between line- and char-mode"
  147.       (with-current-buffer (window-buffer)
  148.         (when (eq major-mode 'exwm-mode)
  149.           (if (equal (second (second mode-line-process)) "line")
  150.               (exwm-input-char-mode)
  151.             (exwm-input-line-mode)))))
  152.  
  153.     (exwm-input-set-key (kbd "s-i")
  154.                         (lambda () (interactive)
  155.                           (exwm-input-toggle-mode)))
  156.  
  157.     (exwm-input-set-key (kbd "s-o")
  158.                         (lambda ()
  159.                           (interactive)
  160.                           (exwm-input-toggle-mode)
  161.                           (org-capture)))
  162.     ;; Quick keys
  163.  
  164.     ;; `exwm-input-set-key' allows you to set a global key binding (available in
  165.     ;; any case). Following are a few examples.
  166.     ;; + We always need a way to go back to line-mode from char-mode
  167.     (exwm-input-set-key (kbd "s-r") 'exwm-reset)
  168.  
  169.     (exwm-input-set-key (kbd "s-f") #'exwm-layout-toggle-fullscreen)
  170.     (exwm-input-set-key (kbd "<s-tab>") #'exwm-jump-to-last-exwm)
  171.     ;; + Bind a key to switch workspace interactively
  172.     (exwm-input-set-key (kbd "s-w") 'exwm-workspace-switch)
  173.  
  174.     ;; Preserve the habit
  175.     (exwm-input-set-key (kbd "s-:") 'helm-M-x)
  176.     (exwm-input-set-key (kbd "s-;") 'evil-ex)
  177.     ;; Shell (not a real one for the moment)
  178.     (exwm-input-set-key (kbd "C-'") #'spacemacs/default-pop-shell)
  179.     ;; Undo window configurations
  180.     (exwm-input-set-key (kbd "s-u") #'winner-undo)
  181.     (exwm-input-set-key (kbd "S-s-U") #'winner-redo)
  182.     ;; Change buffers
  183.     (exwm-input-set-key (kbd "s-b") #'helm-mini)
  184.     ;; Focusing windows
  185.     (exwm-input-set-key (kbd "s-h") #'evil-window-left)
  186.     (exwm-input-set-key (kbd "s-j") #'evil-window-down)
  187.     (exwm-input-set-key (kbd "s-k") #'evil-window-up)
  188.     (exwm-input-set-key (kbd "s-l") #'evil-window-right)
  189.     ;; Moving Windows
  190.     (exwm-input-set-key (kbd "s-H") #'evil-window-move-far-left)
  191.     (exwm-input-set-key (kbd "s-J") #'evil-window-move-very-bottom)
  192.     (exwm-input-set-key (kbd "s-K") #'evil-window-move-very-top)
  193.     (exwm-input-set-key (kbd "s-L") #'evil-window-move-far-right)
  194.     ;; Resize
  195.     (exwm-input-set-key (kbd "M-s-h") #'spacemacs/shrink-window-horizontally)
  196.     (exwm-input-set-key (kbd "M-s-j") #'spacemacs/shrink-window)
  197.     (exwm-input-set-key (kbd "M-s-k") #'spacemacs/enlarge-window)
  198.     (exwm-input-set-key (kbd "M-s-l") #'spacemacs/enlarge-window-horizontally)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement