I showed you my source code, pls respond
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

5.5 KiB

Desktop

/chris/dotfiles/src/commit/6a193d540f71b984a37e7fe00640ff53b9759051/docs/images/desktop-example.png

I use Emacs as a Desktop Environment with the EXWM1 package. It allows Emacs to function as a complete tiling window manager for X112.

Initialization

My workflow includes launching the window manager with Xinit3, without the use of a display manager, controlling everything within Emacs. In addition, compton is used as a display compositor, and slock for a screen lock.

compton &
xss-lock -- slock &

# FIXME! https://github.com/ch11ng/exwm/issues/210#issuecomment-350044271
exec dbus-launch --exit-with-session emacs -mm --debug-init

Create a symbolic link(s)

Xinit3 reads its configuration from ~/.xinitrc. Override this location with a link to the custom configuration.

(dotfiles/symlink "~/.emacs.d/config/xinitrc"
                  "~/.xinitrc")

Desktop environment

Use the desktop-environment package to automatically bind well-known programs for controlling the volume, brightness, media playback, and many other XF86 functionality bindings.

(use-package desktop-environment
  :after exwm
  :custom (desktop-environment-brightness-small-increment "2%+")
          (desktop-environment-brightness-small-decrement "2%-")
          (desktop-environment-brightness-normal-decrement "5%-")
          (desktop-environment-brightness-normal-decrement "5%-")
          (desktop-environment-volume-small-increment "2%+")
          (desktop-environment-volume-small-decrement "2%-")
          (desktop-environment-volume-normal-increment "5%+")
          (desktop-environment-volume-normal-decrement "5%-")
  :config (desktop-environment-mode))
t

Keyboard tweaks

Use XModmap to swap CapsLock and Ctrl to keep common bindings on the home row.

clear lock
clear control

keycode 66 = Control_L

add control = Control_L
add Lock = Control_R
(dotfiles/symlink "~/.emacs.d/config/xmodmap"
                  "~/.Xmodmap")

Browser integration

Write out the $BROWSER variable so other applications can pick up the custom browser.

  • Place custom keybindings for browsing behind SPC b

    • URL with u

    • URL at point with p

    • URL at cursor with c

(setenv "BROWSER" dotfiles/browser)

(dotfiles/leader
  "u" '(:ignore t :which-key "Browse")
  "uu" '(browse-url :which-key "URL")
  "up" '(browse-url-at-point :which-key "Point")
  "uc" '(browse-url-at-cursor :which-key "Cursor"))

Displays detection

When the window manager first launches the init-hook executes, allowing us to define some custom logic.

  • Display time and date

  • Display battery info (if available)

In my personal configuration, I do not want the battery or time displayed within Emacs when it's not running as desktop environment because that information is typically already available.

(defun dotfiles/init-hook ()
  (exwm-workspace-switch-create 1)
  (setq display-time-and-date t)
  (display-battery-mode 1)
  (display-time-mode 1))

Using autorandr with pre configured profiles, switching screens (AKA hot plugging) is also handled through a hook.

(defun dotfiles/update-display ()
  "Update the displays by forcing a change through autorandr."
  (dotfiles/run-in-background "autorandr --change --force"))

Window manager

Connect our custom hooks and configure the input keys, a custom layer for key capture layers.

  • Enable randr support

  • Pass through to Emacs

    • M-x to Emacs

    • C-g to Emacs

    • C-SPC to Emacs

  • Bindings with S (Super / Win)

    • Reset S-r

    • Launch S-&

    • Workspace S-[1..9]

(use-package exwm
  :when (window-system)
  :custom (exwm-workspace-show-all-buffers t)
          (exwm-input-prefix-keys
            '(?\M-x
              ?\C-g
              ?\C-\ ))
          (exwm-input-global-keys
            `(([?\s-r] . exwm-reset)
              ,@(mapcar (lambda (i)
                          `(,(kbd (format "s-%d" i)) .
                          (lambda ()
                          (interactive)
                          (exwm-workspace-switch-create ,i))))
                          (number-sequence 1 9))))
  :config (require 'exwm-randr)
          (exwm-randr-enable)
          (add-hook 'exwm-init-hook #'dotfiles/init-hook)
          (add-hook 'exwm-randr-screen-change-hook #'dotfiles/update-display)
          (add-hook 'exwm-update-class-hook (lambda () (exwm-workspace-rename-buffer exwm-class-name)))
          (dotfiles/update-display)
          (dotfiles/run-in-background "nitrogen --restore") ;; Update the wallpaper.
          (exwm-enable))

Footnotes