Как я могу отправить уведомление с помощью polkit 0.106?

Укажите числовой идентификатор:

gpg --passwd 43E855BB
2
22.02.2018, 21:44
3 ответа

Наконец, я создал клиент dbus, запущенный от имени пользователя, который получает сигнал от системной шины и показывает уведомление пользователю.

Код клиента dbus находится вhttps://github.com/AlmuHS/Pendrive_Reminder/blob/work-in-progress/dbus-client/client.py

В скрипт send-notify.shя добавил только

 dbus-send --system /org/preminder/mensaje org.preminder.App

При выполнении клиента dbus от имени пользователя уведомление отображается правильно

Теперь я пытаюсь сделать так, чтобы клиент запускался автоматически, когда пользователь подключает флешку

Продолжить в Как запустить клиент dbus из скрипта?

0
27.01.2020, 22:33

polkit (ypkexec)eliminan las variables de entorno DISPLAYy XAUTHORITYque se necesitan para el acceso X. notify-sendfalla porque no puede acceder a la pantalla.

De la página de manual de pkexec:

As a result, pkexec will not allow you to run X11 applications as another user since the $DISPLAY and $XAUTHORITY environment variables are not set. These two variables will be retained if the org.freedesktop.policykit.exec.allow_gui annotation on an action is set to a nonempty value

No estoy familiarizado con polkit; tal vez pueda configurar org.freedesktop.policykit.exec.allow_guisolo para esta regla, o hay otras posibilidades. Lo siento, no puedo proporcionar una solución lista.

Sin embargo, el punto central es proporcionar DISPLAYy XAUTHORITYpara notify-send.

(No me golpees :una solución sucia sería codificar DISPLAY=:0y XAUTHORITY=...en tu script de notificación. Tenga en cuenta que esto puede fallar si algo cambia ).


Editar :Basado en la discusión anterior, una solución alternativa que debería funcionar con múltiples usuarios y sinXAUTHORITY:

En el inicio de sesión X,un script debe ejecutarse automáticamente (tal vez alguna configuración .desktopen~/.config/autostart):

#! /bin/bash
# allow polkitd access to X. 
# xhost is an alternative to XAUTHORITY authentication
xhost +SI:localuser:polkitd
# store DISPLAY for each user
echo $DISPLAY > /tmp/display.$USER

En su script polkit incluya

export DISPLAY=$(cat /tmp/display.$user)
0
27.01.2020, 22:33

@mviereck

Intenté crear un archivo de política de polkit para notificar -enviar, con este contenido

<policyconfig>
<action id="org.freedesktop.notify-send">
<description>Launch notify-send command</description>
<message>Authentication is required to run the gedit</message>
<icon_name>accessories-text-editor</icon_name>
<defaults>
    <allow_any>yes</allow_any>
    <allow_inactive>yes</allow_inactive>
    <allow_active>yes</allow_active>
</defaults>
<annotate key="org.freedesktop.policykit.exec.path">/usr/bin/notify-send</annotate>
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
</action>

Pongo este archivo en/usr/share/polkit-1/actions/org.freedesktop.policykit.notify-send.policy

Pero, después de presionar el botón de apagado, el menú de apagado tardó mucho en mostrarse y no apareció la notificación

0
27.01.2020, 22:33

Теги

Похожие вопросы