3

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.

0

2 Answers 2

3
+100

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.

3
  • 1
    Thanks, this works pretty well. Arch Linux only has devilspie in its repository, not devilspie2, but it was simple to adapt your guide to devilspie. Setting the window type to utility makes the windows disappear from the alt+tab order too. While I was following your guide, I happened to find the way that I had done this before, using xprop. I managed to get devilspie to send window IDs to xprop, and things seem to be working now. I’ll write up what I did later, and I’ll give you the bounty in a few days. May 6, 2016 at 4:40
  • 1
    @anaranjada By default, Xfwm4 handles the 'skip' properties. Ensure that you have unchecked the option. More details is found under "Prerequisite" in my older answer on Ask Ubuntu.
    – user125388
    May 6, 2016 at 7:08
  • Thanks, I got it working now. I wrote up the other solution that I found in an answer, but I decided that I liked your solution better. May 7, 2016 at 19:48
1

While I was working through clearkimura’s answer, I found the method I had been using before to make windows stay opaque. Enter this command in a terminal, and then click on the window that you want:

xprop -f _NET_WM_WINDOW_OPACITY_LOCKED 32c -set _NET_WM_WINDOW_OPACITY_LOCKED 1

That sets a window property that causes Xfce to leave the window opacity unchanged when the window becomes active.

I ended up doing what clearkimura suggested, but this is another way to automatically keep windows opaque when they’re inactive:

My repository only has devilspie, not devilspie2. I created this devilspie config file and named it ~/.devilspie/rules.ds (comments start with semicolons):

(begin
    ;(debug)
    (if
        ; For mplayer/smplayer and all Gimp windows:
        (or
            (contains (application_name) "MPlayer")
            (contains (window_class) "Gimp")
        )
        ; comment out one of the lines below:
        (print (window_xid) "\n") ; print the window IDs
        ; (wintype "utility") ; set the window type to utility
    )
)

Then I created this script, named it devilspie_xprop, and put it in my home directory:

#!/bin/bash
devilspie $@ | while read id text; do
    if [[ $id -gt 0 && $text == "" ]]; then
        xprop -id $id -f _NET_WM_WINDOW_OPACITY_LOCKED 32c -set _NET_WM_WINDOW_OPACITY_LOCKED 1
    else
        echo "$id $text"
    fi
done

devilspie prints the window ID for any Gimp or MPlayer/SMPlayer windows. The script then runs xprop for each window ID, setting the _NET_WM_WINDOW_OPACITY_LOCKED property.

Finally, I added this to my .xinitrc before launching Xfce:

$HOME/devilspie_xprop &

I ultimately decided that I liked clearkimura’s solution better, but either one works.

1
  • On side note, the xprop command can be used directly to bind with keyboard shortcuts in Xfce. This allows user to trigger opacity on-demand basis that will last for current session. Tested working, like a magic wand!
    – user125388
    May 9, 2016 at 9:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .