beautiful: Save the theme path

Fix #1508
This commit is contained in:
Emmanuel Lepage Vallee 2017-05-25 04:40:45 -04:00
parent b6e6a04895
commit ac8af66005
1 changed files with 6 additions and 0 deletions

View File

@ -17,6 +17,7 @@ local lgi = require("lgi")
local Pango = lgi.Pango local Pango = lgi.Pango
local PangoCairo = lgi.PangoCairo local PangoCairo = lgi.PangoCairo
local gears_debug = require("gears.debug") local gears_debug = require("gears.debug")
local Gio = require("lgi").Gio
local protected_call = require("gears.protected_call") local protected_call = require("gears.protected_call")
local xresources = require("beautiful.xresources") local xresources = require("beautiful.xresources")
@ -94,6 +95,9 @@ local active_font
--- The Awesome icon path. --- The Awesome icon path.
-- @beautiful beautiful.awesome_icon -- @beautiful beautiful.awesome_icon
--- The current theme path (if any)
-- @tfield string beautiful.theme_path
--- Load a font from a string or a font description. --- Load a font from a string or a font description.
-- --
-- @see https://developer.gnome.org/pango/stable/pango-Fonts.html#pango-font-description-from-string -- @see https://developer.gnome.org/pango/stable/pango-Fonts.html#pango-font-description-from-string
@ -187,6 +191,8 @@ function beautiful.init(config)
if type(config) == 'string' then if type(config) == 'string' then
-- Expand the '~' $HOME shortcut -- Expand the '~' $HOME shortcut
config = config:gsub("^~/", homedir .. "/") config = config:gsub("^~/", homedir .. "/")
local dir = Gio.File.new_for_path(config):get_parent()
beautiful.theme_path = dir and (dir:get_path().."/") or nil
theme = protected_call(dofile, config) theme = protected_call(dofile, config)
elseif type(config) == 'table' then elseif type(config) == 'table' then
theme = config theme = config