Fix GParted and other root GUI apps failing with cannot open display
Arch's gparted PKGBUILD is 1.8.1, configures --enable-xhost-root and lists xorg-xhost: authorization from wayland as an optional dependency. xorg-xhost is not in /usr/share/omarchy/install/omarchy-base.packages or omarchy-other.packages and is not installed here. The defect is in who runs the grant. In the gparted.in launcher at tag GPARTED_1_8_1, the xhost grant sits inside if test "xid -u" != "x0", the branch that elevates through pkexec. Started with sudo gparted, the launcher already runs as root, skips that branch, never runs xhost, and still fails with the same error after xorg-xhost is installed. The record's symptom names sudo gparted and its fix implies xhost alone cures it, so the fix must say to start gparted as your own user. Omarchy 4 has a polkit agent in omarchy-shell (shell.qml keeps lock, idle and polkit services loaded) and polkit 127 is installed, so pkexec can prompt. Issue #3810 (Omarchy 3.2.2) confirms xorg-xhost fixes it and that GParted is not Omarchy default software. The Arch wiki page supports the xhost si:localuser:root, sudo -E and pkexec env forms. Not exercised: GParted is not installed here and I did not install it.
Running a whole GUI application as root runs a large amount of unaudited code with full privileges and can change the ownership of files in your home directory. Revoke any manual xhost grant as soon as the app closes, and prefer sudoedit or a polkit-aware tool where one exists.
Symptom
GParted will not start, from the menu or from the terminal with sudo gparted:
Authorization required, but no authorization protocol specified
(gpartedbin:4425): Gtk-WARNING **: ...: cannot open display: :1
Other apps run with sudo show No protocol specified / Unable to init server: Could not connect: Connection refused / cannot open display: :0.
Cause
Wayland does not let a process running as another user draw on your session, and XWayland by default only accepts clients from the user who started it, so the old Xorg workarounds (XAUTHORITY, pam_xauth) do not apply. Arch's gparted 1.8.1 is built with --enable-xhost-root. When you start gparted as your normal user, its launcher runs xhost +SI:localuser:root, elevates gparted through pkexec, and runs xhost -SI:localuser:root after it exits, but only if the xhost command exists. xorg-xhost is only an optional dependency ("authorization from wayland") and Omarchy does not install it, so the grant is silently skipped and GParted fails. Starting it with sudo gparted fails even with xhost installed, because the launcher is then already root and skips the grant entirely.
Fix
**GParted.** Install xhost, then start GParted as your own user, from the app launcher or as plain gparted in a terminal. Do not use sudo gparted: the launcher only grants root access to the display when it does the elevation itself. It asks for your password through polkit, grants root access for the life of the window and revokes it afterwards:
sudo pacman -S --needed xorg-xhost
gparted
**Editing a system file.** Do not run a GUI editor as root. Use sudoedit, which edits an unprivileged copy:
sudoedit /etc/fstab
**Another XWayland app that must run as root.** Grant root for the session, run it, then revoke. Run xhost as your user, not with sudo:
xhost si:localuser:root
sudo some-x11-app
xhost -si:localuser:root
**A native Wayland app.** Preserve WAYLAND_DISPLAY and the runtime dir:
sudo -E some-wayland-app
# or
pkexec env WAYLAND_DISPLAY="$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY" XDG_RUNTIME_DIR=/run/user/0 some-wayland-app
Verify
Run gparted as your user (no sudo), authenticate at the polkit prompt, and GParted opens and lists your disks. After closing it, xhost no longer lists SI:localuser:root.
Sources
- https://wiki.archlinux.org/title/Privilege_elevation_for_graphical_applications
- https://github.com/omacom/omarchy/issues/3810
- https://gitlab.gnome.org/GNOME/gparted/-/raw/master/gparted.in
- https://gitlab.archlinux.org/archlinux/packaging/packages/gparted/-/raw/main/PKGBUILD
- https://gitlab.gnome.org/GNOME/gparted/-/raw/GPARTED_1_8_1/gparted.in