naughty: make sendNotificationClosed() and sendActionInvoked() local
This commit is contained in:
parent
0ccda0eb9e
commit
28a6468f37
|
@ -258,6 +258,20 @@ local function getById(id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function sendActionInvoked(notificationId, action)
|
||||||
|
res = capi.dbus.emit_signal("session", "/org/freedesktop/Notifications",
|
||||||
|
"org.freedesktop.Notifications", "ActionInvoked",
|
||||||
|
"i", notificationId,
|
||||||
|
"s", action)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function sendNotificationClosed(notificationId, reason)
|
||||||
|
res = capi.dbus.emit_signal("session", "/org/freedesktop/Notifications",
|
||||||
|
"org.freedesktop.Notifications", "NotificationClosed",
|
||||||
|
"i", notificationId,
|
||||||
|
"i", reason)
|
||||||
|
end
|
||||||
|
|
||||||
--- Create notification. args is a dictionary of (optional) arguments.
|
--- Create notification. args is a dictionary of (optional) arguments.
|
||||||
-- @param text Text of the notification. Default: ''
|
-- @param text Text of the notification. Default: ''
|
||||||
-- @param title Title of the notification. Default: nil
|
-- @param title Title of the notification. Default: nil
|
||||||
|
@ -449,11 +463,11 @@ function naughty.notify(args)
|
||||||
actionmarginbox:buttons(util.table.join(
|
actionmarginbox:buttons(util.table.join(
|
||||||
button({ }, 1, function()
|
button({ }, 1, function()
|
||||||
sendActionInvoked(notification.id, actionid)
|
sendActionInvoked(notification.id, actionid)
|
||||||
die(2)
|
die(notificationClosedReason.dismissedByUser)
|
||||||
end),
|
end),
|
||||||
button({ }, 3, function()
|
button({ }, 3, function()
|
||||||
sendActionInvoked(notification.id, actionid)
|
sendActionInvoked(notification.id, actionid)
|
||||||
die(2)
|
die(notificationClosedReason.dismissedByUser)
|
||||||
end))
|
end))
|
||||||
)
|
)
|
||||||
actionslayout:add(actionmarginbox)
|
actionslayout:add(actionmarginbox)
|
||||||
|
@ -690,7 +704,7 @@ if capi.dbus then
|
||||||
elseif data.member == "CloseNotification" then
|
elseif data.member == "CloseNotification" then
|
||||||
local obj = getById(appname)
|
local obj = getById(appname)
|
||||||
if obj then
|
if obj then
|
||||||
sendNotificationClosed(obj.id, 3)
|
sendNotificationClosed(obj.id, notificationClosedReason.dismissedByCommand)
|
||||||
naughty.destroy(obj)
|
naughty.destroy(obj)
|
||||||
end
|
end
|
||||||
elseif data.member == "GetServerInfo" or data.member == "GetServerInformation" then
|
elseif data.member == "GetServerInfo" or data.member == "GetServerInformation" then
|
||||||
|
@ -762,20 +776,6 @@ if capi.dbus then
|
||||||
capi.dbus.request_name("session", "org.freedesktop.Notifications")
|
capi.dbus.request_name("session", "org.freedesktop.Notifications")
|
||||||
end
|
end
|
||||||
|
|
||||||
function sendActionInvoked(notificationId, action)
|
|
||||||
res = capi.dbus.emit_signal("session", "/org/freedesktop/Notifications",
|
|
||||||
"org.freedesktop.Notifications", "ActionInvoked",
|
|
||||||
"i", notificationId,
|
|
||||||
"s", action)
|
|
||||||
end
|
|
||||||
|
|
||||||
function sendNotificationClosed(notificationId, reason)
|
|
||||||
res = capi.dbus.emit_signal("session", "/org/freedesktop/Notifications",
|
|
||||||
"org.freedesktop.Notifications", "NotificationClosed",
|
|
||||||
"i", notificationId,
|
|
||||||
"i", reason)
|
|
||||||
end
|
|
||||||
|
|
||||||
return naughty
|
return naughty
|
||||||
|
|
||||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||||
|
|
Loading…
Reference in New Issue