Merci nany,
nany a écritpkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY hardinfo
Ça fonctionne très bien, et c'est bien plus simple que la solution que je décrit ci-dessous !
Car dans l'intervalle, j'ai trouvé la
page de documentation sur pkexec, qui rejoint la dernière remarque d'Inbox (mais la solution de nany fonctionne sur Ubuntu sans ce fichier).
À la lecture de ce doc. et
sur le modèle de l'exemple donné, et d'un
fil sur unix.stackexchange, j'ai donc ajouté dans
/usr/share/polkit-1/actions/ un fichier
org.freedesktop.policykit.hardinfo.policy contenant :
<?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.hardinfo">
<description>Run hardinfo program</description>
<message>Authentication is required to run hardinfo</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/hardinfo</annotate>
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
</action>
</policyconfig>
et cela fonctionne aussi.
J'ai alors pu ajouter dans
/usr/share/applicatioins/ un fichier
hardinfo-root.desktop (à la manière de
bleachbit-root.desktop et de
zenmap-root.desktop) contenant :
[Desktop Entry]
Name=HardInfo (as root)
Exec=pkexec hardinfo
Comment=System profiler and benchmark
Icon=logo.png
Type=Application
Terminal=false
Categories=Utility;
Ce fichier devrait être retravaillé (en particulier la ligne
Icon= doit être erronée), mais j'ai un lanceur pour hardinfo en mode graphique et superuser qui fonctionne.
J'aurais sans doute pu mettre les variables d'environnement DISPLAY et XAUTHORITY dans un lanceur, mais je ne suis pas encore au point sur ce genre de fichier...
Merci à nany, Inbox et Qid,
Bonnes fêtes de fin d'année.
Je noterai ce fil résolu l'année prochaine :-)