This commit is contained in:
Uli Schlachter 2016-01-17 15:59:54 +01:00
commit 1aed092fea
4 changed files with 45 additions and 14 deletions

View File

@ -39,7 +39,7 @@ end
-- {{{ Variable definitions -- {{{ Variable definitions
-- Themes define colours, icons, font and wallpapers. -- Themes define colours, icons, font and wallpapers.
beautiful.init("@AWESOME_THEMES_PATH@/default/theme.lua") beautiful.init(awful.util.get_themes_dir() .. "default/theme.lua")
-- This is used later as the default terminal and editor to run. -- This is used later as the default terminal and editor to run.
terminal = "xterm" terminal = "xterm"
@ -318,7 +318,7 @@ globalkeys = awful.util.table.join(
awful.prompt.run({ prompt = "Run Lua code: " }, awful.prompt.run({ prompt = "Run Lua code: " },
mypromptbox[awful.screen.focused()].widget, mypromptbox[awful.screen.focused()].widget,
awful.util.eval, nil, awful.util.eval, nil,
awful.util.getdir("cache") .. "/history_eval") awful.util.get_cache_dir() .. "/history_eval")
end, end,
{description = "lua execute prompt", group = "awesome"}), {description = "lua execute prompt", group = "awesome"}),
-- Menubar -- Menubar

View File

@ -134,6 +134,43 @@ function util.restart()
capi.awesome.restart() capi.awesome.restart()
end end
--- Get the config home according to the XDG basedir specification.
-- @return the config home (XDG_CONFIG_HOME) with a slash at the end.
function util.get_xdg_config_home()
return (os.getenv("XDG_CONFIG_HOME") or os.getenv("HOME") .. "/.config") .. "/"
end
--- Get the cache home according to the XDG basedir specification.
-- @return the cache home (XDG_CACHE_HOME) with a slash at the end.
function util.get_xdg_cache_home()
return (os.getenv("XDG_CACHE_HOME") or os.getenv("HOME") .. "/.cache") .. "/"
end
--- Get the path to the user's config dir.
-- This is the directory containing the configuration file ("rc.lua").
-- @return A string with the requested path with a slash at the end.
function util.get_configuration_dir()
return capi.awesome.conffile:match(".*/") or "./"
end
--- Get the path to a directory that should be used for caching data.
-- @return A string with the requested path with a slash at the end.
function util.get_cache_dir()
return util.get_xdg_cache_home() .. "awesome/"
end
--- Get the path to the directory where themes are installed.
-- @return A string with the requested path with a slash at the end.
function util.get_themes_dir()
return "@AWESOME_THEMES_PATH@" .. "/"
end
--- Get the path to the directory where our icons are installed.
-- @return A string with the requested path with a slash at the end.
function util.get_awesome_icon_dir()
return "@AWESOME_ICON_PATH@" .. "/"
end
--- Get the user's config or cache dir. --- Get the user's config or cache dir.
-- It first checks XDG_CONFIG_HOME / XDG_CACHE_HOME, but then goes with the -- It first checks XDG_CONFIG_HOME / XDG_CACHE_HOME, but then goes with the
-- default paths. -- default paths.
@ -141,17 +178,11 @@ end
-- @return A string containing the requested path. -- @return A string containing the requested path.
function util.getdir(d) function util.getdir(d)
if d == "config" then if d == "config" then
local dir = os.getenv("XDG_CONFIG_HOME") -- No idea why this is what is returned, I recommend everyone to use
if dir then -- get_configuration_dir() instead
return dir .. "/awesome" return util.get_xdg_config_home() .. "awesome/"
end
return os.getenv("HOME") .. "/.config/awesome"
elseif d == "cache" then elseif d == "cache" then
local dir = os.getenv("XDG_CACHE_HOME") return util.get_cache_dir()
if dir then
return dir .. "/awesome"
end
return os.getenv("HOME").."/.cache/awesome"
end end
end end

View File

@ -27,7 +27,7 @@ local function run(promptbox)
promptbox:spawn_and_handle_error(...) promptbox:spawn_and_handle_error(...)
end, end,
completion.shell, completion.shell,
util.getdir("cache") .. "/history") util.get_cache_dir() .. "/history")
end end
local function spawn_and_handle_error(self, ...) local function spawn_and_handle_error(self, ...)

View File

@ -317,7 +317,7 @@ function menubar.show(scr)
awful.prompt.run(prompt_args, instance.prompt.widget, awful.prompt.run(prompt_args, instance.prompt.widget,
function(s) end, -- exe_callback function set to do nothing function(s) end, -- exe_callback function set to do nothing
awful.completion.shell, -- completion_callback awful.completion.shell, -- completion_callback
awful.util.getdir("cache") .. "/history_menu", awful.util.get_cache_dir() .. "/history_menu",
nil, nil,
menubar.hide, function(query) menulist_update(query, scr) end, menubar.hide, function(query) menulist_update(query, scr) end,
prompt_keypressed_callback prompt_keypressed_callback