summaryrefslogtreecommitdiff
path: root/.config/emacs/modules/bd--exwm-windowing.el
diff options
context:
space:
mode:
authorbd <bdunahu@colostate.edu>2024-01-10 19:44:21 -0700
committerbd <bdunahu@colostate.edu>2024-01-10 19:44:21 -0700
commit1ced565816120bfcc351daf9fc3a4e851162e3b7 (patch)
tree93e9c23660cd07f4dba861f334b23c03d322f48c /.config/emacs/modules/bd--exwm-windowing.el
parentda5922a476cebdbbf338f0192165dbbbcd3f7b6f (diff)
Initial commit of new repository structure
Diffstat (limited to '.config/emacs/modules/bd--exwm-windowing.el')
-rw-r--r--.config/emacs/modules/bd--exwm-windowing.el168
1 files changed, 168 insertions, 0 deletions
diff --git a/.config/emacs/modules/bd--exwm-windowing.el b/.config/emacs/modules/bd--exwm-windowing.el
new file mode 100644
index 0000000..a275f5a
--- /dev/null
+++ b/.config/emacs/modules/bd--exwm-windowing.el
@@ -0,0 +1,168 @@
+;; -*- lexical-binding: t; -*-
+
+
+;;;; utilities
+;; desktop
+(use-package desktop-environment
+ :custom
+ (desktop-environment-screenshot-directory (xdg-user-dir "PICTURES"))
+ (desktop-environment-screenshot-command "flameshot full")
+ (desktop-environment-screenshot-partial-command "flameshot launcher"))
+
+
+(defun bd/exwm-update-class ()
+ "Changes the buffer name to reflect the class name for
+that buffer."
+ (exwm-workspace-rename-buffer exwm-class-name))
+
+(defun bd/exwm-init-hook ()
+ "Make workspace 1 the default startup workspace."
+ (exwm-workspace-switch-create 1))
+
+
+(defun toggle-current-window-dedication ()
+ "Adds or revokes dedicated window status from a buffer. A
+dedicated buffer will never be automatically orphaned."
+ (interactive)
+ (let* ((window (selected-window))
+ (dedicated (window-dedicated-p window)))
+ (set-window-dedicated-p window (not dedicated))
+ (message "Window %sdedicated to %s"
+ (if dedicated "no longer " "")
+ (buffer-name))))
+
+
+;;;; bookmarks, passwords
+(defun insert-bookmark ()
+ "Inserts a url or string from permanent
+bookmark file. If an x window, place in kill-ring."
+ ;; note xdotool had issues with repeated keys when sending to windowid
+ (interactive)
+ (let ((url (car (last (split-string (choose-line-from-file "~/Personal/scripts/bookmarks.txt"))))))
+ (if (exwm--buffer->id (current-buffer))
+ (kill-new url)
+ (insert url))))
+
+(defun choose-line-from-file (file)
+ "Uses completion-framework to allow user to
+select a line from a file."
+ (let* ((choices (read-file-into-list file)))
+ (completing-read "Recall: " choices)))
+
+(defun read-file-into-list (file)
+ (with-current-buffer
+ (find-file-noselect file)
+ (split-string
+ (save-restriction
+ (widen)
+ (buffer-substring-no-properties
+ (point-min)
+ (point-max)))
+ "\n" t)))
+
+(use-package password-store
+ :custom
+ (password-store-time-before-clipboard-restore 20)
+ (define-key global-map (kbd "C-c k") #'password-store-copy))
+
+;; emacs-pinentry; wonderful in EXWM, has security flaws
+(use-package pinentry
+ :init
+ (pinentry-start)
+ :custom
+ (pinentry-popup-prompt-window nil))
+
+
+(use-package exwm
+ :config
+ (add-hook 'exwm-init-hook #'bd/exwm-init-hook)
+ (add-hook 'exwm-update-class-hook #'bd/exwm-update-class)
+ ;; order is important
+ (require 'exwm-randr)
+ (exwm-randr-enable)
+ ;; because my nvidia driver is currently unsupported with nouveau,
+ ;; xrandr seems to be entirely broken. This line is only here for
+ ;; future reference
+ ;;(start-process-shell-command "xrandr" nil (expand-file-name "exwm_xrandr.sh" user-emacs-directory))
+ (start-process-shell-command "picom" nil "picom")
+ (start-process-shell-command "bg" nil "set-bg")
+ (start-process-shell-command "xrate" nil "xset r rate 250 70")
+
+ (dolist (k '(("s-B" "icecat")))
+ (let ((f (lambda () (interactive)
+ (save-window-excursion
+ (start-process-shell-command (cadr k) nil (cadr k))))))
+ (exwm-input-set-key (kbd (car k)) f)
+ (define-key exwm-mode-map (kbd (car k)) f)))
+
+ (define-key exwm-mode-map [?\C-q] 'exwm-input-send-next-key)
+ (exwm-enable)
+ (server-start)
+ :custom
+ (exwm-workspace-number 10) ; puts scratch buffer everywhere
+ (exwm-input-prefix-keys
+ '(?\C-x
+ ?\C-u
+ ?\C-g
+ ?\C-h
+ ?\C-z
+ ?\M-x
+ ?\M-`
+ ?\M-&
+ ?\M-: ))
+ (exwm-input-global-keys
+ `(([?\s-n] . other-window)
+ ([?\s-p] . (lambda ()
+ (interactive)
+ (other-window -1)))
+ ([?\s-L] . desktop-environment-lock-screen)
+ ([f2] . desktop-environment-brightness-decrement)
+ ([f3] . desktop-environment-brightness-increment)
+ ([f7] . emms-volume-lower)
+ ([f8] . emms-volume-raise)
+ ([f9] . emms-next)
+ ([f10] . emms-pause)
+ ([f11] . emms-previous)
+ ([print] . desktop-environment-screenshot-part)
+ ([S-print] . desktop-environment-screenshot)
+ ([?\s-O] . insert-bookmark)
+ ([?\s-P] . password-store-copy)
+ ([?\s-r] . exwm-reset)
+ ([?\s-d] . toggle-current-window-dedication)
+ ([?\s-q] . kill-current-buffer)
+ ([?\s-x] . (lambda (command)
+ (interactive (list (read-shell-command "s-x ")))
+ (start-process-shell-command command nil command)))
+ ,@(mapcar (lambda (i)
+ `(,(kbd (format "s-%d" i)) .
+ (lambda ()
+ (interactive)
+ (exwm-workspace-switch-create ,i))))
+ (number-sequence 0 9))))
+ (exwm-input-simulation-keys
+ '(([?\C-b] . [left])
+ ([?\C-f] . [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 delete])
+ ([?\M-w] . [C-c])
+ ([?\C-y] . [C-v])))
+
+ ;; ,@(mapcar (lambda (i)
+ ;; `(,(kbd (format "s-%s" (car i))) .
+ ;; (lambda ()
+ ;; (interactive
+ ;; (exwm-workspace-switch-create ,(car (cdr i)))))))
+ ;; '((! 0) (@ 1) (\# 2) ($ 3) (% 4) (^ 5) (& 6) (* 7) (\( 8) (\) 9)))))
+
+ (exwm-workspace-show-all-buffers t)
+ (exwm-layout-show-all-buffers t)
+ (exwm-randr-workspace-monitor-plist '(0 "HDMI-1" 6 "HDMI-1" 7 "HDMI-1" 8 "HDMI-1" 9 "HDMI-1")))
+
+
+(provide 'bd--exwm-windowing)