#+TITLE: X11 #+AUTHOR: Christopher James Hayward #+EMAIL: chris@chrishayward.xyz #+PROPERTY: header-args:emacs-lisp :tangle x11.el :comments org #+PROPERTY: header-args :results silent :eval no-export :comments org #+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil #+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil X11[fn:1] is a graphical display manager. * Setup Install the required software on your system before loading the module. Installing X11[fn:1] without any install recommends may not include all of the packages you need on your system. Make sure you don't need any GNOME software utilities before using this example. #+begin_src shell RUN apt install -y xserver-xorg-core \ --no-install-recommends \ --no-install-suggests #+end_src ** Displays Setup ~autorandr~[fn:2] with pre-configured profiles for screen size and display output. #+begin_src shell RUN apt install autorandr -y #+end_src ** Screen locking If you want to be able to lock and unlock your screen when you're away from your machine, install ~xss-lock~[fn:3]. By default, it will show a blue screen, turning red if you input your password incorrectly, and returning to your previous screen when successful. #+begin_src shell RUN apt install -y xss-lock slock #+end_src ** Desktop compositor Download and install ~compton~[fn:4], a desktop compositor for X11[fn:1] that adds shadows, fading, translucency, and implements window frame opacity controls, inactive window transparency, and more. #+begin_src shell RUN apt install -y compton #+end_src ** Desktop notifications Make sure ~dbus~[fn:5] is installed to receive desktop notifications, it's an IPC system used by lots of utilities. #+begin_src shell RUN apt install -y dbus #+end_src * Config :PROPERTIES: :header-args: :tangle ../config/xinitrc :comments org :END: My workflow includes launching Emacs under X11[fn:1] without the use of a display manager, controlling everything within Emacs, while still providing the functionality of a desktop environment. #+begin_src conf compton & xss-lock -- slock & exec dbus-launch --exit-with-session emacs -mm --debug-init #+end_src ** Create symbolic link By default ~xinit~[fn:1] will read the configuration file at =$HOME/.xinitrc=. Override this location with a link to the custom configuration. #+begin_src emacs-lisp (dotfiles/symlink "~/.emacs.d/config/xinitrc" "~/.xinitrc") #+end_src ** Desktop environment Use the ~desktop-environment~[fn:6] package to automatically bind well-known programs for controlling the volume, brightness, media playback, and many other XF86 functionality bindings. #+begin_src emacs-lisp (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)) #+end_src ** Swapping CAPS and CTRL :PROPERTIES: :header-args: conf :tangle ../config/xmodmap :END: Use ~Xmodmap~[fn:7] to swap CapsLock and Ctrl to keep common bindings on the home row. #+begin_src conf clear lock clear control keycode 66 = Control_L add control = Control_L add Lock = Control_R #+end_src Override the configuration file. #+begin_src emacs-lisp (dotfiles/symlink "~/.emacs.d/config/xmodmap" "~/.Xmodmap") #+end_src ** Frame transparency Emacs supports frame transparency when running under the X Window System[fn:1]. #+begin_src emacs-lisp (defun dotfiles/toggle-transparency () (interactive) (let ((alpha (frame-parameter nil 'alpha))) (set-frame-parameter nil 'alpha (if (eql (cond ((numberp alpha) alpha) ((numberp (cdr alpha)) (cdr alpha)) ((numberp (cadr alpha)) (cadr alpha))) 100) '(85 . 50) '(100 . 100))))) #+end_src Enable frame transparency by default. #+begin_src emacs-lisp (set-frame-parameter (selected-frame) 'alpha '(85 . 50)) (add-to-list 'default-frame-alist '(alpha . (85 . 50))) #+end_src * Shortcuts Toggle frame transparency with =SPC t r=. #+begin_src emacs-lisp (dotfiles/leader "tr" '(dotfiles/toggle-transparency :which-key "Toggle transparency")) #+end_src * Footnotes [fn:1] https://en.wikipedia.org/wiki/X_Window_System [fn:2] https://github.com/phillipberndt/autorandr [fn:3] https://man.archlinux.org/man/xss-lock.1 [fn:4] https://github.com/chjj/compton [fn:5] https://packages.debian.org/stretch/dbus-x11 [fn:6] https://github.com/DamienCassou/desktop-environment [fn:7] https://wiki.archlinux.org/title/Xmodmap