emacs-config/config-exwm.org
2022-04-16 06:24:41 -05:00

5.2 KiB

exwm

  ;; This will be the hardest to write :/
  (when my/enable-exwm
    (use-exwm
      :load-path "~/.emacs.d/submodule/exwm/"
      :config
      (use-package exwm-x)
      (exwm-global-set-key (kbd "s-e") #'exwm-edit--compose)

      ;; Editting with Emacs in X-windows
      (use-package exwm-edit
        :init
        (setq exwm-edit-bind-default-keys nil)
        :config
        (exwm-global-set-key (kbd "s-e") #'exwm-edit--compose))

      ;; System tray
      (require 'exwm-systemtray)
      (exwm-systemtray-enable)

      ;; Multi monitor support
      (require 'exwm-randr)
      (exwm-enable)
      (exwm-randr-enable)

      ;; This is a new-frame hack. Don't copy faces for floating windows
      (require 'face-copier)

      (unless (eq 'hash-table (type-of face-new-frame-defaults))
        (def-face-copier1 my/frame-dont-copy-faces (sym)
          (let ((name (symbol-name sym)))
            (string-match-p "^doom-.*" name))
          mode-line
          mode-line-inactive
          variable-pitch
          diredp-file-suffix
          font-lock-type-face)

        (defun my/exwm-floating--advise-make-frame (orig id)
          (override1-face my/frame-dont-copy-faces
            (funcall orig id)))

        (advice-add #'exwm-floating--set-floating
                    :around
                    #'my/exwm-floating--advise-make-frame)

        (def-face-copier x-show-tip-faces (sym)
          nil
          tooltip)

        (defun dont-copy-faces-for-x-show-tip (orig &rest args)
          (override1-face x-show-tip-faces
            (apply orig args)))

        (advice-add #'x-show-tip
                    :around
                    #'dont-copy-faces-for-x-show-tip))

      ;; Actually launch programs
      (require 'exwm-launch-program)
      (define-key *root-map* (kbd "C-p") #'launch-program)

      ;; Shut down
      (add-hook 'exwm-exit-hook 'org-save-all-org-buffers)

      ;; Startup programs
      (add-hook 'exwm-init-hook 'server-start)

      ;; Reminder: Hooks execute in order. Make sure megasync launches after systemtray is enabled
      (require 'exwm-startup)
      (add-hook 'exwm-init-hook 'call-startup-programs)

      (require 'exwm-systemtray)
      (exwm-systemtray-enable)

      ;; Setup screens before anything else
      (require 'exwm-screens)
      (add-hook 'exwm-init-hook 'my/setup-screens)

      ;; This lets me do rapid emacs iteration
      (defun ignore-emacs ()
        (when (and exwm-class-name (string= exwm-class-name "Emacs"))
          (call-interactively #'exwm-input-release-keyboard)))

      (add-hook 'exwm-manage-finish-hook
                #'ignore-emacs)))

exwm-background

  (add-to-list 'load-path "~/.emacs.d/submodule/exwm-background/")
  (require 'exwm-background)

  (let ((wm (shell-command-to-string "wmctrl -m")))
    (when (and (string-match "Name: \\(.*\\)\n" wm)
               (not (string= "EXWM"
                             (match-string 1 wm))))
      (setq exwm-background/current-transparency 95)))

  (define-key *window-map* (kbd "t") 'exwm-background/window-transparency-hydra/body)
  (setq window-system-default-frame-alist `((x . ((alpha . (,exwm-background/current-transparency . 50))))))
  (exwm-global-set-key (kbd "s-v") #'exwm-background/toggle-viewing-background)
  (exwm-global-set-key (kbd "s-b") #'exwm-background/exwm-background-window) ;; TODO: Fix keybinding
  ;; (define-key desktop-environment-mode-map (kbd "<S-XF86MonBrightnessDown>") #'exwm-background/decrease-transparency)
  ;; (define-key desktop-environment-mode-map (kbd "<S-XF86MonBrightnessUp>") #'exwm-background/increase-transparency)
  (define-key *window-map* (kbd "b") #'exwm-background/exwm-background-window)
  (define-key *root-map* (kbd "k") #'exwm-background/exwm-send-key-to-background)
  (define-key *root-map* (kbd "C-k") #'exwm-background/exwm-send-key-to-background-loop)

tags

  ;; Need my tags
  (require 'exwm-tag)

Don't show these buffers in buffer-list

(defvar my/exclude-buffer-modes '(helm-major-mode messages-buffer-mode special-mode))

(defun my-buffer-predicate (buf)
  (with-current-buffer buf
    (if (memq major-mode my/exclude-buffer-modes)
        nil
      (exwm-layout--other-buffer-predicate buf))))

(add-hook 'exwm-init-hook
          (lambda ()
            (interactive) 
            (modify-all-frames-parameters
             '((buffer-predicate . my-buffer-predicate)))))

switch-window

  (use-package switch-window)
  (setq switch-window-shortcut-style 'qwerty)
  (setq switch-window-qwerty-shortcuts
        '("a" "o" "e" "u" "i" "d" "h" "t" "n" "s"))

restart emacs custom

  (defun my/exwm-restart ()
    "Restart EXWM."
    (interactive)
    (exwm--log)
    (when (exwm--confirm-kill-emacs "[EXWM] Restart? " 'no-check)
      (let* ((attr (process-attributes (emacs-pid)))
             (args (cdr (assq 'args attr)))
             (ppid (cdr (assq 'ppid attr)))
             (pargs (cdr (assq 'args (process-attributes ppid)))))
        (shell-command "emacs & disown")
        (kill-emacs))))