awesomeWM / awesome

awesome window manager
https://awesomewm.org/
GNU General Public License v2.0
6.21k stars 593 forks source link

xresources theme: might define same fg/bg colors / enhance an existing theme #314

Open blueyed opened 8 years ago

blueyed commented 8 years ago

With the dark Solarized theme, xrdb.color8 is the same color as theme.bg_normal, which results in the tasklist entry of minimized windows to be invisible.

I could imagine to fix this by using a pattern like this:

local different = function(from, c1, c2)
    return from ~= c1 and c1 or c2
end

theme.fg_minimize   = theme.bg_normal
theme.bg_minimize   = different(theme.fg_minimize, xrdb.color8, xrdb.color0)

(although color0 and color8 are very similar, it would be better already).

Is there some functionality in awesome already to calculate how different two colors are already? Then maybe multiple alternatives could be checked, until the contrast is big enough?

Solarized theme

Apart from that, I've started to create a Solarized theme, based on the xresources one already.

The themes itself are not "importable" via require, are they?

Is there a better way to deviate from another theme than the following?

local beautiful = require("beautiful")
local xrdb = beautiful.xresources.get_current_theme()

local this_file = debug.getinfo(1, "S").source:sub(2)
function dirname(name)
    return name:match("^(.+)[/\\].-$") or (default or "")
end
local theme = dofile(dirname(this_file) .. "/../xresources/theme.lua")

-- adjust theme

return theme
actionless commented 8 years ago

i will think on the first topic during the day

about the latter -- i am doing exactly the same thing in my local config: https://github.com/actionless/awesome_config/blob/devel/actionless/common_theme.lua#L16 mb it will make sense to add some helper to beautiful for importing a theme, like:

local theme = beautiful.load_theme('theme_name')
actionless commented 8 years ago

for me it seems to be an error in the theme if some of the colors is the same as background, so i don't think what it's reasonable to handle such case

actionless commented 5 years ago

mb we can move choose_contrast_color from gtk theme somewhere to gears? : https://github.com/awesomeWM/awesome/blob/4bd5b1940dbfb7d8275cc8a55b870b5fde55ebfc/themes/gtk/theme.lua#L249-L253

https://github.com/awesomeWM/awesome/blob/4bd5b1940dbfb7d8275cc8a55b870b5fde55ebfc/themes/gtk/theme.lua#L68-L82

in this implementation priority of choices is defined by order, it could be changed to compare lightness of two colors and choose most contrast, but i personally would prefer to have both options