Linux – How to make windows stay opaque when inactive

linuxwindow-managerxfcexorg

I set Xfce to make all windows semi-transparent when they don’t have mouse focus. How can I set a particular window to remain opaque when inactive? Xfce doesn’t have an option to change settings for specific windows (as far as I know).

I found a solution for this before, but I can’t find it anymore. I used a command-line program to set a particular window manager hint on the window I wanted, and that prevented the window from becoming transparent. But I can’t remember the program I used or the name of the window manager hint. I think part of the hint name may have been LOCKED.

This is useful for keeping GIMP windows from becoming transparent when they lose mouse focus, for example.

I have transset-df but it doesn’t have a way to force a window to keep the same transparency when inactive.

Best Answer

Use Devilspie2 to set the window type to "Utility" for selective applications. This window type will not be affected by "Opacity of inactive windows" in Xfce environment.

Preliminary setup

Install Devilspie2 from the repository (available in Debian and Ubuntu repositories), then create a new configuration file at $HOME/.config/devilspie2 with the following content.

debug_print("Window Name: " .. get_window_name());
debug_print("Application name: " .. get_application_name());

if (get_application_name()=="xfce4-dict") then
   set_window_type "_NET_WM_WINDOW_TYPE_UTILITY";
end

Save the file as opaque.lua. The file name can be anything, but it must have .lua file extension to work with Devilspie2.

Preliminary testing

Run Devilspie2 in debug mode and you will see something like below.

$  devilspie2 -d
Running devilspie2 in debug mode.

Using scripts from folder: /home/USERNAME/.config/devilspie2
------------
List of LUA files handling "window_open" events in folder:
/home/USERNAME/.config/devilspie2/opaque.lua
List of LUA files handling "window_close" events in folder:
------------
Window Name: Desktop
Application name: xfdesktop
Window Name: xfce4-panel
Application name: xfce4-panel
Window Name: Application Finder
Application name: xfrun4
Window Name: Dictionary
Application name: xfce4-dict

The following screenshots are showing inactive window of Dictionary, before and after running Devilspie2. Notice that the opacity changes for Dictionary (bottom) but Xfce Terminal remained less opaque (left) while both windows are inactive.

Dictionary less opaque without Devilspie2

Dictionary full opaque with Devilspie2

The inactive window of Dictionary remained fully opaque because the window type has been changed to "Utility" by Devilspie2, with respect to the configuration file.

Modifying setup

The created configuration file contains the first two lines that begin with debug_print to show debug messages of "Window Name: ... Application name: ...". These lines allow Devilspie2 to show respective names for both currently running applications and subsequently run applications.

Based on the debug messages, user shall follow these steps:

  1. Identify the application of choice, which needs to be fully opaque when inactive. Look for the line containing its Application name: and copy the value.

  2. Open the same configuration file at /home/USERNAME/.config/devilspie2/opaque.lua using a text editor, then replace xfce4-dict with the application of choice.

  3. Save the file.

  4. Quit and run again Devilspie2.

Note that USERNAME refers to the current username.

The modified configuration will now be effective. If the application of choice is already running, switch the window back and forth to see effective changes when the window becomes inactive again.

Persistent setup: Devilspie2 must be running in background for this solution to be effective for every session. To make this persistent, add devilspie2 under "Applications Autostart" tab in "Session and Startup".

What window type

Initially, I found this solution while playing with Devilspie2 by trials and errors. Later I tried running GIMP 2.8 and noticed that main window became less opaque when inactive, but the other two floating windows were remained fully opaque.

Then I had confirmed the window type by running xwininfo, then click on one of the floating windows, to print the window manager hints.

$ xwininfo -wm

xwininfo: Please select the window about which you
          would like information by clicking the
          mouse in that window.

xwininfo: Window id: 0x2a00686 "Layers - Brushes"

  Window manager hints:
      Client accepts input or input focus: Yes
      Initial state is Normal State
      Displayed on desktop 1
      Window type:
          Utility
      Window state:
          Skip Pager
          Skip Taskbar
      Process id: 5262 on host XXXXX
      Frame extents: 1, 1, 22, 4

And bingo, the window type was indeed "Utility"!

Trivial issue: The "Utility" window type has one different behaviour, that is, the application window will no longer appear in the taskbar. User can continue to navigate by Alt+Tab keys instead of taskbar.

That behaviour is normal for "Utility" window type, which can be observed the same for the floating windows a.k.a. the docks in GIMP.

If user feels that this behaviour is not desirable, then changing window type could be a solution with drawback. On the other hand, the behaviour is a trivial issue while being able to keep selective windows as opaque when inactive.

Tested working in Xubuntu 14.04 (Xfce 4.10), using Devilspie2 v0.31.

Related Question