13

Wow - this seems so difficult to resolve! I've searched and see other people with similar problem/complaint about being able to quickly identify active window, for example, Highlight Window with focus even more But, I have yet to find any real solution!

I have 3 monitors, and am "color-impaired" or "shade-blind" (a step above 'color-blind') I find the difference in active vs inactive window so subtle I can't tell what's what.

Adding a window shadow does not help much because full-screen windows don't get the shadow. Plus, the shadow is quite subtle, so it's not quick-easy identifier.

I'm used to MS Windows where it is so easy to change the window's title bar color, and to have very high contrast. I can see in an instant what window is the active window. I'm constantly - and this is after few weeks now on Ubuntu - having problem figuring this out with Ubuntu.

The simple solution for me would be to have 2 different highly contrasting colors for the title bar of windows. Can't this be done? I've tried looking for other themes, but they all seem to stick with the 'all windows have the same (or so it appears to me) colored title bar whether active or not'. I am finding this issue VERY frustrating. I also tried the dim inactive window plugin and it didn't do much of anything and is of no help. (Ubuntu 16.04. 3 monitors, nvidia controller and their video driver)

  • 2
    I find the issue VERY frustrating too – user3804598 Sep 3 '17 at 16:41
  • 2
    I noticed that the active window has 1) a different color of the title text (in my case white vs gray for active/inactive), 2) close button (cross) is highlighted with orange color. Not a solution, but lets discriminate between active / inactive windows somehow. – user3804598 Sep 3 '17 at 16:52
  • 1
    I find it also very difficult to distinguish from active and other windows, I often type things in the wrong windows and this has been happening FOR YEARS now..., have someone found a way to fix it? it is really an annoying and frustrating thing. I am using 16.04, but ready to move to 18.04. – Aquarius Power Jan 5 '19 at 16:29
  • Grace period note: The bounty has failed to look for a good answer, unfortunately. We have three new answers that do not fulfill the requirement by OP: to change colours for active/inactive window decoration for Ubuntu 16.04 (supported until 2021) and not just newer releases. I guess the only way *is to suggest modifying the theme that works for both Unity and GNOME, which might be written as a community wiki. – clearkimura Nov 18 '19 at 21:17
5
+50

Have you checked the answer for this question? Create or edit ~/.config/gtk-3.0/gtk.css as:

.titlebar {
    background: #3089FF;
    color:white; 
}

.titlebar:backdrop  {
    background: #777777;
    color:white;
} 

Note that you can choose different colors to suite your preferences. Then refresh the gnome:

setsid gnome-shell --replace

I just tried it and it worked for me.enter image description here

| improve this answer | |
  • 1
    @RRelax is referring to the Unity interface. From what I can remember, Unity has no GNOME elements in it. – CStafford-14 Nov 14 '19 at 16:03
  • Suggestion: Mention the release compatibility. What is the equivalent modification in Ubuntu 16.04 (Unity) as per original question? Ubuntu 16.04 is supported until 2021 at least, so still relevant to include that in the answer. – clearkimura Nov 15 '19 at 0:11
  • @RRelax, if you upgrade to 18.04 my answer is valid. – Mostafa Najafiyazdi Nov 18 '19 at 0:35
  • @CStafford, yes, it won't work in 16.04 – Mostafa Najafiyazdi Nov 18 '19 at 0:36
4
+250

Out of the box solution

There is a quick little trick pressing Alt+F7, jiggling your mouse and then press Left-Click on mouse when window is positioned back where you wanted it.

The disadvantage is time to manually realign window to it's original coordinates. A better method involving a script assigned to shortcut key is described in the next section.


Reveal active Window with Shortcut Key

This is an improved script over revealwindow2 documented in the next section. That script shrinks and expands the window which overtaxes browser windows that have to reformat the web page layouts.

This new script revealwindow3 can be assigned to a shortcut key so no matter where you are you know the active window:

reveal window3.gif

revealwindow3 bash script

#!/bin/bash

# NAME: revealwindow3
# CALL: Best method is to call via hotkey.

# DESC: Reveal active window by moving it in circle on screen.
# PARM: Pare 1 override default # pixels for moving
#       For Ask Ubuntu Question:
#       https://askubuntu.com/questions/943147/different-colors-for-active-inactive-unity-window-title-bars

# DATE: November 19, 2019.

# NOTE: Enhancement to revealwindow2 which shrinks and expand sizes of window
#       which taxes browsers, etc. that have to reformat the window. Also cause
#       of epileptic like shock.

