0

I followed the first and fourth comments of this post but I couldn't install firefox dev.

Actually I don't really know if the browser was installed, every step of the fourth comment seems to work, but when I tried use gksu gedit /usr/share/applications/firefox-dev to create the icon the terminal returned the following error:

Command 'gksu' not found

I search and found out that gksu is deprecated, so one alternative presented was pkexec, and I tried:

pkexec gedit /usr/share/applications/firefox-dev.desktop

The termonal returned this error:

Unable to init server: Could not connect: Connection refused

(org.gnome.gedit:2744): Gtk-WARNING **: 22:07:54.667: cannot open display:

  1. How I make sure that the firefox developer is installed and how do I open it from the terminal?

  2. How to create an executable icon to it?

1 Answers1

0

As taliezin answered in https://unix.stackexchange.com/questions/203136/how-do-i-run-gui-applications-as-root-by-using-pkexec I tried and worked fine.

It can be done by adding custom actions to policykit.
If you want to run gedit as root with pkexec you have to create new file /usr/share/polkit-1/actions/org.freedesktop.policykit.gedit.policy for example:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC
 "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
<policyconfig>
    <action id="org.freedesktop.policykit.pkexec.gedit">
    <description>Run gedit program</description>
    <message>Authentication is required to run the gedit</message>
    <icon_name>accessories-text-editor</icon_name>
    <defaults>
        <allow_any>auth_admin</allow_any>
        <allow_inactive>auth_admin</allow_inactive>
        <allow_active>auth_admin</allow_active>
    </defaults>
    <annotate key="org.freedesktop.policykit.exec.path">/usr/bin/gedit</annotate>
    <annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
    </action>
</policyconfig>

Finally pkexec gedit should work as expected.

Read the man pkexec which explains it examples.

danilo
  • 1,385
  • it didn't worked, I did it but when I tried pkexec agein it returned: ** (org.gnome.gedit:4250): WARNING **: 23:21:33.186: Set document metadata failed: Setting attribute metadata::gedit-position not supported – trayingHardFi Mar 05 '20 at 02:23
  • @trayingHardFi, it is only a warning, you can hide this with: https://askubuntu.com/questions/798935/set-document-metadata-failed-when-i-run-sudo-gedit – danilo Mar 05 '20 at 02:48