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.

55 lines
2.4 KiB

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. -- Quick application launcher
  9. local awful = require("awful")
  10. local wibox = require("wibox")
  11. local gears = require("gears")
  12. local awmtk2 = require("awmtk2")
  13. local beautiful = require("beautiful")
  14. local menubar_utils = require("menubar").utils
  15. local function synchronous_ls(dir)
  16. local filenames = {}
  17. local handler = io.popen("ls -1 "..dir,"r")
  18. handler:read("*a"):gsub("[^\n]+",function(filename)
  19. table.insert(filenames,filename)
  20. end)
  21. return filenames
  22. end
  23. return function(args)
  24. local style = awmtk2.create_style("launcher",
  25. awmtk2.generic.button_list, args.style)
  26. local templates = awmtk2.create_template_lib("launcher", awmtk2.templates, args.templates)
  27. local t = awmtk2.build_templates(templates,style,args.vertical)
  28. local w = wibox.widget({
  29. layout = ((args.vertical and
  30. wibox.layout.fixed.vertical) or
  31. wibox.layout.fixed.horizontal
  32. ),
  33. spacing = style.base.spacing
  34. })
  35. local path = args.path or root_path.."/links"
  36. if gears.filesystem.dir_readable(path) then
  37. local files = synchronous_ls(path)
  38. for _,v in pairs(files) do
  39. local data = menubar_utils.parse_desktop_file(path.."/"..v)
  40. local new_widget = wibox.widget(t.button(t.icon({
  41. image = menubar_utils.lookup_icon_uncached(data.Icon),
  42. })))
  43. local exec = data.Exec:gsub("%%%w","")
  44. new_widget:connect_signal("button::press",style.button.onpress)
  45. new_widget:connect_signal("button::release",style.button.onrelease)
  46. new_widget:connect_signal("button::press",function()
  47. awful.spawn(exec)
  48. end)
  49. w:add(new_widget)
  50. end
  51. end
  52. return w
  53. end