summaryrefslogtreecommitdiff
path: root/.config/emacs/modules/bd--exwm-windowing.el
blob: 7f52d2acfc9ad408ff29722bcdd070cf5070643a (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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
;;; -*- lexical-binding: t; -*-
;;; Commentary:
;;; Code:


(defun bd/lock ()
  "Lock the screen."
  (interactive)
  (start-process "lock" nil "slock"))

(defun bd/shoot-full ()
  "Take a full-screen screenshot."
  (interactive)
  (let ((default-directory (xdg-user-dir "PICTURES")))
    (start-process-shell-command "flameshot" nil "flameshot full")))

(defun bd/shoot-part ()
  "Take a selective screen screenshot."
  (interactive)
  (let ((default-directory (xdg-user-dir "PICTURES")))
    (start-process-shell-command "flameshot" nil "flameshot launcher")))

(defun bd/toggle-mute ()
  "Toggle between muted and unmuted."
  (interactive)
  (start-process "sound toggle" nil "pactl" "set-sink-mute" "@DEFAULT_SINK@" "toggle"))

(defun bd/set-volume (value)
  "Sets the volume to VALUE."
  (start-process "set volume" nil "pactl" "set-sink-volume" "@DEFAULT_SINK@" value))

(defun bd/decrement-volume ()
  "Decrements the volume."
  (interactive)
  (bd/set-volume "-4%"))

(defun bd/increment-volume ()
  "Increments the volume."
  (interactive)
  (bd/set-volume "+4%"))

(defun bd/set-brightness (value)
  "Sets the brightness to VALUE."
  (start-process "set brightness" nil "brightnessctl" "set" value))

(defun bd/decrement-brightness ()
  "decrements the brightness."
  (interactive)
  (bd/set-brightness "5%-"))

(defun bd/increment-brightness ()
  "Increments the brightness."
  (interactive)
  (bd/set-brightness "5%+"))


(use-package exwm
  :config
  (defun bd/exwm-update-title ()
    "Changes the buffer name to reflect the class name for
that buffer."
    (exwm-workspace-rename-buffer exwm-title))
  (add-hook 'exwm-update-title-hook #'bd/exwm-update-title)

  (define-key exwm-mode-map [?\C-q] 'exwm-input-send-next-key)
  (exwm-enable)
  (server-start)
  :custom
  (exwm-input-prefix-keys
   `(?\C-x
     ?\C-u
     ?\C-g
     ?\C-h
     ?\C-z
     ?\C-`
     ?\M-x
     ?\M-`
     ?\M-&
     ?\M-:
     ,@(mapcar (lambda (i)
                 (kbd (concat "s-" (number-to-string i))))
               (number-sequence 0 9))))
  (exwm-input-global-keys
   '(([?\s-n] . other-window)
     ([?\s-p] . (lambda ()
                  (interactive)
                  (other-window -1)))
     ([?\s-L] . bd/lock)
     ([f2] . bd/toggle-mute)
     ([f5] . bd/decrement-volume)
     ([f6] . bd/increment-volume)
     ([f7] . bd/decrement-brightness)
     ([f8] . bd/increment-brightness)
     ([f9] . emms-previous)
     ([f10] . emms-next)
     ([print] . bd/shoot-part)
     ([S-print] . bd/shoot-full)
     ([?\s-O] . bd/visit-bookmark)
     ([?\s-P] . bd/password)
     ([?\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)))))
  (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])
     ([?\C-s] . [C-g])
     ([?\C-r] . [C-S-g])
     ([?\M-d] . [C-delete])
     ([?\M-b] . [C-left])
     ([?\M-f] . [C-right])
     ([?\H-b] . [M-left])
     ([?\H-f] . [M-right]))))

(setopt tab-bar-select-tab-modifiers '(super))

(defvar new-mode-line nil)
(defun set-new-mode-line ()
  "Return the current value of my-custom-variable for the mode line."
  (setq new-mode-line
        (replace-regexp-in-string
         "%" "%%"
         (format "[%s] [%s]"
                 (shell-command-to-string "/home/bdunahu/.local/bin/mail-string 2>/dev/null")
		 (shell-command-to-string "/home/bdunahu/.local/bin/t1-string 2>/dev/null")))))

(defvar-local bd/external-mode-line
    '(:eval (when new-mode-line
              new-mode-line)))

(run-with-timer t 30 #'set-new-mode-line)
(add-to-list 'global-mode-string bd/external-mode-line)

(provide 'bd--exwm-windowing)
;;; bd-exwm ends here