awesome/widgets/mailbox.lua

95 lines
3.3 KiB
Lua
Raw Permalink Normal View History

2021-11-14 10:28:13 +00:00
local awful = require("awful")
local beautiful = require("beautiful")
local gears = require("gears")
local spawn = require("awful.spawn")
local wibox = require("wibox")
local naughty = require("naughty")
local awmtk_status,awmtk = pcall(require,"awmtk")
local dbus_config = require("naughty.dbus")
return function(args)
2021-11-14 10:28:13 +00:00
local args = args or {}
-- Set up style variables
style = awmtk.style(awmtk.defaults,args.style or {},"mailbox_")
2021-11-14 10:28:13 +00:00
style.mailbox_container_width = style.mailbox_container_width or 260
args.mail_limit = args.mail_limit or 8
-- Create a notifications list
local notifications_list = wibox.widget {
2021-11-14 10:28:13 +00:00
spacing = style.mailbox_container_spacing_vertical,
layout = wibox.layout.fixed.vertical,
}
local notification_popup = awful.popup(style.container(
{
2021-11-14 10:28:13 +00:00
{
text = "Notifications: ",
widget = wibox.widget.textbox
},
notifications_list,
layout = wibox.layout.fixed.vertical,
forced_width = style.mailbox_container_width
},{
visible = false,
ontop = true,
}
))
2021-11-14 10:28:13 +00:00
-- Create a mailbox button
args.screen.notify_widget = style.icon (
{
image = style["mailbox_icon"],
2021-11-14 10:28:13 +00:00
widget = wibox.widget.imagebox
},{},{
function()
if notification_popup.visible then
--rows = nil
notification_popup.visible = not notification_popup.visible
else
--init_popup()
for s in screen do
s.notify_widget.bg = style.mailbox_button_bg
end
notification_popup:move_next_to(mouse.current_widget_geometry)
end
end
}
)
naughty.config.notify_callback = function(update_args)
2022-03-21 13:33:25 +00:00
notifications_list:insert(1,style.button(
2021-11-14 10:28:13 +00:00
{
(update_args.icon and {
image = update_args.icon,
resize = true,
widget = wibox.widget.imagebox
}),
{
markup = "<b>"..
(update_args.title or "")..
"</b>\n"..(update_args.text or ""),
widget = wibox.widget.textbox,
},
layout = wibox.layout.fixed.horizontal
},{
bg = style.mailbox_button_bg_focus,
shape = style.mailbox_container_shape,
2022-04-03 15:18:03 +00:00
border_width = style.mailbox_button_border_width,
forced_height = style.mailbox_button_height
2021-11-14 10:28:13 +00:00
},{
function()
clip = io.open("/tmp/clip","w")
clip:write(update_args.text)
clip:close()
awful.spawn.with_shell("cat /tmp/clip | xclip -selection clipboard")
notification_popup.visible = false
end
}
))
2022-04-03 15:18:03 +00:00
if #notifications_list.children > args.mail_limit then
notifications_list:remove(#notifications_list.children)
end
2021-11-14 10:28:13 +00:00
for s in screen do
s.notify_widget.bg = style.mailbox_button_bg_focus
2021-11-14 10:28:13 +00:00
end
return update_args
end
return args.screen.notify_widget
2021-11-14 10:28:13 +00:00
end