You are not logged in.

#1 2019-01-09 22:31:15

chrjen
Member
Registered: 2019-01-09
Posts: 5

Tint windows with compton

I currently am running i3 as my wm with compton as a compositor. I noticed this piece on the arch wiki about compton.

opacity-rule = [
  "90:class_g = 'URxvt' && focused",
  "60:class_g = 'URxvt' && !focused"
];

It adjustes the opacity based on whether the window currently is focused or not. However I think I would prefer if it tinted the window instead. Not sure if compton actually supports tinting windows, couldn't find anything. Also would be nice if the effect only lasted while actually switching windows, only to turn back a few seconds later.

Anyone have any ideas?

Last edited by chrjen (2019-01-09 22:48:09)

Offline

#2 2019-01-09 23:41:05

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,796

Re: Tint windows with compton

fwwi, urxvt in particular can tint itself, "urxvt -fade 50 -fadecolor '#666666'"
Compton supports "inactive-dim" - see the wiki you linked.

Offline

#3 2019-01-09 23:53:06

chrjen
Member
Registered: 2019-01-09
Posts: 5

Re: Tint windows with compton

Yes «inactive-dim» is what I was looking for it seems, thank you. Really helps with seeing which
window I am currently focusing when switching using the keyboard. Also I don't use URxvt, I just
copy-pasted the example from the wiki, but thanks again.

Though would be even more amazing if it was only like that when actually switching between
windows, as mentioned above. wink

Offline

#4 2019-01-10 08:03:41

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,796

Re: Tint windows with compton

I'm frankly not sure how you vision that - do you want an effect on the focused or the focus loosing window (and why)?

Offline

#5 2019-01-10 09:10:48

chrjen
Member
Registered: 2019-01-09
Posts: 5

Re: Tint windows with compton

I want the effect when switching between windows because it's not always
easy to tell which window I am currently focusing. It would be extra nice
if it only lasted while switching.

Create a simple mock-up for you using video editing magic.

Offline

#6 2019-01-10 15:38:29

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,796

Re: Tint windows with compton

#!/bin/bash
last_act=0
while read dummy dummy dummy dummy act_win; do
    ((act_win == 0 || act_win == last_act)) && continue
    last_act=$act_win
    echo "Active: $act_win"
    while read wid dummy; do
        (( $wid != $act_win )) && xprop -id $wid -f _NET_WM_WINDOW_OPACITY 32c -set _NET_WM_WINDOW_OPACITY 2147483645
    done < <(wmctrl -l)
    sleep 0.25
    while read wid dummy; do
        (( $wid != $act_win )) && xprop -id $wid -f _NET_WM_WINDOW_OPACITY 32c -set _NET_WM_WINDOW_OPACITY 4294967295
    done < <(wmctrl -l)
done < <(xprop -root -spy _NET_ACTIVE_WINDOW)

You'll need xprop and wmctrl, the script is full of bashisms, so keep the shebang. Also be aware that the WM *might* interfere (dunno for i3wm) by setting the active transparency itself.

Offline

#7 2019-01-10 16:24:14

chrjen
Member
Registered: 2019-01-09
Posts: 5

Re: Tint windows with compton

Well it kinda works, though not quite. For one it uses opacity which doesn't
do much for me since most of my windows are already translucent, but more
importantly it handles every event with the delay. So if I toggle between two
windows really fast, faster than 0.25 seconds, your scripts starts lagging behind
and you just end up with flicker as it tries to catch up. It only gets worse the
bigger the delay is.

Offline

#8 2019-01-10 16:31:33

Ropid
Member
Registered: 2015-03-09
Posts: 1,069

Re: Tint windows with compton

Play around with the numbers used in the script. There's that "sleep 0.25" in the middle for the delay, try something else.

And those confusingly looking decimal numbers you see can also be written like this in bash:

2147483645  -->  $(( 0x7ffffffd ))
4294967295  -->  $(( 0xffffffff ))

To change opacity you can tweak that "7f" in the front, and the color is that "ff ff fd" part.

Offline

#9 2019-01-10 16:42:49

chrjen
Member
Registered: 2019-01-09
Posts: 5

Re: Tint windows with compton

Hi Ropid,

I already tried messing with the sleep, it's what I meant by delay. However
increasing it only exacerbates the issue I mentioned. Also I tried messing
with the colours as you suggested, but they didn't do anything sadly.

Offline

#10 2019-01-10 21:42:22

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,796

Re: Tint windows with compton

It's possible to fork the inner loop and kill the running one (covering for fast switches in a row), but tinting is a no-starter: the property (introduced by xcompmgr and supported by pretty much all compositors) only controls the opactiy (as the name kinda gives away) - there's no color component, it's just a 32bit integer.
You could probably maintain original opacities, if that's your concern.

And of course you could patch compton - no idea whether such feature would be accepted upstream.

Offline

Board footer

Powered by FluxBB