Невозможно получить системное сообщение в Ubuntu 24.04.C++

Программы на C++. Форум разработчиков
Ответить
Anonymous
 Невозможно получить системное сообщение в Ubuntu 24.04.

Сообщение Anonymous »

Когда я запускаю эту команду:

Код: Выделить всё

notify-send "Test here" "Test body"
И чем мониторить:

Код: Выделить всё

dbus-monitor "interface='org.freedesktop.Notifications',member='Notify'"
Я получаю такой результат:

Код: Выделить всё

$ dbus-monitor "interface='org.freedesktop.Notifications',member='Notify'"
signal time=1737337906.487066 sender=org.freedesktop.DBus -> destination=:1.202 serial=2 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameAcquired
string ":1.202"
signal time=1737337906.487090 sender=org.freedesktop.DBus -> destination=:1.202 serial=4 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameLost
string ":1.202"
method call time=1737337958.906320 sender=:1.203 -> destination=:1.43 serial=9 path=/org/freedesktop/Notifications; interface=org.freedesktop.Notifications; member=Notify
string "notify-send"
uint32 0
string ""
string "Test here"
string "Test body"
array [
]
array [
dict entry(
string "urgency"
variant             byte 1
)
dict entry(
string "sender-pid"
variant             int64 26834
)
]
int32 -1
method call time=1737337958.907631 sender=:1.43 -> destination=:1.34 serial=344 path=/org/freedesktop/Notifications; interface=org.freedesktop.Notifications; member=Notify
string "notify-send"
uint32 0
string ""
string "Test here"
string "Test body"
array [
]
array [
dict entry(
string "urgency"
variant             byte 1
)
dict entry(
string "sender-pid"
variant             int64 26834
)
dict entry(
string "x-shell-sender-pid"
variant             uint32 26834
)
dict entry(
string "x-shell-sender"
variant             string ":1.203"
)
]
int32 -1
Поэтому я решил написать программу на C++, которая также должна захватывать системные уведомления:

Код: Выделить всё

#include 
#include 
#include 

void listenForNotifications()
{
DBusConnection* connection;
DBusError error;

// Initialize D-Bus error
dbus_error_init(&error);

// Connect to the D-Bus session bus
connection = dbus_bus_get(DBUS_BUS_SESSION, &error);
if (!connection) {
std::cerr 

Подробнее здесь: [url]https://stackoverflow.com/questions/79370131/unable-to-fetch-system-message-on-ubuntu-24-04[/url]
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C++»