# Dependancy
command -v xdotool >/dev/null 2>&1 || { echo >&2 \
        "xdotool package required but it is not installed.  Aborting."; \
        exit 3; }

# Defaults

STEP_PIXELS=25
SLEEP=.025

if [[ "$#" -eq 1 ]] ; then
    [[ "$1" -lt 5 ]] || [[ "$1" -gt 1000 ]] && { \
        echo "STEP_PIXELS must be between 5 and 1000" ; exit 2; }
    STEP_PIXELS="$1"
fi

# Get Window Information
    WinID=$(xdotool getactivewindow)
  WinLeft=$(xwininfo -id "$WinID" | grep 'ute upper-left X:' | cut -d: -f2)
   WinTop=$(xwininfo -id "$WinID" | grep 'ute upper-left Y:' | cut -d: -f2)
#echo "Win Flds: $WinLeft x $WinTop x $WinWidth x $WinHeight"

# Array of steps
StepArr=( R R R R R D D D D L L L L L U U U U U )

CurrLeft=$(( WinLeft - (STEP_PIXELS *2) ))
[[ $CurrLeft -lt 0 ]] && CurrLeft=0
CurrTop=$(( WinTop - (STEP_PIXELS *3) ))
[[ $CurrTop -lt 0 ]] && CurrTop=0

function XdoMove () {
    local i
    i="$1"
    case "$1" in
    R)
        CurrLeft=$(( CurrLeft + STEP_PIXELS )) ;;
    D)
        CurrTop=$(( CurrTop + STEP_PIXELS )) ;;
    L)
        CurrLeft=$(( CurrLeft - STEP_PIXELS ))
        [[ $CurrLeft -lt 0 ]] && CurrLeft=0 ;;
    U)
        CurrTop=$(( CurrTop - STEP_PIXELS ))
        [[ $CurrTop -lt 0 ]] && CurrTop=0 ;;
    esac

    xdotool windowmove "$WinID" "$CurrLeft" "$CurrTop"
    sleep $SLEEP
}

xdotool windowmove "$WinID" "$CurrLeft" "$CurrTop"
for i in "${StepArr[@]}" ; do XdoMove "$i" ; done


# Restore original Window size and position just in case
xdotool windowmove "$WinID" "$WinLeft" "$WinTop"

sleep .1 # Need time for xorg to update itself.

# Compensate for Window refusing to move to top (Y) coordinate specified
   InfoTop=$(xwininfo -id "$WinID" | grep 'ute upper-left Y:' | cut -d: -f2)

if [[ $InfoTop -ne $WinTop ]] ; then
    Adjust=$((InfoTop - WinTop))
    AdjTop=$((WinTop - Adjust))
    xdotool windowmove "$WinID" "$WinLeft" "$AdjTop"
    echo "Top adjusted by: -$Adjust from: $WinTop to: $AdjTop"
fi


A script to highlight active window

This method uses shortcut key. I used Ctrl+Alt+W because left pinky + left middle finger + left thumb is an easy combination. Assign the shortcut key to the script reavelwindow2.

revealwindow2.gif

The script shrinks the active window in 10 steps and then expands it in 5 steps. Originally I wrote the script using wmctrl but it wouldn't work for me. So I used xdotool instead:

#!/bin/bash

# NAME: revealwindow2
# CALL: Best method is to call via hotkey.

# DESC: Shrink and expand size of active window.
#       For Ask Ubuntu Question:
#       https://askubuntu.com/questions/943147/different-colors-for-active-inactive-unity-window-title-bars

# DATE: November 17, 2019. Modified November 18, 2019.

# Dependancy
command -v xdotool >/dev/null 2>&1 || { echo >&2 \
        "xdotool package required but it is not installed.  Aborting."; \
        exit 3; }

# Get Window Information
    WinID=$(xdotool getactivewindow)
  WinLeft=$(xwininfo -id "$WinID" | grep 'ute upper-left X:' | cut -d: -f2)
   WinTop=$(xwininfo -id "$WinID" | grep 'ute upper-left Y:' | cut -d: -f2)
 WinWidth=$(xwininfo -id "$WinID" | grep 'Width:' | cut -d: -f2)
WinHeight=$(xwininfo -id "$WinID" | grep 'Height:' | cut -d: -f2)
#echo "Win Flds: $WinLeft x $WinTop x $WinWidth x $WinHeight"

WidthStep=$(( WinWidth / 10 ))
HeightStep=$(( WinHeight / 10 ))

