exwm, edwina, and startup optimizations

This commit is contained in:
Rachel Lambda Samuelsson 2022-12-01 09:02:21 +01:00
parent b667b54963
commit a8cdbea488
5 changed files with 133 additions and 13 deletions

View File

@ -16,3 +16,8 @@
`((".*" . ,temporary-file-directory))) `((".*" . ,temporary-file-directory)))
(setq auto-save-file-name-transforms (setq auto-save-file-name-transforms
`((".*" ,temporary-file-directory t))) `((".*" ,temporary-file-directory t)))
;; Don't remove current window when opening new ones
(setq display-buffer-base-action '(display-buffer-below-selected))
(setq display-buffer-overriding-action '(display-buffer-below-selected))
(setq display-buffer-fallback-action '(display-buffer-below-selected))

48
exwm.el
View File

@ -1,7 +1,11 @@
(require 'exwm) (require 'exwm)
(require 'exwm-config) (require 'exwm-systemtray)
(require 'edwina)
(display-battery-mode) (exwm-systemtray-enable)
(display-battery-mode 1)
(display-time-mode 1)
(defun discord () (defun discord ()
(interactive) (interactive)
@ -12,4 +16,42 @@
(interactive) (interactive)
(start-process "firefox" nil "firefox")) (start-process "firefox" nil "firefox"))
(exwm-config-example) (setq exwm-input-global-keys
`((,(kbd "s-E") . exwm-exit)
(,(kbd "s-Q") . evil-quit)
(,(kbd "s-w") . exwm-workspace-switch)
;; Windowing
(,(kbd "s-h") . edwina-dec-mfact)
(,(kbd "s-j") . edwina-select-next-window)
(,(kbd "s-k") . edwina-select-previous-window)
(,(kbd "s-l") . edwina-inc-mfact)
(,(kbd "s-J") . edwina-swap-next-window)
(,(kbd "s-K") . edwina-swap-previous-window)
(,(kbd "s-r") . exwm-reset)
(,(kbd "s-f") . exwm-layout-set-fullscreen)
;; Applications
(,(kbd "s-<backspace>") . firefox)
(,(kbd "s-<return>") . vterm)
;; Workspaces
,@(mapcar (lambda (i)
`(,(kbd (format "s-%d" i)) .
(lambda ()
(interactive)
(exwm-workspace-switch-create ,i))))
(number-sequence 0 9))))
(add-hook 'exwm-update-class-hook
(lambda () (exwm-workspace-rename-buffer exwm-class-name)))
(edwina-mode)
(add-hook 'after-make-frame-functions 'edwina-arrange)
(add-hook 'delete-frame-functions 'edwina-arrange)
(setq exwm-manage-force-tiling 1)
(exwm-init)

88
init.el
View File

@ -1,3 +1,77 @@
;;; -*- lexical-binding: t; -*-
;;; BEGIN OPTIMIZATION
;; Optimizations (mostly taken from doom)
(defvar init-done-hook nil)
;; Don't garbage collect during init
(add-hook 'init-done-hook
`(lambda () (setq gc-cons-threshold
,(default-toplevel-value 'gc-cons-threshold))))
(setq gc-cons-threshold most-positive-fixnum)
;; Don't use file type handlers during init
(let ((old-value (default-toplevel-value 'file-name-handler-alist)))
(setq file-name-handler-alist nil)
(set-default-toplevel-value 'file-name-handler-alist file-name-handler-alist)
(put 'file-name-handler-alist 'initial-value old-value)
(add-hook 'init-done-hook
(lambda ()
(setq file-name-handler-alist
;; Merge instead of overwrite because there may have been changes to
;; `file-name-handler-alist' since startup we want to preserve.
(delete-dups (append file-name-handler-alist old-value))))))
;; Don't resize during init
(setq frame-inhibit-implied-resize t)
(setq inhibit-startup-screen t
inhibit-startup-echo-area-message user-login-name)
(advice-add #'display-startup-echo-area-message :override #'ignore)
(advice-add #'display-startup-screen :override #'ignore)
;; Don't use advanced modes for scratch buffer
(setq initial-major-mode 'fundamental-mode
initial-scratch-message nil)
;; Don't cause rewrites when loading file
(define-advice load-file (:override (file) silence) (load file nil 'nomessage))
(define-advice startup--load-user-init-file (:before (&rest _) undo-silence)
(advice-remove #'load-file #'load-file@silence))
;; Disable modeline
(put 'mode-line-format 'initial-value (default-toplevel-value 'mode-line-format))
(setq-default mode-line-format nil)
(dolist (buf (buffer-list))
(with-current-buffer buf (setq mode-line-format nil)))
;; Inhibit redraws
(setq-default inhibit-redisplay t
inhibit-message t)
(defun reset-inhibited-vars-h ()
(setq-default inhibit-redisplay nil
;; Inhibiting `message' only prevents redraws and
inhibit-message nil)
(redraw-frame))
(add-hook 'after-init-hook #'reset-inhibited-vars-h)
(define-advice startup--load-user-init-file (:after (&rest _) undo-inhibit-vars)
(when init-file-had-error
(reset-inhibited-vars-h))
(unless (default-toplevel-value 'mode-line-format)
(setq-default mode-line-format (get 'mode-line-format 'initial-value))))
;; Don't load toolbar
(advice-add #'tool-bar-setup :override #'ignore)
(define-advice startup--load-user-init-file (:before (&rest _) defer-tool-bar-setup)
(advice-remove #'tool-bar-setup #'ignore)
(add-transient-hook! 'tool-bar-mode (tool-bar-setup)))
;; Don't bother with MACOS exclusive options
(setq command-line-ns-option-alist nil)
;;; END OPTIMIZATION
;; Packages ;; Packages
(require 'package) (require 'package)
(setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/") (setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
@ -29,20 +103,19 @@
;; Exwm ;; Exwm
(include "exwm.el") (include "exwm.el")
;; Don't touch
(custom-set-variables (custom-set-variables
;; custom-set-variables was added by Custom. ;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful. ;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance. ;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right. ;; If there is more than one, they won't work right.
'(elcord-display-buffer-details nil) '(display-time-24hr-format t)
'(elcord-mode t nil (elcord)) '(display-time-default-load-average nil)
'(elcord-quiet t) '(display-time-interval 15)
'(elcord-use-major-mode-as-main-icon t) '(display-time-mode t)
'(evil-undo-system 'undo-tree) '(evil-undo-system 'undo-tree)
'(org-agenda-files '("/home/deppy/doc/org/todo.org")) '(org-agenda-files '("/home/deppy/doc/org/todo.org"))
'(package-selected-packages '(package-selected-packages
'(exwm elcord org-superstar org-fragtog org-pretty-tags visual-fill writeroom-mode haskell-emacs treemacs-evil treemacs solarized-theme doom-modeline all-the-icons-dired page-break-lines all-the-icons dashboard org-evil zotero vterm magit undo-fu latex-math-preview use-package haskell-mode evil-surround undo-tree evil-org evil)) '(edwina markdown-preview-mode markdown-mode exwm org-superstar org-fragtog org-pretty-tags visual-fill writeroom-mode haskell-emacs treemacs-evil treemacs solarized-theme doom-modeline all-the-icons-dired page-break-lines all-the-icons dashboard org-evil zotero vterm magit undo-fu latex-math-preview use-package haskell-mode evil-surround undo-tree evil-org evil))
'(warning-suppress-log-types '((comp))) '(warning-suppress-log-types '((comp)))
'(warning-suppress-types '((comp))) '(warning-suppress-types '((comp)))
'(writeroom-mode-line t) '(writeroom-mode-line t)
@ -61,3 +134,6 @@
'(bookmark-face ((t (:foreground "#fdf6e3")))) '(bookmark-face ((t (:foreground "#fdf6e3"))))
'(mode-line ((t (:underline nil :overline nil)))) '(mode-line ((t (:underline nil :overline nil))))
'(mode-line-inactive ((t (:underline nil :overline nil))))) '(mode-line-inactive ((t (:underline nil :overline nil)))))
;; Reset values
(run-hooks 'init-done-hook)

View File

@ -17,6 +17,3 @@
(python . t) (python . t)
(java . t) (java . t)
(haskell . t))) (haskell . t)))
(require 'elcord)
(elcord-mode)

View File

@ -23,7 +23,7 @@
;; Tool bar mode ;; Tool bar mode
(menu-bar-mode -1) (menu-bar-mode -1)
(tool-bar-mode -1) (tool-bar-mode -1)
(toggle-scroll-bar -1) (scroll-bar-mode -1)
;; Images ;; Images
(setq image-use-external-converter t) (setq image-use-external-converter t)