Reno is the second iteration of the AWMTK-powered AwesomeWM config.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

110 lines
4.6 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. -- This file is part of Reno desktop.
  2. --
  3. -- Reno desktop is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  4. --
  5. -- Reno desktop is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  6. --
  7. -- You should have received a copy of the GNU General Public License along with Reno desktop. If not, see <https://www.gnu.org/licenses/>.
  8. -- Notifications pager
  9. local awful = require("awful")
  10. local pager = require("pager")
  11. local beautiful = require("beautiful")
  12. local gears = require("gears")
  13. local wibox = require("wibox")
  14. local awmtk2 = require("awmtk2")
  15. local naughty = require("naughty")
  16. return function(args)
  17. local style = awmtk2.create_style("notifications",
  18. awmtk2.generic.popup,args.style)
  19. local templates = awmtk2.create_template_lib("notifications",awmtk2.templates,args.templates)
  20. local t = awmtk2.build_templates(templates,style,args.vertical)
  21. local layout = wibox.widget({
  22. layout = wibox.layout.fixed.vertical,
  23. spacing = style.base.spacing
  24. })
  25. local pager = pager(layout,{},args.max_notifications or 8)
  26. local test_xclip = os.execute("xclip -version")
  27. local result = test_xclip
  28. if _VERSION:match("5.1") then
  29. result = (test_xclip == 0)
  30. end
  31. local count = 0
  32. local popup = awful.popup(t.popup({
  33. t.textbox({
  34. markup = "Click to copy text"
  35. }),
  36. ((not result) and t.textbox({
  37. markup = "(xclip is not installed)"
  38. })),
  39. t.container(layout,{
  40. bg = style.container.bg_highlight,
  41. bgimage = style.container.bgimage_highlight
  42. }),
  43. t.textbox({
  44. id = "page_id",
  45. markup = "Page 0/0"
  46. }),
  47. layout = wibox.layout.fixed.vertical
  48. },{
  49. visible = false
  50. }))
  51. naughty.config.notify_callback = function(update_args)
  52. count = count + 1
  53. local w = wibox.widget(t.button(t.article({
  54. icon = update_args.icon,
  55. title = update_args.title or "(No title)",
  56. description = update_args.text
  57. }),{
  58. forced_height = style.button.height,
  59. forced_width = style.button.width
  60. }))
  61. local page_index = popup.widget:get_children_by_id("page_id")[1]
  62. page_index:set_markup("Page "..tostring(pager.index+1).."/"..
  63. tostring(math.ceil(count/(args.max_notifications or 8))))
  64. w:connect_signal("button::press",style.button.onpress)
  65. w:connect_signal("button::release",style.button.onrelease)
  66. w:connect_signal("button::press",function(self,x,y,button)
  67. if button == 1 then
  68. clip = io.open("/tmp/clip","w")
  69. clip:write(update_args.text)
  70. clip:close()
  71. awful.spawn.with_shell("cat /tmp/clip | xclip -selection clipboard")
  72. elseif button == 4 then
  73. pager:prev()
  74. page_index:set_markup("Page "..tostring(pager.index+1).."/"..
  75. tostring(math.ceil(count/(args.max_notifications or 8))))
  76. elseif button == 5 then
  77. pager:next()
  78. page_index:set_markup("Page "..tostring(pager.index+1).."/"..
  79. tostring(math.ceil(count/(args.max_notifications or 8))))
  80. end
  81. end)
  82. table.insert(pager.list,1,w)
  83. pager:update()
  84. return update_args
  85. end
  86. -- create popup button
  87. local clip_widget
  88. do
  89. local style = awmtk2.create_style("notifications",
  90. awmtk2.generic.iconified_widget,args.style)
  91. local templates = awmtk2.create_template_lib("notifications",awmtk2.templates,args.templates)
  92. local t = awmtk2.build_templates(templates,style,args.vertical)
  93. clip_widget = wibox.widget(t.button(t.icon({
  94. image = beautiful["notifications-area-symbolic"],
  95. resize = true,
  96. })))
  97. clip_widget:connect_signal("button::press",style.button.onpress)
  98. clip_widget:connect_signal("button::release",style.button.onrelease)
  99. clip_widget:connect_signal("button::press",function(self,x,y,button)
  100. if button == 1 then
  101. popup.visible = (not popup.visible)
  102. if popup.visible then
  103. popup:move_next_to(mouse.current_widget_geometry)
  104. end
  105. end
  106. end)
  107. end
  108. return clip_widget
  109. end