Should I be using run0 instead of sudo?

You can set environment variables with run0 using the --setenv flag. For GParted specifically you can run it like this:

run0 --setenv=WAYLAND_DISPLAY="$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY" gparted

This is similar to how you would do it with pkexec. See this related note from the ArchWiki: https://wiki.archlinux.org/title/Running_GUI_applications_as_root#Using_pkexec

Probably you mean “sudo -E”.

You shouldn’t use sudo -E except for testing; it passes the entire user environment to root, which is pretty much never appropriate. Instead, you should identify what specific environment variables need to be preserved for whatever you are trying to achieve and explicitly set them.

1 Like