14 | 14 |
local menu_gen = require("menubar.menu_gen")
|
15 | 15 |
local menu_utils = require("menubar.utils")
|
16 | 16 |
local icon_theme = require("menubar.icon_theme")
|
17 | |
local gls = require("gears.filesystem")
|
18 | 17 |
|
19 | |
local pairs, string, table, os = pairs, string, table, os
|
20 | |
|
21 | |
-- Add support for NixOS systems too
|
22 | |
table.insert(menu_gen.all_menu_dirs, string.format("%s/.nix-profile/share/applications", os.getenv("HOME")))
|
23 | |
|
24 | |
-- Remove non existent paths in order to avoid issues
|
25 | |
local existent_paths = {}
|
26 | |
for k,v in pairs(menu_gen.all_menu_dirs) do
|
27 | |
if gls.is_dir(v) then
|
28 | |
table.insert(existent_paths, v)
|
29 | |
end
|
30 | |
end
|
31 | |
menu_gen.all_menu_dirs = existent_paths
|
|
18 |
local io, pairs, string, table, os = io, pairs, string, table, os
|
32 | 19 |
|
33 | 20 |
-- Expecting a wm_name of awesome omits too many applications and tools
|
34 | 21 |
menu_utils.wm_name = ""
|
|
36 | 23 |
-- Menu
|
37 | 24 |
-- freedesktop.menu
|
38 | 25 |
local menu = {}
|
|
26 |
|
|
27 |
-- Determines if a path points to a directory, by checking if it can be read
|
|
28 |
-- (which is `nil` also for empty files) and if its size is not 0.
|
|
29 |
-- @author blueyed
|
|
30 |
-- @param path the path to check
|
|
31 |
function menu.is_dir(path)
|
|
32 |
local f = io.open(path)
|
|
33 |
return f and not f:read(0) and f:seek("end") ~= 0 and f:close()
|
|
34 |
end
|
|
35 |
|
|
36 |
-- Remove non existent paths in order to avoid issues
|
|
37 |
local existent_paths = {}
|
|
38 |
for k,v in pairs(menu_gen.all_menu_dirs) do
|
|
39 |
if menu.is_dir(v) then
|
|
40 |
table.insert(existent_paths, v)
|
|
41 |
end
|
|
42 |
end
|
|
43 |
menu_gen.all_menu_dirs = existent_paths
|
39 | 44 |
|
40 | 45 |
-- Determines whether an table includes a certain element
|
41 | 46 |
-- @param tab a given table
|