UP | HOME

Emacs Tipps & Tricks

Emacs is the Program I live in.

I don’t use Emacs for everything, because it is not best for everything, but any tool that cannot be integrated with Emacs requires considerably more context switches than if it can be integrated.

Also see the org-mode tipps. Org-mode is what binds Emacs together for me.

Other larger topics have their own articles:


PDF (drucken)

Simple EXWM setup

EXWM is a window manager running in Emacs. It’s actually awesome to work in it, though it still has some rough edges. I started using it when Gnome Shell killed my keyboard layout once too often when switching users and Chromium corrupted its shortcuts when I set my keyboard layout again.

I’m typing this from my Emacs running exwm.

Setup:

(use-package exwm :ensure t)
;; show the time in the modeline (also see the customization in the variables)
(display-time-mode)
;; Make buffer name more meaningful
(add-hook 'exwm-update-class-hook
          (lambda ()
          (exwm-workspace-rename-buffer exwm-class-name)))
(use-package pinentry
  :ensure t
  :config
  (pinentry-start))
(setq ediff-window-setup-function 'ediff-setup-windows-plain)

I currently start my session as normal in Gnome Shell (to get all the monitor setup and tweaks), then start Emacs and just run

M-x exwm-init

(answer yes: replace existing window manager)

Controlling pulseaudio from EXWM

I need mouse-controlled volume. The desktop-environment package provides it, but out of the box only for amixer. I adjusted it for pulseaudio.

Also I added the volume to the modline, with scrollwheel control: Scroll up or down to increase or decrease volume.

(use-package desktop-environment :ensure t
  :custom
  (desktop-environment-screenshot-directory "~/Bilder")
  (desktop-environment-volume-normal-decrement "-5%")
  (desktop-environment-volume-normal-increment "+5%")
  (desktop-environment-volume-get-command
   "LC_ALL=C pacmd list-sinks|grep -A 15 '* index'| awk '/volume: front/{ print $5 }' | sed 's/,//g'")
  (desktop-environment-volume-set-command "pactl set-sink-volume 1 %s")
  (desktop-environment-volume-small-decrement "-1%")
  (desktop-environment-volume-small-increment "+1%")
  :config
  (desktop-environment-mode)
  (global-set-key (kbd "M-σ") 'desktop-environment-volume-decrement-slowly)
  (global-set-key (kbd "M-π") 'desktop-environment-volume-increment-slowly)
  (global-set-key (kbd "M--") 'desktop-environment-volume-decrement)
  (global-set-key (kbd "M-+") 'desktop-environment-volume-increment))


(define-minor-mode display-volume-mode
  "Toggle display of volume in mode lines.

Depends on desktop-environment.

When Display Time mode is enabled, it queries the volume from
your system on every displaying using
desktop-environment-volume-get (which you can customize)."
  :global t :group 'desktop-environment
  (or global-mode-string (setq global-mode-string '("")))
  (setq display-volume-keymap (make-sparse-keymap))
  (define-key display-volume-keymap (kbd "<mode-line> <mouse-4>") 'desktop-environment-volume-increment-slowly)
  (define-key display-volume-keymap (kbd "<mode-line> <mouse-5>") 'desktop-environment-volume-decrement-slowly)
  (setq display-volume-modeline-entry
        '(:eval (propertize (format " V:%s%% "(desktop-environment-volume-get))
                            'keymap display-volume-keymap)))
  (if display-volume-mode
      (progn
        (or (memq display-volume-modeline-entry global-mode-string)
            (setq global-mode-string
                  (append global-mode-string (list display-volume-modeline-entry)))))))

(display-volume-mode)

ArneBab 2022-01-06 Do 00:00 - Impressum - GPLv3 or later (code), cc by-sa (rest)