Raspberry Pi Imager is the official tool for writing Raspberry Pi OS images (and other images) to SD cards or USB drives. While it works smoothly on traditional desktop environments, running it on Hyprland — a Wayland compositor — can be tricky, especially if installed via the AUR. Here’s a deep dive into the issue and how to fix it.
The Problem
On Arch Linux, you have two main ways to install Raspberry Pi Imager:
-
Pacman (official repo):
sudo pacman -S rpi-imager -
AUR (latest version):
yay -S rpi-imager-latest
When using the AUR version:
- Launching the app from wofi shows no response — the GUI doesn’t open.
- Running from terminal works only with
sudo -E rpi-imager.
Meanwhile, the Pacman version works normally from the menu.
Why This Happens
- Root Privileges Needed
- Raspberry Pi Imager requires access to devices (SD cards/USB drives), which normal users cannot access.
- Therefore, it must run as root, usually via
pkexecorsudo.
- Wayland Environment
- On Hyprland (Wayland),
pkexecoften fails silently if the environment variables (DISPLAY,WAYLAND_DISPLAY,XAUTHORITY) aren’t set properly. - The desktop file provided by the AUR package typically uses:
Exec=pkexec --disable-internal-agent /usr/bin/rpi-imager %u
- On Wayland, this does not carry over the environment, so the GUI never appears.
- Desktop File Difference
- The Pacman version (
/usr/share/applications/org.raspberrypi.rpi-imager.desktop) works because its environment and paths are standard. - The AUR version may install to a slightly different path or not account for Wayland, causing the menu launcher to fail.
The Solution
The fix involves creating a wrapper script that preserves the Wayland environment and modifying the desktop file to use it.
Step 1: Create a Wayland-safe Wrapper
Create a new script at /usr/local/bin/rpi-imager-launch:
sudo nano /usr/local/bin/rpi-imager-launch
Paste the following:
#!/bin/bash
# Wayland-safe wrapper for Raspberry Pi Imager
export DISPLAY=$DISPLAY
export WAYLAND_DISPLAY=$WAYLAND_DISPLAY
export XAUTHORITY=$XAUTHORITY
# Launch Raspberry Pi Imager with pkexec
pkexec env DISPLAY=$DISPLAY WAYLAND_DISPLAY=$WAYLAND_DISPLAY XAUTHORITY=$XAUTHORITY /usr/bin/rpi-imager
Make it executable:
sudo chmod +x /usr/local/bin/rpi-imager-launch
Step 2: Modify the Desktop File
Edit the AUR-installed desktop file (likely /usr/share/applications/com.raspberrypi.rpi-imager.desktop):
sudo nano /usr/share/applications/com.raspberrypi.rpi-imager.desktop
Change the Exec line to:
Exec=/usr/local/bin/rpi-imager-launch %u
This ensures that when you click the app in wofi, the wrapper script runs, preserving the environment variables necessary for Wayland.
Step 3: Refresh the Menu
If necessary, refresh your desktop database:
update-desktop-database
Now, launching Raspberry Pi Imager from wofi works as expected — it will prompt for your password via GUI and open the application.
Why This Works
- The wrapper ensures
DISPLAY,WAYLAND_DISPLAY, andXAUTHORITYare correctly passed topkexec, which is required on Wayland. - Modifying the desktop file allows the menu launcher to call the wrapper instead of the original binary directly.
- This approach works for any root-required GUI application on Wayland that fails to launch from a menu.
Optional Enhancements
-
Passwordless Launch: You can configure
sudoersto allow your user to run/usr/bin/rpi-imagerwithout a password. This makes one-click launching possible but slightly reduces security. -
Icon Customization: If the AUR version lacks an icon, you can download a PNG and set
Icon=/path/to/icon.pngin the desktop file.
Conclusion
Running AUR-installed Raspberry Pi Imager on Hyprland can fail silently due to Wayland environment issues with pkexec. The solution is simple:
- Create a wrapper script that preserves environment variables.
- Edit the desktop file to point to the wrapper.
This ensures wofi or any other menu launcher can start the app reliably, bridging the gap between Arch’s flexibility, Wayland, and applications requiring root access.
Top comments (0)