Toggle opacity with a keyboard shortcut?

Duncan 1i5t5.duncan at cox.net
Mon May 31 23:31:39 BST 2010


Tassilo Horn posted on Mon, 31 May 2010 21:32:42 +0200 as excerpted:

> I frequently have the situation, that I switch between 2 windows
> hundreds of times, because one overlaps the other and I cannot use
> kwin's tiling feature, cause my resolution is too small.  For example, I
> edit LaTeX code in emacs and after texing, I want to review the
> resulting PDF that is already open in Okular.
> 
> So now, I use the Alt-TAB window switching, but that's not really a good
> solution.
> 
> What I would really like to have is something like this:
> 
>   I press Meta+O and the currently focussed window changes its opacity
>   to 20%.  When I release the key, the opacity changes back to whatever
>   it was before.
> 
> Is that possible?  If the press/release is not feasible, a simple
> toggle, where I would click Meta+O twice would also be ok...

Option 1:

If you're a strong keyboard user that finds switching to the mouse a 
terrible interruption of your processing stream, this might not work for 
you, but it's the single biggest /practical/ usage I've found for window 
transparency here...  This is with focus-follows-mouse window policy, with 
auto-raise turned OFF (click-to-raise) -- that last bit is crucial to 
making this work!  Also, this assumes that the two windows aren't 100% 
overlapped, as both maximized, for instance.  (If resolution is small 
enough that both need maximized, try offsetting the reference window 
slightly, so there's at least a few pixels difference.)

In desktop effects, I have the windows translucency effect enabled, with 
inactive window opacity set to about 85%.  I'd say that's the top of the 
range for making this work, with a range of perhaps 60-85%, with active 
windows set to 100% opacity.  (If your active window opacity is lower, 
you'd presumably want your inactive window opacity lower as well, but a 
lower than 100% active window opacity by default, just doesn't work for 
me.)

My usage case is generally referring to reference documentation or 
application windows, while typing instructions for newsgroup/list/forum/
etc help (like this list).

The setup is the reverse of what might be intuitive.  That is, the window 
that's intended to be the reference window and thus inactive during the 
reference to it, should be set ON TOP.

Now, simply move the mouse to focus (without raising) the window you want 
active.  In doing so, it'll return to 100% opacity, while the window on 
top will deactivate (while remaining on top), thus returning to the 
inactive window opacity setting.

If the settings are correct, this should allow you to see BOTH windows, 
the reference window on top at 70-85% opacity, good enough to use it as a 
reference, with the 100% opacity active window below it obscuring the 
desktop and anything further down the stack, also being viewable enough to 
see what you're typing into it.

The one caveat, however, is that both windows aren't primarily text 
content, or if they are, the fonts used are enough different that they 
don't jumble up too much.  Do note that, for closer checking of the 
reference, it's possible to flick the mouse a bit, thereby temporarily 
activating (and bringing to 100% opacity) the reference window, then flick 
it back, reactivating the typing window.  Thus, it's usually better to 
error slightly on the side of too transparent, than too opaque, since you 
can easily toggle to 100% opacity with a simple flick of the mouse.

Option 2:

Another option, one that might work better for you, is to use kwin's 
dynamic scroll-button opacity adjustment feature.  Configure window 
behavior, window actions, ensure that modifier-key (alt or meta) + mouse-
wheel is set to change opacity.  You can then alt-scroll (or meta-scroll, 
I use meta, aka windows key, as it's intuitive for me that the windows key 
modifier controls windows actions) to near-zero opacity to check what's 
underneath, and back, with little problem.  Of course assuming you have a 
mouse or alternative hardware with a scroller...

Option 3:

Another option would be using the keep-window-above-others feature (which 
has a keyboard shortcut setting available, global shortcuts, kwin) to 
accomplish much the same thing as option 1.  However, this could work 
better if you find switching to the mouse disruptive, as you'd simply 
switch to the reference window, toggle keep-on-top ON, switch to the 
typing window (thereby deactivating the on-top reference window, reducing 
its opacity accordingly), and work, all with the keyboard.

Option 4:

This option should be possible but requires technical knowledge to 
implement.  Use dbus to send opacity-change instructions to kwin, then 
setup a hotkey to invoke said opacity change on the desired window.
I /think/ this should be doable even using shell scripting to call a 
helper app to do the dbus calls, I know it used to be possible in kde3 
with dcop, but I'm not familiar enough with dbus to know what that helper 
app, invokable from the command line, might be.  This one would take some 
research.

Kevin or anyone else here know?

-- 
Duncan - List replies preferred.   No HTML msgs.
"Every nonfree program has a lord, a master --
and if you use the program, he is your master."  Richard Stallman

___________________________________________________
This message is from the kde mailing list.
Account management:  https://mail.kde.org/mailman/listinfo/kde.
Archives: http://lists.kde.org/.
More info: http://www.kde.org/faq.html.




More information about the kde mailing list