feat(themes: xresources): recolor layout icons

This commit is contained in:
actionless 2015-08-02 12:46:44 +02:00 committed by Daniel Hahler
parent 47ba4729a4
commit 2f340f05ff
2 changed files with 36 additions and 19 deletions

View File

@ -286,6 +286,16 @@ function color.create_opaque_pattern(col)
-- gradients can do weird self-intersections) -- gradients can do weird self-intersections)
end end
function color.recolor_image(image, new_color)
if type(image) == 'string' then
image = cairo.ImageSurface.create_from_png(image)
end
local cr = cairo.Context.create(image)
cr:set_source(color.create_pattern(new_color))
cr:mask(cairo.Pattern.create_for_surface(image), 0, 0)
return image
end
function color.mt:__call(...) function color.mt:__call(...)
return color.create_pattern(...) return color.create_pattern(...)
end end

View File

@ -6,10 +6,12 @@
local xresources = require("beautiful").xresources local xresources = require("beautiful").xresources
local xrdb = xresources.get_current_theme() local xrdb = xresources.get_current_theme()
local dpi = xresources.apply_dpi local dpi = xresources.apply_dpi
local recolor_image = require("gears").color.recolor_image
local theme_assets = dofile("@AWESOME_THEMES_PATH@/xresources/assets.lua") -- inherit default theme
local theme = dofile("@AWESOME_THEMES_PATH@/default/theme.lua") local theme = dofile("@AWESOME_THEMES_PATH@/default/theme.lua")
-- load vector assets' generators for this theme
local theme_assets = dofile("@AWESOME_THEMES_PATH@/xresources/assets.lua")
theme.font = "sans 8" theme.font = "sans 8"
@ -77,23 +79,28 @@ theme.menu_width = dpi(100)
--theme.titlebar_maximized_button_normal_active = "@AWESOME_THEMES_PATH@/default/titlebar/maximized_normal_active.png" --theme.titlebar_maximized_button_normal_active = "@AWESOME_THEMES_PATH@/default/titlebar/maximized_normal_active.png"
--theme.titlebar_maximized_button_focus_active = "@AWESOME_THEMES_PATH@/default/titlebar/maximized_focus_active.png" --theme.titlebar_maximized_button_focus_active = "@AWESOME_THEMES_PATH@/default/titlebar/maximized_focus_active.png"
-- You can use your own layout icons like this:
--theme.layout_fairh = "@AWESOME_THEMES_PATH@/default/layouts/fairh.png" -- Recolor layout icons:
--theme.layout_fairv = "@AWESOME_THEMES_PATH@/default/layouts/fairv.png" for _, layout_name in ipairs({
--theme.layout_floating = "@AWESOME_THEMES_PATH@/default/layouts/floating.png" 'layout_fairh',
--theme.layout_magnifier = "@AWESOME_THEMES_PATH@/default/layouts/magnifier.png" 'layout_fairv',
--theme.layout_max = "@AWESOME_THEMES_PATH@/default/layouts/max.png" 'layout_floating ',
--theme.layout_fullscreen = "@AWESOME_THEMES_PATH@/default/layouts/fullscreen.png" 'layout_magnifier',
--theme.layout_tilebottom = "@AWESOME_THEMES_PATH@/default/layouts/tilebottom.png" 'layout_max',
--theme.layout_tileleft = "@AWESOME_THEMES_PATH@/default/layouts/tileleft.png" 'layout_fullscreen',
--theme.layout_tile = "@AWESOME_THEMES_PATH@/default/layouts/tile.png" 'layout_tilebottom',
--theme.layout_tiletop = "@AWESOME_THEMES_PATH@/default/layouts/tiletop.png" 'layout_tileleft ',
--theme.layout_spiral = "@AWESOME_THEMES_PATH@/default/layouts/spiral.png" 'layout_tile',
--theme.layout_dwindle = "@AWESOME_THEMES_PATH@/default/layouts/dwindle.png" 'layout_tiletop',
--theme.layout_cornernw = "@AWESOME_THEMES_PATH@/default/layouts/cornernw.png" 'layout_spiral ',
--theme.layout_cornerne = "@AWESOME_THEMES_PATH@/default/layouts/cornerne.png" 'layout_dwindle',
--theme.layout_cornersw = "@AWESOME_THEMES_PATH@/default/layouts/cornersw.png" 'layout_cornernw',
--theme.layout_cornerse = "@AWESOME_THEMES_PATH@/default/layouts/cornerse.png" 'layout_cornerne',
'layout_cornersw',
'layout_cornerse',
}) do
theme[layout_name] = recolor_image(theme[layout_name], theme.fg_normal)
end
-- Define the icon theme for application icons. If not set then the icons -- Define the icon theme for application icons. If not set then the icons