You are not logged in.

#1 2005-05-23 01:52:14

Kitsunebi
Member
Registered: 2004-12-31
Posts: 31

Transparency Automation

Okay, here's the situation:

I'm playing around with the Composite extension for X.org (drop-shadows, transparency, and such).  My problem is that I want to automatically set certain programs to be transparent when they start up--in particular:  Eterm.  Now, after much experimentation, I have come up with a solution, but it seems really inefficient and terribly hackish to me. If possible, I would like to see if anyone knows of a better way.

Here is the solution I have come up with:

Since I am using OpenBox, I added the following to menu.xml:

 <item label="Eterm">
   <action name="Execute"><execute>Eterm</execute></action>
   <action name="Execute"><execute>etermscript</execute></action>
 </item>

Where etermscript is:

#!/bin/bash

# Wait until the Eterm we just ran is completely loaded so it gets caught, too

sleep .25

# Get the IDs of all the Eterm windows that are running (really inefficient!)

# NOTE: This is all one line:
IDS=$(xwininfo -root -children -all | grep '("Eterm" "Eterm")' | egrep -o 0x[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]? | sed ':a;N;$!ba;s/n/ /g')

# Make all of those IDs transparent

exec transallid $IDS

and transallid is:

#!/bin/bash

# for each ID, set that window to 75% transparent

while [ "$#" != "0" ]
do
    transset-df .75 -i $1 > /dev/null
    shift
done

(You can get transset-df here)

Even though this works (and better than I expected), I'm sure there's a much, much better way. Is there perhaps some way to directly access the ID of the last window created? Or initialize the window with the opacity property already set? Any thoughts? 

Notes:
$! only gives the ID of the last process, not the last window.

transset-df .75 -n Eterm doesn't work because it stops at the first Eterm it finds (usually the first one run). I tend to use multiple Eterms at once.

(And if anyone wants to see, here's a screenshot.)

Thanks in advance.

Offline

#2 2005-05-23 14:49:26

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Transparency Automation

Hmmm, this is cool... I'm going to move it to the programming forum (you'll probably get more responses there)...

Offline

#3 2005-05-23 16:41:43

Kitsunebi
Member
Registered: 2004-12-31
Posts: 31

Re: Transparency Automation

Okay, thank you.

Offline

#4 2005-05-23 16:51:54

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Transparency Automation

why not make etermscript:

#!/bin/bash

Eterm & pid=$!
sleep .25
transset-df .75 -i $pid > /dev/null
(or transallid $!)

and remove the call to execute Eterm from the OB menu

it seems like your script is setting ALL eterms transparent every time you start 1... if you start Eterm from a script, you're guarenteed to have $! as the pid of the Eterm..

Offline

#5 2005-05-23 16:58:57

Kitsunebi
Member
Registered: 2004-12-31
Posts: 31

Re: Transparency Automation

phrakture wrote:

why not make etermscript:

#!/bin/bash

Eterm & pid=$!
sleep .25
transset-df .75 -i $pid > /dev/null
(or transallid $!)

and remove the call to execute Eterm from the OB menu

As I explained above, $! only gets the ID of the last process.  But this is not usually the ID of the Window, so transset-df -i with that value won't work:

X Error of failed request:  BadWindow (invalid Window parameter)
  Major opcode of failed request:  15 (X_QueryTree)
  Resource id in failed request:  0x18da
  Serial number of failed request:  7
  Current serial number in output stream:  7
phrakture wrote:

it seems like your script is setting ALL eterms transparent every time you start 1

That's why I'm looking for a better way.  There has to be something better than parsing the xwininfo output and setting all Eterms to transparent just to catch the last one opened.

Offline

#6 2005-05-23 17:23:59

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Transparency Automation

Kitsunebi wrote:

As I explained above, $! only gets the ID of the last process.  But this is not usually the ID of the Window, so transset-df -i with that value won't work

ahhh... ok, I didn't get that at first... what you need is a pid <-> window id utility.... dunno... sounds like a hassle...

devil's pie might work in your favor though:
http://www.burtonini.com/blog/computers/devilspie

Offline

#7 2005-05-23 17:31:48

Kitsunebi
Member
Registered: 2004-12-31
Posts: 31

Re: Transparency Automation

Okay, thanks for the link. I'll have to check that out.

Offline

#8 2005-05-23 17:34:59

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Transparency Automation

Kitsunebi wrote:

Okay, thanks for the link. I'll have to check that out.

for the record... the app allows you to perform actions when an app starts...

i.e.
"when firefox starts, maximize it"
"when gkrellm starts, show it on all workspaces"
"when xterm starts, remove decorations"
"when Eterm starts, execute *this* command"

worse comes to worse, I don't know if it'd be that hard to hack transset-df to work with all names... or even to accept a pid (this would require a NETWM compliant WM, otherwise the window props don't store the PID)

Offline

#9 2005-05-23 18:32:01

Vinny
Member
From: the fifth floor
Registered: 2005-04-25
Posts: 29

Re: Transparency Automation

phrakture wrote:

.. what you need is a pid <-> window id utility...

You can get WINDOWID from /proc/$PID/environ
;-)

Offline

#10 2005-05-23 18:36:51

Kitsunebi
Member
Registered: 2004-12-31
Posts: 31

Re: Transparency Automation

Devil's pie worked like a charm with this configuration:

.devilspie.xml:

<?xml version="1.0"?>
<!DOCTYPE devilspie SYSTEM "devilspie.dtd">

<!-- The root element is devilspie -->
<devilspie>

  <!-- Set Eterms to 75% transparent -->
  <flurb name="Eterm opacity">
      <matchers>
          <matcher name="DevilsPieMatcherWindowName">
              <property name="application_name" value="Eterm"/>
          </matcher>
      </matchers>
      <actions>
          <action name="DevilsPieActionOpacity">
              <property name="opacity" value=".75"/>
          </action>
      </actions>
  </flurb>

</devilspie>

Thank you very much for pointing me in that direction, phrakture.

Offline

#11 2005-05-23 18:45:04

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Transparency Automation

Vinny wrote:
phrakture wrote:

.. what you need is a pid <-> window id utility...

You can get WINDOWID from /proc/$PID/environ
;-)

sweet!

Offline

#12 2005-05-23 18:46:16

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Transparency Automation

Kitsunebi wrote:

Devil's pie worked like a charm with this configuration

yeah devil's pie is cool as hell - I used to use it alot when I was using fluxbox...
it does almost everything

Offline

Board footer

Powered by FluxBB