Skip to content

Commit

Permalink
Add initial EXWM config from Desktop Environment daviwil#1
Browse files Browse the repository at this point in the history
  • Loading branch information
daviwil committed Nov 13, 2020
1 parent abdf4ac commit 219c060
Show file tree
Hide file tree
Showing 8 changed files with 427 additions and 0 deletions.
80 changes: 80 additions & 0 deletions Emacs.org
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,86 @@ Dired is a built-in file manager for Emacs that does some pretty amazing things!

#+end_src

* Window Management

** EXWM Configuration

We use the excellent [[https://github.com/ch11ng/exwm][EXWM]] module as the basis for our Emacs Desktop Environment. The [[https://github.com/ch11ng/exwm/wiki][EXWM Wiki]] is a great place to find tips about how to configure everything!

#+begin_src emacs-lisp

(defun efs/exwm-update-class ()
(exwm-workspace-rename-buffer exwm-class-name))

(use-package exwm
:config
;; Set the default number of workspaces
(setq exwm-workspace-number 5)

;; When window "class" updates, use it to set the buffer name
(add-hook 'exwm-update-class-hook #'efs/exwm-update-class)

;; Rebind CapsLock to Ctrl
(start-process-shell-command "xmodmap" nil "xmodmap ~/.emacs.d/exwm/Xmodmap")

;; Set the screen resolution (update this to be the correct resolution for your screen!)
(require 'exwm-randr)
(exwm-randr-enable)
;; (start-process-shell-command "xrandr" nil "xrandr --output Virtual-1 --primary --mode 2048x1152 --pos 0x0 --rotate normal")

;; Load the system tray before exwm-init
(require 'exwm-systemtray)
(exwm-systemtray-enable)

;; These keys should always pass through to Emacs
(setq exwm-input-prefix-keys
'(?\C-x
?\C-u
?\C-h
?\M-x
?\M-`
?\M-&
?\M-:
?\C-\M-j ;; Buffer list
?\C-\ )) ;; Ctrl+Space

;; Ctrl+Q will enable the next key to be sent directly
(define-key exwm-mode-map [?\C-q] 'exwm-input-send-next-key)

;; Set up global key bindings. These always work, no matter the input state!
;; Keep in mind that changing this list after EXWM initializes has no effect.
(setq exwm-input-global-keys
`(
;; Reset to line-mode (C-c C-k switches to char-mode via exwm-input-release-keyboard)
([?\s-r] . exwm-reset)

;; Move between windows
([s-left] . windmove-left)
([s-right] . windmove-right)
([s-up] . windmove-up)
([s-down] . windmove-down)

;; Launch applications via shell command
([?\s-&] . (lambda (command)
(interactive (list (read-shell-command "$ ")))
(start-process-shell-command command nil command)))

;; Switch workspace
([?\s-w] . exwm-workspace-switch)
([?\s-`] . (lambda () (interactive) (exwm-workspace-switch-create 0)))

;; 's-N': Switch to certain workspace with Super (Win) plus a number key (0 - 9)
,@(mapcar (lambda (i)
`(,(kbd (format "s-%d" i)) .
(lambda ()
(interactive)
(exwm-workspace-switch-create ,i))))
(number-sequence 0 9))))

(exwm-enable))

#+end_src

* Applications

** Some App
Expand Down
8 changes: 8 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ If you're enjoying the videos and benefitting from the examples in this repo, pl

* Episodes

This repo now contains configuration from multiple series on the channel!

** [[https://www.youtube.com/playlist?list=PLEoMzSkcN8oPH1au7H6B7bBJ4ZO7BXjSZ][Emacs From Scratch]]

Here is a list of all the episode videos with links to the configuration we built for each one:

1. [[https://www.youtube.com/watch?v=74zOY-vgkyw][Live-Coding a Custom Emacs Configuration from Scratch]] ([[https://github.com/daviwil/emacs-from-scratch/tree/c0266ff684f670ecc5e41615c0282912e6615214][Code]])
Expand All @@ -21,6 +25,10 @@ Here is a list of all the episode videos with links to the configuration we buil
9. [[https://youtu.be/wa_wZIuT9Vw][Learn to Love the Terminal Modes]] ([[https://github.com/daviwil/emacs-from-scratch/tree/bbfbc77b3afab0c14149e07d0ab08d275d4ba575][Code]])
10. [[https://youtu.be/PMWwM8QJAtU][Effortless File Management with Dired]] ([[https://github.com/daviwil/emacs-from-scratch/blob/8c302a79bf5700f6ef0279a3daeeb4123ae8bd59/Emacs.org#dired][Code]])

** [[https://www.youtube.com/playlist?list=PLEoMzSkcN8oNPbEMYEtswOVTvq7CVddCS][Emacs Desktop Environment]]

1. [[https://www.youtube.com/watch?v=f7xB2fFk1tQ][Getting Started with EXWM]] (Code, [[file:show-notes/Emacs-Desktop-01.org][Notes]])

* Usage Instructions

*IMPORTANT:* Be sure to read the commentary in [[file:Emacs.org][Emacs.org]] in case anything unexpected happens when you load this configuration. Feel free to [[https://github.com/daviwil/runemacs/issues][file an issue]] to discuss any questions or problems you have so we can discuss it in a future stream!
Expand Down
8 changes: 8 additions & 0 deletions exwm/EXWM.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Desktop Entry]
Name=EXWM
Comment=Emacs Window Manager
Exec=sh /home/daviwil/.emacs.d/exwm/start-exwm.sh
TryExec=sh
Type=Application
X-LightDM-DesktopName=exwm
DesktopNames=exwm
5 changes: 5 additions & 0 deletions exwm/Xmodmap
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
clear lock
clear control
keycode 66 = Control_L
add control = Control_L
add Lock = Control_R
1 change: 1 addition & 0 deletions exwm/Xresources
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Xft.dpi: 100 # Set this to your desired DPI! Larger number means bigger text and UI
7 changes: 7 additions & 0 deletions exwm/start-exwm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

# Set the screen DPI (uncomment this if needed!)
# xrdb ~/.emacs.d/exwm/Xresources

# Fire it up
exec dbus-launch --exit-with-session emacs -mm --debug-init
70 changes: 70 additions & 0 deletions init.el
Original file line number Diff line number Diff line change
Expand Up @@ -522,3 +522,73 @@
:config
(evil-collection-define-key 'normal 'dired-mode-map
"H" 'dired-hide-dotfiles-mode))

(defun efs/exwm-update-class ()
(exwm-workspace-rename-buffer exwm-class-name))

(use-package exwm
:config
;; Set the default number of workspaces
(setq exwm-workspace-number 5)

;; When window "class" updates, use it to set the buffer name
(add-hook 'exwm-update-class-hook #'efs/exwm-update-class)

;; Rebind CapsLock to Ctrl
(start-process-shell-command "xmodmap" nil "xmodmap ~/.emacs.d/exwm/Xmodmap")

;; Set the screen resolution (update this to be the correct resolution for your screen!)
(require 'exwm-randr)
(exwm-randr-enable)
;; (start-process-shell-command "xrandr" nil "xrandr --output Virtual-1 --primary --mode 2048x1152 --pos 0x0 --rotate normal")

;; Load the system tray before exwm-init
(require 'exwm-systemtray)
(exwm-systemtray-enable)

;; These keys should always pass through to Emacs
(setq exwm-input-prefix-keys
'(?\C-x
?\C-u
?\C-h
?\M-x
?\M-`
?\M-&
?\M-:
?\C-\M-j ;; Buffer list
?\C-\ )) ;; Ctrl+Space

;; Ctrl+Q will enable the next key to be sent directly
(define-key exwm-mode-map [?\C-q] 'exwm-input-send-next-key)

;; Set up global key bindings. These always work, no matter the input state!
;; Keep in mind that changing this list after EXWM initializes has no effect.
(setq exwm-input-global-keys
`(
;; Reset to line-mode (C-c C-k switches to char-mode via exwm-input-release-keyboard)
([?\s-r] . exwm-reset)

;; Move between windows
([s-left] . windmove-left)
([s-right] . windmove-right)
([s-up] . windmove-up)
([s-down] . windmove-down)

;; Launch applications via shell command
([?\s-&] . (lambda (command)
(interactive (list (read-shell-command "$ ")))
(start-process-shell-command command nil command)))

;; Switch workspace
([?\s-w] . exwm-workspace-switch)
([?\s-`] . (lambda () (interactive) (exwm-workspace-switch-create 0)))

;; 's-N': Switch to certain workspace with Super (Win) plus a number key (0 - 9)
,@(mapcar (lambda (i)
`(,(kbd (format "s-%d" i)) .
(lambda ()
(interactive)
(exwm-workspace-switch-create ,i))))
(number-sequence 0 9))))

(exwm-enable))
Loading

0 comments on commit 219c060

Please sign in to comment.