User:K1tsu/Emacs under Wayland

From Gentoo Wiki
Jump to:navigation Jump to:search

The section on Pure GTK has been commented out from the main wiki page, however I believe such documentation should be accessible on the Gentoo wiki.

Wayland

Warning
Pure GTK support is ONLY available for Emacs 29 and above.

Emacs can be built to the use the "pgtk" (Pure GTK) frontend: Emacs will no longer use X11 APIs directly, instead it only uses GTK (and Cairo), which allows Emacs to run under Wayland native, without relying on Xwayland support.

Noted benefits are a slightly different look to some dialog options, proper scaling and improved font rendering.

To make use of PGTK, emacs 29 first has to be unmasked.

FILE /etc/portage/package.accept_keywords
app-editors/emacs ~amd64

To activate pgtk, disable X and enable gui and gtk for app-editors/emacs:

FILE /etc/portage/package.use
app-editors/emacs gui gtk -X

Then run:

root #emerge --ask --update --changed-use @world

This will also get rid of the annoying warning of:

Warning: due to a long standing Gtk+ bug
http://bugzilla.gnome.org/show_bug.cgi?id=85715
Emacs might crash when run in daemon mode and the X11 connection is unexpectedly lost.
Using an Emacs configured with --with-x-toolkit=lucid does not have this problem.

If a previous version of emacs was already present on the system, it may be necessary to use app-eselect/emacs to set a symlink to emacs 29.

root #eselect emacs list
root #eselect emacs set [number]

Emacs Distribution Update

Note
When a distribution such as Doom Emacs is used and elpa packages are installed they need to be rebuilt for the higher emacs version.

Doom emacs example

user $.emacs.d/bin/doom --sync

Troubleshooting

When attempting to set emacs opacity via a config.el example like below, some users may experience a graphical bug where emacs appears to be covered in a white layer.

(set-frame-parameter (selected-frame)'alpha '(80 80)) (add-to-list 'default-frame-alist '(alpha 80 80))

A possible way of circumventing this error would be the usage of the Wayland compositor's native opacity settings.

A hyprland example:

FILE .config/hypr/hyprland
{{{1}}}