(defun launch-alacritty()
(interactive)
(start-process-shell-command "alacritty" nil "alacritty"))
(exwm-input-set-key (kbd "C-s-t") 'launch-alacritty)
(defun alacritty-toggle-theme()
(interactive)
(call-process-shell-command "bash ~/.scripts/alacritty-theme-toggle.sh"))
(defun launch-chromium()
(interactive)
(start-process-shell-command "chromium" nil "chromium"))
(exwm-input-set-key (kbd "C-c c") 'launch-chromium)
(defun launch-chromium-incognito()
(interactive)
(start-process-shell-command "chromium" nil "chromium --incognito"))
(exwm-input-set-key (kbd "C-c C") 'launch-chromium-incognito)
(require 'exwm-randr)
(setq exwm-randr-workspace-output-plist '(0 "HDMI-0"
1 "HDMI-0"
2 "HDMI-0"
3 "HDMI-0"
4 "HDMI-0"
5 "DP-2"
6 "DP-2"))
(exwm-randr-enable)
(defun display-vertical()
(interactive)
(start-process-shell-command
"xrandr" nil "xrandr --output HDMI-0 --primary --mode 2560x1440 --pos 0x0 --rotate left --output DP-2 --off --output DP-1 --off --output DP-0 --off"))
(defun display-horizontal()
(interactive)
(start-process-shell-command
"xrandr" nil "xrandr --output HDMI-0 --primary --mode 2560x1440 --pos 0x0 --rotate normal --output DP-2 --off --output DP-1 --off --output DP-0 --off"))
(defun display-laptop()
(interactive)
(start-process-shell-command
"xrandr" nil "xrandr --output HDMI-0 --off --output DP-2 --primary --mode 1920x1080 --pos 0x0 --rotate normal --output DP-1 --off --output DP-0 --off"))
(defun launch-filezilla()
(interactive)
(start-process-shell-command "filezilla" nil "export FZ_DATADIR=/nix/store/fz6yww82878pbww35q4q8nfg0lcg7gl3-filezilla-3.31.0/share/filezilla/resources/ && filezilla"))
(key-chord-define-global "fz" 'launch-filezilla)
(defun launch-firefox()
(interactive)
(start-process-shell-command "firefox" nil "firefox"))
(exwm-input-set-key (kbd "C-c f") 'launch-firefox-fullscreen)
(key-chord-define-global "cf" 'launch-firefox-fullscreen)
(key-chord-define-global "sf" 'launch-firefox-fullscreen)
(defun launch-firefox-fullscreen()
(interactive)
(start-process-shell-command "firefox fullscreen" nil "firefox -P fullscreen"))
(defun launch-firefox-private()
(interactive)
(start-process-shell-command "firefox private" nil "firefox --private-window -P fullscreen"))
(exwm-input-set-key (kbd "C-c F") 'launch-firefox-private)
(key-chord-define-global "cF" 'launch-firefox-private)
(defun open-lastpass()
(interactive)
(if (string= exwm-class-name "Firefox")
(progn
(exwm-input--fake-key 'C-l)
(run-with-idle-timer 0.05 nil (lambda()
(interactive)
(exwm-input--fake-key 'tab)
(exwm-input--fake-key 'tab)
(exwm-input--fake-key 'return)
(run-with-idle-timer 0.5 nil (lambda()
(interactive)
(exwm-input--fake-key 'down)
(exwm-input--fake-key 'down)
(exwm-input--fake-key 'down)
(exwm-input--fake-key 'down)
(exwm-input--fake-key 'down)
(exwm-input--fake-key 'down)
(exwm-input--fake-key 'right)
)))))
(progn
(exwm-input--fake-key 'C-L)
(run-with-idle-timer 0.5 nil (lambda()
(interactive)
(exwm-input--fake-key 'down)
(exwm-input--fake-key 'down)
(exwm-input--fake-key 'down)
(exwm-input--fake-key 'down)
(exwm-input--fake-key 'down)
(exwm-input--fake-key 'down)
(exwm-input--fake-key 'right)
)))))
(exwm-input-set-key (kbd "M-s-l") 'open-lastpass)
(exwm-input-set-key (kbd "C-S-l") 'open-lastpass)
(exwm-input-set-key (kbd "<S-XF86PowerOff>") (lambda () (interactive) (shell-command "slock")))
(defun launch-insomnia()
(interactive)
(start-process-shell-command "insomnia" nil "insomnia"))
(setq exwm-enable-ido-workaround t)
(setq exwm-workspace-display-echo-area-timeout 0.5)
(setq exwm-workspace--attached-minibuffer-height -32)
(defun exwm-workspace--echo-area-maybe-clear ()
"Eventually clear the echo area container."
(exwm--log)
(if (not (current-message))
(exwm-workspace--on-echo-area-clear)
;; in case the echo area is detached, clean echo area so it doesn't block the modeline
;; but with a delay so user can view the echoed message
(when (exwm-workspace--minibuffer-own-frame-p)
(unless (exwm-workspace--minibuffer-attached-p)
;; cancel previous timer if one is set
(cancel-function-timers 'exwm-workspace--on-echo-area-clear)
(run-with-timer exwm-workspace-display-echo-area-timeout nil
#'exwm-workspace--on-echo-area-clear)))
;; Reschedule.
(cancel-timer exwm-workspace--display-echo-area-timer)
(setq exwm-workspace--display-echo-area-timer
(run-with-timer exwm-workspace-display-echo-area-timeout nil
#'exwm-workspace--echo-area-maybe-clear))))
(defun open-url-from-clipboard()
(interactive)
(start-process-shell-command "Firefox" nil (concat "firefox --new-window '" (substring-no-properties (car kill-ring)) "'")))
(exwm-input-set-key (kbd "M-S") 'open-url-from-clipboard)
(defun toggle-polybar()
(interactive)
(if (string= "" (shell-command-to-string "ps aux | grep [p]olybar"))
(launch-polybar)
(kill-polybar)))
(exwm-input-set-key (kbd "s-\\") 'toggle-polybar)
(defun launch-polybar()
(interactive)
(call-process-shell-command "nm-applet" nil 0)
(call-process-shell-command "pasystray" nil 0)
(call-process-shell-command "blueman-applet" nil 0)
(call-process-shell-command "polybar topbar &")
(setq exwm-workspace--workareas '(
[0 32 1920 1048]
[0 32 1920 1048]
[0 32 1920 1048]
[0 32 1920 1048]
[0 32 1920 1048]
[0 32 1920 1048]
[0 32 1920 1048]
[0 32 1920 1048]
[0 32 1920 1048]
[0 32 1920 1048]))
(run-hooks 'exwm-workspace-switch-hook))
(defun kill-polybar()
(interactive)
(call-process-shell-command "kill $(ps aux | grep nm-applet | awk '{print $2}')")
(call-process-shell-command "kill $(ps aux | grep pasystray | awk '{print $2}')")
(call-process-shell-command "kill $(ps aux | grep blueman-applet | awk '{print $2}')")
(call-process-shell-command "kill $(ps aux | grep polybar | awk '{print $2}')")
(setq exwm-workspace--workareas '(
[0 0 1920 1080]
[0 0 1920 1080]
[0 0 1920 1080]
[0 0 1920 1080]
[0 0 1920 1080]
[0 0 1920 1080]
[0 0 1920 1080]
[0 0 1920 1080]
[0 0 1920 1080]
[0 0 1920 1080]))
(run-hooks 'exwm-workspace-switch-hook))
(defun prepare-workstation()
(interactive)
(launch-slack)
(exwm-workspace-switch 2)
(run-with-idle-timer 0.15 nil (lambda() (interactive)
(start-process-shell-command "GMail" nil "firefox -P fullscreen --new-window https://mail.google.com/mail/u/0/")))
(run-with-idle-timer 0.5 nil (lambda() (interactive)
(exwm-workspace-switch 3)
(start-process-shell-command "HelpScout" nil "firefox -P fullscreen --new-window https://secure.helpscout.net/mailbox/aa97b20d6be7aedb/")))
(run-with-idle-timer 1 nil (lambda() (interactive)
(exwm-workspace-switch 4)
(start-process-shell-command "Toggl" nil "firefox -P fullscreen --new-window https://toggl.com/app/timer")))
(run-with-idle-timer 1.5 nil (lambda() (interactive)
(exwm-workspace-switch 1))))
(defun search-from-clipboard()
(interactive)
(start-process-shell-command "Firefox" nil (concat "firefox --new-window 'https://duckduckgo.com/?q=" (substring-no-properties (car kill-ring)) "'")))
(exwm-input-set-key (kbd "M-s-s") 'search-from-clipboard)
(defun exwm-rename-buffer ()
(interactive)
(setq exwm-title-check exwm-title)
(setq title-checker (run-with-idle-timer 1 nil (lambda ()
(interactive)
(when (equal exwm-title-check exwm-title)
(exwm-workspace-rename-buffer
(concat "*"
(if (<= (length exwm-title) 95) exwm-title
(concat (substring exwm-title 0 94) "...")))))
(cancel-timer title-checker)))))
(add-hook 'exwm-update-title-hook 'exwm-rename-buffer)
(exwm-input-set-key (kbd "C-$") (lambda ()
(interactive)
(shell-command "scrot '%Y-%m-%d_$wx$h.png' -e 'mv $f ~/'")))
(setq exwm-input-global-simulation-keys
'(("C-b" . left)
("C-S-b" . S-left)
("C-s-p" . C-p)
("M-b" . C-left)
("M-B" . C-S-left)
("C-f" . right)
("C-S-f" . S-right)
("M-f" . C-right)
("M-F" . C-S-right)
("C-p" . up)
("C-S-p" . S-up)
("C-n" . down)
("C-S-n" . S-down)
("C-s-n" . C-n)
("C-a" . home)
("C-w" . ?\C-c)
("C-S-w" . ?\C-w)
("C-S-a" . S-home)
("C-e" . end)
("C-u" . ?\C-u)
("C-S-e" . S-end)
("C-k" . (home S-end delete backspace))
("C-s-k" . C-k)
("C-l" . (?\C-l ?\C-c))
("C-'" . (\" home \" return))
("C-\"" . (\" end \" return))
("<S-return>" . (end return))
("C-v" . next)
("M-v" . prior)
("M-p" . (home S-end ?\C-c backspace delete up home return up ?\C-v))
("M-P" . C-S-p)
("M-n" . (home S-end ?\C-c backspace delete end return ?\C-v))
("C-," . (home S-end ?\C-c))
("M-N" . C-S-n)
("C-d" . delete)
("M-d" . C-delete)
("C-g" . escape)
("s-g" . escape)
("C-s-x" . ?\C-x)
("C-s-b" . ?\C-b)
("C-s" . ?\C-s)
("s-c" . ?\C-c)
("s-v" . ?\C-v)
("s-[" . M-left)
("s-]" . M-right)
("s-a" . ?\C-a)
("M-s" . ?\C-f)
("C-y" . ?\C-v)
("M-w" . ?\C-c)
("C-S-u" . C-S-f)
("M-I" . C-S-i)
("M-K" . C-S-k)
("S-TAB" . (C-left C-S-right C-c))
("M-<" . C-home)
("M->" . C-end)))
(defun exwm-manage-keys-hook ()
(exwm-input-set-simulation-keys
(mapcar (lambda (c) (cons (kbd (car c)) (cdr c))) exwm-input-global-simulation-keys)))
(add-hook 'exwm-manage-finish-hook 'exwm-manage-keys-hook)
(exwm-enable)
(exwm-input-set-key (kbd "s-i") 'exwm-input-toggle-keyboard)
(defun exwm-toggle-fullscreen()
(interactive)
(exwm-input--fake-key 'f11)
(sleep-for 0.25)
(if (string= exwm-class-name "Firefox")
(progn
(exwm-input--grab-keyboard)
(setq exwm-input-line-mode-passthrough nil))
(progn
(exwm-reset)
(update-modalka-status))))
(exwm-input-set-key (kbd "C-s-f") 'exwm-toggle-fullscreen)
(setq exwm-workspace-number 10)
(exwm-input-set-key (kbd "s-0") (lambda() (interactive) (exwm-workspace-switch 0)))
(exwm-input-set-key (kbd "s-1") (lambda() (interactive) (exwm-workspace-switch 1)))
(exwm-input-set-key (kbd "s-2") (lambda() (interactive) (exwm-workspace-switch 2)))
(exwm-input-set-key (kbd "s-3") (lambda() (interactive) (exwm-workspace-switch 3)))
(exwm-input-set-key (kbd "s-4") (lambda() (interactive) (exwm-workspace-switch 4)))
(exwm-input-set-key (kbd "s-5") (lambda() (interactive) (exwm-workspace-switch 5)))
(exwm-input-set-key (kbd "s-6") (lambda() (interactive) (exwm-workspace-switch 6)))
(exwm-input-set-key (kbd "s-7") (lambda() (interactive) (exwm-workspace-switch 7)))
(exwm-input-set-key (kbd "s-8") (lambda() (interactive) (exwm-workspace-switch 8)))
(exwm-input-set-key (kbd "s-9") (lambda() (interactive) (exwm-workspace-switch 9)))
Adds support for EXWM workspaces to Polybar
(setq exwm-workspace-index-map
(lambda (index)
(let ((named-workspaces ["0"]))
(if (< index (length named-workspaces))
(elt named-workspaces index)
(number-to-string index)))))
(defun exwm-workspace--update-ewmh-desktop-names ()
(xcb:+request exwm--connection
(make-instance 'xcb:ewmh:set-_NET_DESKTOP_NAMES
:window exwm--root :data
(mapconcat (lambda (i) (funcall exwm-workspace-index-map i))
(number-sequence 0 (1- (exwm-workspace--count)))
"\0"))))
(add-hook 'exwm-workspace-list-change-hook
#'exwm-workspace--update-ewmh-desktop-names)
(add-hook 'exwm-init-hook 'exwm-workspace--update-ewmh-desktop-names)