Fix luacheck warnings in beautiful and menubar
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
cf1576cdd8
commit
f2cf4a6385
|
@ -10,22 +10,13 @@
|
|||
|
||||
-- Grab environment
|
||||
local os = os
|
||||
local print = print
|
||||
local pcall = pcall
|
||||
local pairs = pairs
|
||||
local type = type
|
||||
local dofile = dofile
|
||||
local setmetatable = setmetatable
|
||||
local util = require("awful.util")
|
||||
local lgi = require("lgi")
|
||||
local cairo = lgi.cairo
|
||||
local Pango = lgi.Pango
|
||||
local PangoCairo = lgi.PangoCairo
|
||||
local capi =
|
||||
{
|
||||
screen = screen,
|
||||
awesome = awesome
|
||||
}
|
||||
local gears_debug = require("gears.debug")
|
||||
|
||||
local xresources = require("beautiful.xresources")
|
||||
|
@ -99,7 +90,7 @@ end
|
|||
-- @treturn lgi.Pango.FontDescription
|
||||
function beautiful.get_merged_font(name, merge)
|
||||
local font = beautiful.get_font(name)
|
||||
local merge = Pango.FontDescription.from_string(merge)
|
||||
merge = Pango.FontDescription.from_string(merge)
|
||||
local merged = font:copy_static()
|
||||
merged:merge(merge, true)
|
||||
return beautiful.get_font(merged:to_string())
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
----------------------------------------------------------------------------
|
||||
|
||||
-- Grab environment
|
||||
local print = print
|
||||
local awesome = awesome
|
||||
local round = require("awful.util").round
|
||||
local gears_debug = require("gears.debug")
|
||||
|
|
|
@ -21,21 +21,6 @@ local setmetatable = setmetatable
|
|||
local string = string
|
||||
local table = table
|
||||
local math = math
|
||||
local io = io
|
||||
|
||||
-- Returns a table whose element is a path used for icon lookup.
|
||||
-- The names of the directories and the order of them are based on the spec.
|
||||
local get_default_base_directories = function()
|
||||
local dirs = {}
|
||||
|
||||
table.insert(dirs, GLib.get_home_dir() .. "/.icons")
|
||||
for _, dir in ipairs(GLib.get_system_data_dirs()) do
|
||||
table.insert(dirs, dir .. "/icons")
|
||||
end
|
||||
table.insert(dirs, "/usr/share/pixmaps")
|
||||
|
||||
return dirs
|
||||
end
|
||||
|
||||
local get_pragmatic_base_directories = function()
|
||||
local dirs = {}
|
||||
|
@ -98,8 +83,8 @@ local index_theme_cache = {}
|
|||
-- @tparam table base_directories Paths used for lookup
|
||||
-- @treturn table An instance of the class `icon_theme`
|
||||
icon_theme.new = function(icon_theme_name, base_directories)
|
||||
local icon_theme_name = icon_theme_name or beautiful.icon_theme or get_default_icon_theme_name()
|
||||
local base_directories = base_directories or get_pragmatic_base_directories()
|
||||
icon_theme_name = icon_theme_name or beautiful.icon_theme or get_default_icon_theme_name()
|
||||
base_directories = base_directories or get_pragmatic_base_directories()
|
||||
|
||||
local self = {}
|
||||
self.icon_theme_name = icon_theme_name
|
||||
|
@ -238,10 +223,10 @@ end
|
|||
-- @tparam number icon_size Prefereable icon size
|
||||
-- @treturn string Absolute path to the icon file, or nil if not found
|
||||
function icon_theme:find_icon_path(icon_name, icon_size)
|
||||
icon_size = icon_size or 16
|
||||
if not icon_name or icon_name == "" then
|
||||
return nil
|
||||
end
|
||||
local icon_size = icon_size or 16
|
||||
|
||||
local filename = find_icon_path_helper(self, icon_name, icon_size)
|
||||
if filename then
|
||||
|
|
|
@ -189,7 +189,7 @@ local function menulist_update(query, scr)
|
|||
end
|
||||
|
||||
-- Add the applications according to their name and cmdline
|
||||
for i, v in ipairs(menubar.menu_entries) do
|
||||
for _, v in ipairs(menubar.menu_entries) do
|
||||
v.focused = false
|
||||
if not current_category or v.category == current_category then
|
||||
if string.match(v.name, pattern)
|
||||
|
@ -205,7 +205,7 @@ local function menulist_update(query, scr)
|
|||
end
|
||||
|
||||
-- Now add items from match_inside to shownitems
|
||||
for i, v in ipairs(match_inside) do
|
||||
for _, v in ipairs(match_inside) do
|
||||
table.insert(shownitems, v)
|
||||
end
|
||||
|
||||
|
@ -315,7 +315,7 @@ function menubar.show(scr)
|
|||
local prompt_args = menubar.prompt_args or {}
|
||||
prompt_args.prompt = "Run: "
|
||||
awful.prompt.run(prompt_args, instance.prompt.widget,
|
||||
function(s) end, -- exe_callback function set to do nothing
|
||||
function() end, -- exe_callback function set to do nothing
|
||||
awful.completion.shell, -- completion_callback
|
||||
awful.util.get_cache_dir() .. "/history_menu",
|
||||
nil,
|
||||
|
|
|
@ -83,7 +83,7 @@ local function get_icon_lookup_path()
|
|||
table.insert(paths, 1, glib.get_user_data_dir())
|
||||
table.insert(paths, 1, glib.build_filenamev({glib.get_home_dir(),
|
||||
'.icons'}))
|
||||
for k,dir in ipairs(paths) do
|
||||
for _,dir in ipairs(paths) do
|
||||
local icons_dir = glib.build_filenamev({dir, 'icons'})
|
||||
if awful_util.dir_readable(icons_dir) then
|
||||
if icon_theme then
|
||||
|
@ -96,14 +96,14 @@ local function get_icon_lookup_path()
|
|||
glib.build_filenamev({icons_dir, 'hicolor'}))
|
||||
end
|
||||
end
|
||||
for i, icon_theme_directory in ipairs(icon_theme_paths) do
|
||||
for j, size in ipairs(all_icon_sizes) do
|
||||
for _, icon_theme_directory in ipairs(icon_theme_paths) do
|
||||
for _, size in ipairs(all_icon_sizes) do
|
||||
add_if_readable(icon_lookup_path,
|
||||
glib.build_filenamev({icon_theme_directory,
|
||||
size, 'apps'}))
|
||||
end
|
||||
end
|
||||
for k,dir in ipairs(paths)do
|
||||
for _,dir in ipairs(paths)do
|
||||
-- lowest priority fallbacks
|
||||
add_if_readable(icon_lookup_path,
|
||||
glib.build_filenamev({dir, 'pixmaps'}))
|
||||
|
@ -127,7 +127,7 @@ function utils.lookup_icon_uncached(icon_file)
|
|||
-- supported, do not perform a lookup.
|
||||
return awful_util.file_readable(icon_file) and icon_file or nil
|
||||
else
|
||||
for i, directory in ipairs(get_icon_lookup_path()) do
|
||||
for _, directory in ipairs(get_icon_lookup_path()) do
|
||||
if is_format_supported(icon_file) and
|
||||
awful_util.file_readable(directory .. "/" .. icon_file) then
|
||||
return directory .. "/" .. icon_file
|
||||
|
@ -170,6 +170,7 @@ function utils.parse(file)
|
|||
for line in io.lines(file) do
|
||||
if line:find("^%s*#") then
|
||||
-- Skip comments.
|
||||
(function() end)() -- I haven't found a nice way to silence luacheck here
|
||||
elseif not desktop_entry and line == "[Desktop Entry]" then
|
||||
desktop_entry = true
|
||||
else
|
||||
|
@ -260,7 +261,7 @@ end
|
|||
-- @treturn int Text width.
|
||||
function utils.compute_textbox_width(textbox, s)
|
||||
s = s or mouse.screen
|
||||
local w, h = textbox:get_preferred_size(s)
|
||||
local w, _ = textbox:get_preferred_size(s)
|
||||
return w
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue