3

I like for example the function you've got per window "above other windows" Is it also somehow possible to set transparency of a window?

J. Doe
  • 595
  • 1
  • 9
  • 25

2 Answers2

10

From the Command Line

Ubuntu 20.04 should ship with a command line tool called transset which provides some useful options for setting the transparency of a window.

In my opinion, the options that work best for quickly changing a window's transparency level are the -p flag (which targets the window under the cursor) and the --inc/--dec flags (which respectively increase and decrease the transparency value by a given amount).

Note that the transparency value is a decimal value between 0 and 1.

To make the window more transparent:

$ transset -p --dec 0.05

To make the window more opaque:

$ transset -p --inc 0.05

Making it better...

You can make it easier to toggle by pairing the aforementioned transset commands with xbindkeys. The following steps will make Alt + MouseWheel UP and Alt + MouseWheel DOWN control the opacity of the window under the cursor.

First, use apt (or apt-get) to install the tool:

$ sudo apt install xbindkeys

Then create and edit the xbindkeys configuration:

$ xbindkeys --defaults > ~/.xbindkeysrc && vi ~/.xbindkeysrc

Add the following lines to ~/.xbindkeysrc:

...

"transset -p --inc 0.05" alt + b:4

"transset -p --dec 0.05" alt + b:5

...

Save and exit the configuration file and reload the xbindkeys configuration with:

$ killall xbindkeys
$ xbindkeys

Now you can use Alt + MouseWheel UP/DOWN to change the transparency of the window under the cursor.

kenorb
  • 10,944
drummerboy
  • 461
  • 5
  • 7
5

There appears to be a non-standardized Extended Window Manager hint named _NET_WM_WINDOW_OPACITY which can be modified with the xprop tool.

xprop -f _NET_WM_WINDOW_OPACITY 32c -set _NET_WM_WINDOW_OPACITY \
  $(printf 0x%x $((0xffffffff * 60 / 100)))
  • where 60, in this case, is the number you want to modify to the desired transparency
  • after executing the command your mouse pointer will turn into crosshairs and you need to click on the specific window you want to change its transparency on.

Making it a desktop shortcut

  • made a script with following content and saved it in ~/bin/xprop_transparency.sh
#!/bin/bash

read -p "Set transparency percentage ? [Enter for 100%]" mydectrans

only accept 10 to 99, rest is considered 100

[[ "$mydectrans" != [1-9][0-9] ]] && mydectrans=100

Convert decimal to 32bit hex representation

my32bhextrans=$(printf 0x%x $((0xffffffff * $((mydectrans)) / 100)))

Execute the action

xprop -f _NET_WM_WINDOW_OPACITY 32c -set _NET_WM_WINDOW_OPACITY $my32bhextrans

  • made a desktop shortcut with following content and save it in ~/.local/share/xpropTransparency.desktop
    • Note: you have to expand ~ to full path , /home/paui in my case
[Desktop Entry]
Name=Set Window Transparency / Opacity
Exec=/home/paui/bin/xprop_transparency.sh
Terminal=true
Type=Application
  • made both files executable chmod u+x ~/bin/xprop_transparency.sh , chmod u+x ~/.local/share/xpropTransparency.desktop

how to check if your WM supports this hint:

Its not clear weather this method should be used to verify if your window manager supports it but you could try the following in a terminal window:

xprop -root _NET_SUPPORTED | grep -o _NET_WM_WINDOW_OPACITY

if it appears in the results, then you can be pretty sure that your window manager supports this. If it doesn't appear, perhaps it works, perhaps not, you'll just have to try and see...

Resources:

Other software perhaps worth exploring