You are not logged in.

#1 2010-10-15 08:59:48

tawan
Member
Registered: 2010-03-02
Posts: 290
Website

Windows cascade in opacity like

I use this in Openbox to give a very nice effect which is great for usability and looks.

The script is by ADComp and here is how your windows look when you use it

sLsHos.jpg

here is the script:

#!/usr/bin/python
# -*- coding: utf-8 -*-

##
#   script that uses transset-df to allow opacity to follow the focused window.
#   The focused window get opacity 1.0 while all others have opacity set by 'OPACITY'
#
#   by ADcomp <david.madbox@gmail.com>  [ http://www.ad-comp.be/ ]
#
#   This program is distributed under the terms of the GNU General Public License
#   For more info see http://www.gnu.org/licenses/gpl.txt
##

import os
import signal
import gobject
import gtk
import wnck
import re

global transset

def SigUSR1Handler(signum, frame):
    global transset
    if transset:
        transset.doquit()

CMD = 'transset-df -i'
## opacity when not active
OPACITY = 0.78
## tempo [ ms ]
TEMPO = 30

exceptions = ['^GNU Image Manipulation Program$','GIMP','VLC','Chromium','Swiftfox','Midori']

class Transset():
    def __init__(self):
        self.screen = wnck.screen_get_default()
        self.screen.force_update()
        self.update()
        self.screen.connect("active_window_changed", self.active_window_changed)

    def update(self):
        win_list = self.screen.get_windows()
        active_ws = self.screen.get_active_workspace()
        active_win = self.screen.get_active_window()

        for window in win_list:
            ## don't check window if skip tasklist
            if not window.is_skip_tasklist():
                tmp = True
                for entries in exceptions:
                    if re.search(entries,window.get_name()) != None: tmp = False
                if tmp:
                    #print window.get_name()
                    ## only window open on active workspace
                    if window.get_workspace() == active_ws:
                        if window == active_win:
                            ## remove transparency
                            cmd = "%s %s 1" % ( CMD, window.get_xid() )
                        else:
                            ## set transparency
                            cmd = "%s %s %s" % ( CMD, window.get_xid(), OPACITY )
                        os.system(cmd)
        return False

    def clean(self):
        win_list = self.screen.get_windows()
        for window in win_list:
            ## don't check window if skip tasklist
            if not window.is_skip_tasklist():
                cmd = "%s %s 1" % ( CMD, window.get_xid() )
                os.system(cmd)

    def active_window_changed(self, screen, window):
        gobject.timeout_add(TEMPO, self.update)

    def doquit(self, widget=None, data=None):
        self.clean()
        gtk.main_quit()

    def run(self):
        gtk.main()

#-------------------------
if __name__ == "__main__":
#-------------------------
    global transset
    transset = None
    signal.signal(signal.SIGUSR1, SigUSR1Handler)
    transset = Transset()
    transset.run()

Automatically as you load a new window, terminal or program the other things on screen fade back one step. Sweet.

Offline

#2 2010-10-15 18:19:57

ctruett
Member
Registered: 2010-05-27
Posts: 28

Re: Windows cascade in opacity like

Thanks! I'll most likely use this! I have been looking for a way to automate transparency, and this should do the trick :]


Supergirl: But fortunately I printed out everything I could find, not just the beginner's guide.
Supergirl: I printed out internet.

Offline

#3 2010-10-16 17:39:41

Alm
Member
Registered: 2010-09-15
Posts: 64

Re: Windows cascade in opacity like

Great! This little thing rocks smile
Thank you tawan!


See, you're unpacking.

Offline

#4 2010-10-16 19:01:10

karabaja4
Member
From: Croatia
Registered: 2008-09-14
Posts: 1,000
Website

Re: Windows cascade in opacity like

Extremely nice, thanks!

Offline

#5 2010-10-23 18:38:45

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: Windows cascade in opacity like

I can't seem to get this working. When I run the script it gives me these errors:

[jente@Lappy .scripts]$ ./inactivetrans.sh
Traceback (most recent call last):
  File "./inactivetrans.sh", line 16, in <module>
    import gobject
ImportError: No module named gobject

Also for import wtk, import wnck and import re.

When I comment those out, it gives me this error:

[jente@Lappy .scripts]$ ./inactivetrans.sh
Traceback (most recent call last):
  File "./inactivetrans.sh", line 91, in <module>
    transset = Transset()
  File "./inactivetrans.sh", line 38, in __init__
    self.screen = wnck.screen_get_default()
NameError: global name 'wnck' is not defined

Am I missing some dependencies? Thanks in advance


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#6 2010-10-23 18:40:57

skunktrader
Member
From: Brisbane, Australia
Registered: 2010-02-14
Posts: 1,543

Re: Windows cascade in opacity like

What happens if you change the first line from

#!/usr/bin/python

to

#!/usr/bin/python2

Offline

#7 2010-10-23 18:43:22

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: Windows cascade in opacity like

That also gives me

ImportError: No module named wnck

Strangely though, it now doesn't show

ImportError: No module named gobject

If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#8 2010-10-23 18:49:22

skunktrader
Member
From: Brisbane, Australia
Registered: 2010-02-14
Posts: 1,543

Re: Windows cascade in opacity like

Do you have the package called "python-wnck" installed?

Offline

#9 2010-10-23 18:53:41

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: Windows cascade in opacity like

I have now. It doesn't throw those errors at me now anymore, it gives me these instead:

sh: transset-df: command not found

EDIT: I do have transset installed.
EDIT2: I changed transset-df to transset -df. The error is gone but my mouse cursor stays on the transset crosshair - had to reboot.

Last edited by Unia (2010-10-23 18:58:51)


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#10 2010-10-23 19:05:16

skunktrader
Member
From: Brisbane, Australia
Registered: 2010-02-14
Posts: 1,543

Re: Windows cascade in opacity like

Try installing the package called "transset-df"

Offline

#11 2010-10-23 19:11:33

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: Windows cascade in opacity like

Thanks, that did the trick.

Last edited by Unia (2010-10-23 19:12:46)


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#12 2010-10-23 22:16:13

tawan
Member
Registered: 2010-03-02
Posts: 290
Website

Re: Windows cascade in opacity like

Sorry I should have raised all of those points in the first post but glad you got it working.

Offline

Board footer

Powered by FluxBB