refactor(themes: xresources): move recoloring to theme assets

This commit is contained in:
actionless 2015-08-02 20:50:31 +02:00 committed by Daniel Hahler
parent d1f13975dd
commit 9c750ede63
2 changed files with 65 additions and 57 deletions

View File

@ -5,6 +5,7 @@
local cairo = require("lgi").cairo
local gears = require("gears")
local recolor_image = gears.color.recolor_image
local screen = screen
local theme_assets = {}
@ -150,5 +151,66 @@ function theme_assets.wallpaper(bg, fg, alt_fg)
return img
end
-- Recolor titlebar icons:
function theme_assets.recolor_titlebar_normal(theme, color)
for _, titlebar_icon in ipairs({
'titlebar_close_button_normal',
'titlebar_ontop_button_normal_inactive',
'titlebar_ontop_button_normal_active',
'titlebar_sticky_button_normal_inactive',
'titlebar_sticky_button_normal_active',
'titlebar_floating_button_normal_inactive',
'titlebar_floating_button_normal_active',
'titlebar_maximized_button_normal_inactive',
'titlebar_maximized_button_normal_active',
}) do
theme[titlebar_icon] = recolor_image(theme[titlebar_icon], color)
end
return theme
end
function theme_assets.recolor_titlebar_focus(theme, color)
for _, titlebar_icon in ipairs({
'titlebar_close_button_focus',
'titlebar_ontop_button_focus_inactive',
'titlebar_ontop_button_focus_active',
'titlebar_sticky_button_focus_inactive',
'titlebar_sticky_button_focus_active',
'titlebar_floating_button_focus_inactive',
'titlebar_floating_button_focus_active',
'titlebar_maximized_button_focus_inactive',
'titlebar_maximized_button_focus_active',
}) do
theme[titlebar_icon] = recolor_image(theme[titlebar_icon], color)
end
return theme
end
-- Recolor layout icons:
function theme_assets.recolor_layout(theme, color)
for _, layout_name in ipairs({
'layout_fairh',
'layout_fairv',
'layout_floating',
'layout_magnifier',
'layout_max',
'layout_fullscreen',
'layout_tilebottom',
'layout_tileleft',
'layout_tile',
'layout_tiletop',
'layout_spiral',
'layout_dwindle',
'layout_cornernw',
'layout_cornerne',
'layout_cornersw',
'layout_cornerse',
}) do
theme[layout_name] = recolor_image(theme[layout_name], color)
end
return theme
end
return theme_assets
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -6,7 +6,6 @@
local xresources = require("beautiful").xresources
local xrdb = xresources.get_current_theme()
local dpi = xresources.apply_dpi
local recolor_image = require("gears").color.recolor_image
-- inherit default theme
local theme = dofile("@AWESOME_THEMES_PATH@/default/theme.lua")
@ -56,62 +55,9 @@ theme.menu_width = dpi(100)
--theme.bg_widget = "#cc0000"
-- Recolor titlebar icons:
for _, titlebar_icon in ipairs({
'titlebar_close_button_normal',
'titlebar_ontop_button_normal_inactive',
'titlebar_ontop_button_normal_active',
'titlebar_sticky_button_normal_inactive',
'titlebar_sticky_button_normal_active',
'titlebar_floating_button_normal_inactive',
'titlebar_floating_button_normal_active',
'titlebar_maximized_button_normal_inactive',
'titlebar_maximized_button_normal_active',
}) do
theme[titlebar_icon] = recolor_image(theme[titlebar_icon], theme.fg_normal)
end
for _, titlebar_icon in ipairs({
'titlebar_close_button_focus',
'titlebar_ontop_button_focus_inactive',
'titlebar_ontop_button_focus_active',
'titlebar_sticky_button_focus_inactive',
'titlebar_sticky_button_focus_active',
'titlebar_floating_button_focus_inactive',
'titlebar_floating_button_focus_active',
'titlebar_maximized_button_focus_inactive',
'titlebar_maximized_button_focus_active',
}) do
theme[titlebar_icon] = recolor_image(theme[titlebar_icon], theme.fg_focus)
end
-- Recolor layout icons:
for _, layout_name in ipairs({
'layout_fairh',
'layout_fairv',
'layout_floating',
'layout_magnifier',
'layout_max',
'layout_fullscreen',
'layout_tilebottom',
'layout_tileleft',
'layout_tile',
'layout_tiletop',
'layout_spiral',
'layout_dwindle',
'layout_cornernw',
'layout_cornerne',
'layout_cornersw',
'layout_cornerse',
}) do
theme[layout_name] = recolor_image(theme[layout_name], theme.fg_normal)
end
theme = theme_assets.recolor_titlebar_normal(theme, theme.fg_normal)
theme = theme_assets.recolor_titlebar_focus(theme, theme.fg_focus)
theme = theme_assets.recolor_layout(theme, theme.fg_normal)
-- Define the icon theme for application icons. If not set then the icons
-- from /usr/share/icons and /usr/share/icons/hicolor will be used.