summaryrefslogtreecommitdiff
path: root/.config/emacs/bd-wm.el
blob: 021decbf72a21b8d8964c43208f350b8c37b219f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
;; -*- lexical-binding: t; -*-


(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))))


(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)
  ;; (start-process-shell-command "xrandr" nil "/home/bdunahu/.config/emacs/exwm_xrandr.sh")
  (start-process-shell-command "picom" nil "picom")
  (start-process-shell-command "bg" nil "set-bg")
  (start-process-shell-command "xmodmap" nil "xmodmap ~/.config/xmodmap.config")
  (start-process-shell-command "xrate" nil "xset r rate 250 70")

  (dolist (k '(("s-L" "slock")
               ("s-B" "icecat")
               ("s-O" "xdotool type $(grep -v '^#' /home/bdunahu/Personal/scripts/bookmarks.txt | dmenu -i -l 12 | awk '{print $NF}')")
               ("s-P" "passmenu --type")
               ("<f2>" "brightnessctl set 1%-")
               ("<f3>" "brightnessctl set 1%+")
               ("<f6>" "pactl set-sink-mute @DEFAULT_SINK@ toggle")
               ("<f7>" "pactl set-sink-volume @DEFAULT_SINK@ -10%")
               ("<f8>" "pactl set-sink-volume @DEFAULT_SINK@ +5%")
               ("<f9>" "mpc prev")
               ("<f11>" "mpc next")
               ("<print>" "flameshot launcher")))
    (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-r] . exwm-reset)
     ([?\s-d] . toggle-current-window-dedication)
     ([?\s-q] . kill-current-buffer)
     ;; ([?\s-<f10>] . emms-pause) ; see rest of mpc commands above--mpc pause performed poorly
     ([?\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])))

  ;; ,@(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 "DVI-D-1" 2 "DVI-D-1" 4 "DVI-D-1" 6 "DVI-D-1" 8 "DVI-D-1")))