New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

awesome WM window color black is the same for focused & unfocused #2780

Closed
3hhh opened this Issue Apr 27, 2017 · 3 comments

Comments

Projects
None yet
3 participants
@3hhh

3hhh commented Apr 27, 2017

In Qubes 3.2R2 qubes.get_colour_focus(c) and qubes.get_colour(c) of /usr/share/awesome/lib/qubes.lua return the same color (black) for windows labeled with black, i.e. dom0 or e.g. vault windows.

Expected behavior: Dark gray for the non-focused version in order to identify the focused window (similar behavior for all other colors appears to be implemented, just black isn't working).

Possible impact: Typing in the wrong VM ("focus steal").

@marmarek

This comment has been minimized.

Show comment
Hide comment
@marmarek

marmarek Apr 27, 2017

Member

I think the important line is here: https://github.com/QubesOS/qubes-desktop-linux-awesome/blob/master/awesome-3.5.5-qubes.patch#L238-L239
Any better idea than having special case for black?

Member

marmarek commented Apr 27, 2017

I think the important line is here: https://github.com/QubesOS/qubes-desktop-linux-awesome/blob/master/awesome-3.5.5-qubes.patch#L238-L239
Any better idea than having special case for black?

@3hhh

This comment has been minimized.

Show comment
Hide comment
@3hhh

3hhh Apr 29, 2017

I tested a change of https://github.com/QubesOS/qubes-desktop-linux-awesome/blob/master/awesome-3.5.5-qubes.patch#L216 to
l = math.max(math.min((l+0.5) * factor, 1), 0)
which made it work for black VMs, but also all other colors more bright (unwanted).

The interesting part:
dom0 consoles stayed totally black, i.e. dom0 seems to be a special case not handled via the aforementioned lines.
So we already seem to have some special case for dom0 somewhere.

3hhh commented Apr 29, 2017

I tested a change of https://github.com/QubesOS/qubes-desktop-linux-awesome/blob/master/awesome-3.5.5-qubes.patch#L216 to
l = math.max(math.min((l+0.5) * factor, 1), 0)
which made it work for black VMs, but also all other colors more bright (unwanted).

The interesting part:
dom0 consoles stayed totally black, i.e. dom0 seems to be a special case not handled via the aforementioned lines.
So we already seem to have some special case for dom0 somewhere.

@3hhh

This comment has been minimized.

Show comment
Hide comment
@3hhh

3hhh Apr 30, 2017

local function ensure_min_luminance(colour, minLuminance)
    local r, g, b = color.parse_color(colour)

    h, l, s = rgb_to_hls(r, g, b)
    l = math.max(l,minLuminance)
    r, g, b = hls_to_rgb(h, l, s)

    return string.format('#%02x%02x%02x',
        math.floor(r * 0xff), math.floor(g * 0xff), math.floor(b * 0xff))
end

function qubes.init()
    local minLuminance = 0.3
    local shiftUnfocused = 0.5
    local blackSafe = ensure_min_luminance("#000000", minLuminance)

    -- read labels
    qubes.labels = { ['*'] = {
	--all other (= dom0) windows
        colour = shift_luminance(blackSafe, shiftUnfocused),
        colour_focus = blackSafe 
     } }

    local data = util.pread([[python -c "
import qubes.qubes
print(''.join('{}:{}\n'.format(l.index, l.color)
    for l in qubes.qubes.QubesVmLabels.values()))
"]])
    for index, colour in string.gmatch(data, '(%d):0x([0-9a-f]+)') do
        colour = '#' .. colour
	--ensure min luminance so we can shift it for unfocused windows
        colour = ensure_min_luminance(colour,minLuminance)

        qubes.labels[index] = { colour = shift_luminance(colour, shiftUnfocused),
            colour_focus = colour }
    end
end

seems to do the trick incl. dom0 windows.
Actually it will ensure that all VM colors are sufficiently bright to be able to reduce the luminance/brightness when they are unfocused. So it'll also have an effect on e.g. dark blue VMs (default colour gets more bright - so focused dom0 is now e.g. gray).

I'll test this for some time...

3hhh commented Apr 30, 2017

local function ensure_min_luminance(colour, minLuminance)
    local r, g, b = color.parse_color(colour)

    h, l, s = rgb_to_hls(r, g, b)
    l = math.max(l,minLuminance)
    r, g, b = hls_to_rgb(h, l, s)

    return string.format('#%02x%02x%02x',
        math.floor(r * 0xff), math.floor(g * 0xff), math.floor(b * 0xff))
end

function qubes.init()
    local minLuminance = 0.3
    local shiftUnfocused = 0.5
    local blackSafe = ensure_min_luminance("#000000", minLuminance)

    -- read labels
    qubes.labels = { ['*'] = {
	--all other (= dom0) windows
        colour = shift_luminance(blackSafe, shiftUnfocused),
        colour_focus = blackSafe 
     } }

    local data = util.pread([[python -c "
import qubes.qubes
print(''.join('{}:{}\n'.format(l.index, l.color)
    for l in qubes.qubes.QubesVmLabels.values()))
"]])
    for index, colour in string.gmatch(data, '(%d):0x([0-9a-f]+)') do
        colour = '#' .. colour
	--ensure min luminance so we can shift it for unfocused windows
        colour = ensure_min_luminance(colour,minLuminance)

        qubes.labels[index] = { colour = shift_luminance(colour, shiftUnfocused),
            colour_focus = colour }
    end
end

seems to do the trick incl. dom0 windows.
Actually it will ensure that all VM colors are sufficiently bright to be able to reduce the luminance/brightness when they are unfocused. So it'll also have an effect on e.g. dark blue VMs (default colour gets more bright - so focused dom0 is now e.g. gray).

I'll test this for some time...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment