How to enable polkit agent for elevated rights requests with graphical packages like firewall-config

I put the following note together after running into an issue with Niri and Hyprland where I needed a polkit agent. Hopefully it will help you all exploring WM.

Feel free to add feedback if there is a different approach. Thank you.

How to enable polkit agent for elevated rights requests with graphical packages like firewall-config

When using Wayland Compositors like Niri or Hyprland you will need to add a polkit agent to allow for applications to request elevated rights (e.g. Firewall management Graphical interfaces). Both these compositors do not include a polkit agent.

Example of error in Firewalld:

❯ sudo firewall-config
[sudo: authenticate] Password:
Authorization required, but no authorization protocol specified

Authorization required, but no authorization protocol specified

Authorization required, but no authorization protocol specified


(firewall-config:12321): Gtk-WARNING **: 23:21:27.686: cannot open display: :0

Desktops like Niri and Hyprland you need a polkit agent installed:

sudo pacman -S polkit-kde-agent

or

sudo pacman -S hyprpolkitagent

Then add the polkit agent to the autostart configuration file in Niri or Hyprland:

Example Autostart for Niri:

//Launch Noctalia Shell
spawn-at-startup "/usr/lib/hyprpolkitagent/hyprpolkitagent"
spawn-at-startup "noctalia"

Example Autostart for Hyprland:

--Noctalia v5 Autostart

hl.on("hyprland.start", function()
  hl.exec_cmd("noctalia")
  hl.exec_cmd("/usr/lib/hyprpolkitagent/hyprpolkitagent")
end)

Note:

  • Starting the polkit at a service will work for the first sign in of a session. If you log out and back in you will need to manually start the service via systemctl. This is why utiliing autostart at login is the best option.
systemctl --user enable --now plasma-polkit-agent.service
systemctl --user enable --now hyprpolkitagent

  • If you use Noctalia V5, there is a built in Polkit Agent which can be enabled under Settings ? Security > Authentication > Polkt Agent.

Source:

#polkit #niri #hyprland

For additional options with Noctalia, you can use its built-in polkit plugin instead of the Hyrpland package (not tested with Niri).

I’m using Noctalia V5 as my Shell. I was going through the plugin store and I did not see one which supports polkit agents. Which one were you referring?

I did find a noctalia V4 plugin:

It’s been added as a main feature (in Settings)

Thanks for the support. Found it. I will update my technote above.

I did test Noctalia Polkit Agent on both Niri and Hyprland (worked with firewalld). I did verify that I had uninstalled the 3rd party Polkit Agents prior to testing. Its much nicer then hyprpolkitagent.

On a high level I went with Noctalia because I am trying to simplify my day to day workflows. I really like Scrolling Windows Managers.

Love Noctalia, but scrolling is not for me.

Are you using different desktops in your setup? Also if you are not using scrolling, what is your configuration? Thank you for sharing.

My host system uses Hyprland. I have 20+ VMs - EOS, Manjaro, NixOS - using all types of desktops/compositors. I haven’t tried Niri in a while; scrolling just felt weird.

I have Niri to simulate some of the usecases which may eventual come up in Cosmic Desktop.

At the moment my issue with the Niri project (if you review their issues in Github) is the person doing their triage asks most reporters of bugs to “Replicate on sway and cosmic-comp”. I understand the logic is because they use Smithay Rust Library and they want to see if they can pin the issue upstream. Does not feel like the right approach. I prefer an evidence based approach which means debugging and logging while you reproduce the issue. So I might boot Niri eventually and stay with Hyprland.