function XdoResize () {
    local i
    i="$1"
    NewLeft=$(( i * WidthStep/2 + WinLeft ))
    NewTop=$(( i * HeightStep/2 + WinTop ))
    NewWidth=$(( WinWidth - ( i * WidthStep) ))
    NewHeight=$(( WinHeight - ( i * HeightStep) ))

    xdotool windowsize "$WinID" "$NewWidth" "$NewHeight"
    xdotool windowmove "$WinID" "$NewLeft" "$NewTop"
    sleep .012
}

# Shrink window with xdotool
for (( i=1; i<10; i++ )) ; do XdoResize $i ; done

# Expand window with xdotool
for (( i=5; i>0; i-- )) ; do XdoResize $i ; done

# Restore original Window size and position just in case
xdotool windowsize "$WinID" "$WinWidth" "$WinHeight"
xdotool windowmove "$WinID" "$WinLeft" "$WinTop"

sleep .1 # Need time for xorg to update itself.

# Compensate for Window refusing to move to top (Y) coordinate specified
   InfoTop=$(xwininfo -id "$WinID" | grep 'ute upper-left Y:' | cut -d: -f2)

if [[ $InfoTop -ne $WinTop ]] ; then
    Adjust=$((InfoTop - WinTop))
    AdjTop=$((WinTop - Adjust))
    xdotool windowmove "$WinID" "$WinLeft" "$AdjTop"
    echo "Top adjusted by: -$Adjust from: $WinTop to: $AdjTop"
fi

Some windows don't allow resizing. In this case the Window will just move down to the right and then back up to the left. You still get the same visual clues which is the active window, just with different movements.

| improve this answer | |
  • Suggestion: The script approach may have hope. Instead of shrinking the window, is there something like changing contrast (applying high contrast theme) for the active window only? – clearkimura Nov 18 '19 at 12:15
  • @clearkimura I thought of something that initially - flashing the title bar of active window with different colors but couldn't come up with anything. The most common approach people have for permanent highlighting is changing the .css: linuxquestions.org/questions/… BTW in the script the shrinking / re-zooming is a lot smoother in real life that it appears in the .gif which makes it look choppy. – WinEunuuchs2Unix Nov 18 '19 at 12:24
  • This dated post (2017) noted the possibility to run xprop -f _GTK_THEME_VARIANT 8u -set _GTK_THEME_VARIANT dark and select a window to toggle dark theme. The included screenshots are showing Firefox with light and dark header bar in GNOME (before and after the effect). P.S.: Not sure what makes this possible; doesn't work in other GTK+ desktop like Xfce. – clearkimura Nov 18 '19 at 14:55
  • 1
    @clearkimura I rewrote most of the script tonight as I found a little bug in xdotool and wmcctrl. With three monitors I'm often loosing the active Window after taking micro-breaks so it's handy to have a shortcut to highlight the active window. I'll be using this a lot :) As for the xprop I'll let someone else tackle that project. On the surface though it looks more about displaying a single window's properties rather than changing them. – WinEunuuchs2Unix Nov 19 '19 at 2:16
  • 1
    @clearkimura Although bounty expired and was already awarded, I still felt compelled to write a better script. Not overly magnanimous as I'll use it all the time anyway. Thanks for bringing attention to the difficulty of finding the active window. It had not occurred to me the number of times I had the problem myself before. It's especially difficult these days with three monitors covering 9 ft wide x 4 feet high area. – WinEunuuchs2Unix Nov 20 '19 at 1:00
1

As per Ubuntu 16.04 Documentation, you can open settings and go to the universal access section. All you have to do is turn on High Contrast, and you're done.

You can find this option in Settings > Universal Access > Seeing > High Contrast. If you're using an earlier version of Ubuntu, this should still work.

| improve this answer | |
  • Suggestion: Is there any missing steps or additional tweak aside from the documentation? Looks broken from my testing: Ubuntu 16.04 live session with high contrast ON--even the window title bars had no difference between active and inactive ones. – clearkimura Nov 15 '19 at 0:19
  • Does the high contrast option supposed to differentiate the active and inactive window borders--seems not from my testing. Even the improved Ubuntu 18.04 with high contrast ON has the same colour for active and inactive ones... no wonder colour-blind users are frustrated. – clearkimura Nov 16 '19 at 13:40
  • I haven't used 16.04 in a while, but that's the same suggestion I gave then. – CStafford-14 Dec 24 '19 at 0:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.