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.
 
 
 
 

77 lines
3.1 KiB

-- This file is part of Reno desktop.
--
-- 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.
--
-- 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.
--
-- You should have received a copy of the GNU General Public License along with Reno desktop. If not, see <https://www.gnu.org/licenses/>.
-- Simple global context menu controls
local beautiful = require("beautiful")
local menugen = require("context_menu")
local xdglib = require("xdg_data")
local menu_gen = require("menubar.menu_gen")
local gears = require("gears")
local json = require("dkjson")
local function regenerate_xdg()
local desktop_dirs = {os.getenv("HOME").."/Desktop"}
local desktop_dirs_complete = 0
local _ = ((table.concat(gears.filesystem.get_xdg_data_dirs(),":") or
"/usr/share:/usr/local/share")..":"..os.getenv("HOME").."/.local/share")
:gsub("[^:]*",function(path)
if gears.filesystem.dir_readable(path.."/applications") then
table.insert(desktop_dirs,path.."/applications")
end
end)
local function count(t)
local c = 0
for _,_ in pairs(t) do
c = c +1
end
return c
end
require("naughty").notify({title="Regenerating XDG cache..."})
-- Generate a patch containing metadata
local meta = xdglib.generate_meta_patch(_G.xdg)
-- Initialize structure
_G.xdg = xdglib.init_xdg_struct()
-- Add missing category entries
xdglib.add_categories(xdg,menu_gen.all_categories)
-- Asynchronous process scanning
xdglib.async_process_dirs(xdg,desktop_dirs,nil,function()
desktop_dirs_complete = desktop_dirs_complete + 1
if desktop_dirs_complete == #desktop_dirs then
for k,v in pairs(xdg.categories) do
if count(v.apps) == 0 then
xdg.categories[k] = nil
end
end
xdglib.apply_meta_patch(xdg,meta)
require("naughty").notify({
text="Done! Restart WM to reload menus."
})
io.open(gears.filesystem.get_xdg_cache_home()..
".reno_xdg_cache.json","w"
):write(json.encode(xdg)):close()
end
end)
end
return function(args)
local widget = menugen({
items = {
{"Awesome", {
{"reload cache",regenerate_xdg},
{"open config dir", "xdg-open "..root_path},
{"open docs", "xdg-open https://awesomewm.org/doc/api/"},
{"restart", function() awesome.restart() end},
{"quit", function() awesome.quit() end}
}, beautiful.awesome_icon},
{"open terminal", global.terminal},
},
parent = args.menu_parent
})
return widget
end