Between Linux and Anime

Kind of like Schrodinger's Cat

Applying Kwin Blur to Transparent Konsole/Yakuake Windows

If you use Konsole or Yakuake with transparency you might have noticed that Kwin’s blur effect, that has been around for awhile and that blurs the background of various transparent elements in the UI (eg panels and plasma popups), does not apply to transparent Konsole or Yakuake windows. This has always irked me a tiny bit, but when I discovered that you can blur transparent terminal windows on OSX, that got me itchy enough to do the token research.

The story is a familiar one: it’s not too hard just to GET WORKING, and patches to do it exist, however getting it to work in a sensible way is non-trivial, and so the patches are rejected and the feature itself is pending future structural changes. Basically, it’s not going to happen on it’s own anytime soon.

Fortunately, there are ways to get it working on your own – and they do not involve applying custom patches and rebuilding anything. Turns out there is a terminal command one can run to immediately apply blur on, for example, current active Konsole windows:

xprop -f _KDE_NET_WM_BLUR_BEHIND_REGION 32c -set _KDE_NET_WM_BLUR_BEHIND_REGION 0 -id `qdbus org.kde.konsole /konsole/MainWindow_1 winId`

And for a currently active Yakuake:

xprop -f _KDE_NET_WM_BLUR_BEHIND_REGION 32c -set _KDE_NET_WM_BLUR_BEHIND_REGION 0 -name Yakuake

Now to do this automatically so that your yakuake and konsole windows are ALWAYS blurred, you can simply add the following lines to your ~/.bashrc:

Spoilered: Old, not so good code Show

Edit: commenters have posted improved versions of the code, thanks commenters! See improved version below:

Spoilered: Code for non-KF5 and old yakuake Show

Edit2: KF5 Konsole and Yakuake 3 onwards requires updated code, as well as xdotool to be installed so we can fetch yakuake’s win id:

konsolex=$(qdbus | grep konsole | cut -f 2 -d\ )
if [ -n "$konsolex" ]; then
for konsole in `xdotool search --class konsole`; do
xprop -f _KDE_NET_WM_BLUR_BEHIND_REGION 32c -set _KDE_NET_WM_BLUR_BEHIND_REGION 0 -id $konsole;
done
fi
if [ `qdbus | grep yakuake` ]; then
xprop -f _KDE_NET_WM_BLUR_BEHIND_REGION 32c -set _KDE_NET_WM_BLUR_BEHIND_REGION 0 -id `xdotool search --class yakuake`;
fi

Of course, this often results in the command being run redundantly, but that doesn’t appear to bring any tangible ill-effects. It all works well enough for a quick hackaround. And the results are delicious indeed.


1316
Rate this post
Thanks!
An error occurred!


  • Facebook
  • Twitter
  • Identi.ca
  • Delicious
  • Digg
  • StumbleUpon
  • Add to favorites
  • RSS
  • Reddit

Previous

Hana no Android Gakuen Specials 3 and 4 English Translated

Next

Kyoukai no Kanata: Balance and Bite

37 Comments

  1. Franco

    Great! It works perfect :D
    I don’t understand why this isn’t by default in kde, it improbes readability when transparency is on.
    P.D.: Sorry my bad English, I’m from Argentina :B

    • Jason "moofang"

      There are people who prefer it to be non-blurred, probably so they can read text in the window behind the konsole. So they’ll need to probably get the blurring to be configurable or somthing, which apparently isn’t easy to do with the current way things are architectured.

      Well, this is an easy enough workaround until they work that out :)

  2. Arthur

    Worked like a charm for a few days, but know blur get disabled each time the windows is redrawed and when I type the xprop command, only new lines are blurred …
    Still investigating

  3. Arthur

    Got it, I was using QtCurve to put transparency everywhere, so I think there was a conflict between konsole part transparency and qtcurve transparency.
    Blacklisting konsole and yakuake in qtcurve > settings > applications > no backgroung opacity for …

    btw your reply seems buggy when you don’t specify a mail adress, the reply is send but I get a “please fill mail” error

    • Jason "moofang"

      Ah, that’s probably part of where the “non-trivial to do in proper/sensible way” thing comes from.

  4. Marcos

    Awesome! Excellent work. It works, but only for the first instance of Konsole. When I open a new one, the blur effect doesn’t apply.

    • Jason "moofang"

      Oh man you’re right. I’m too used to just opening lots of tabs on one konsole window that I never noticed that issue! The problem is that a second Konsole window has a different window Id, so some kind of loop will need to be put into the .bashrc code to cycle through and apply the command to the window ids of all existing Konsole windows.

      Don’t have time at the moment, I’ll look into putting up a fixed version as soon as I can.

  5. Alex

    Great Tip! I too saw it on OSX and was wondering if this would be possible in KDE/Yakuake. I do belong to the people who tend to read text behind the temrinal, but the blurring effect is damn cool. gj & ty !

  6. dbb

    Nice tip, the only downside is that it will only work on one Konsole window (namely, Mainwindow_1).

    Here is a way to make it work for each new opened Konsole or Yakuake, without looping through all of them.
    It makes use of xdotool.

    yakuake=$(xdotool search –name Yakuake | grep $(xdotool getactivewindow))
    konsole=$(xdotool search –name Konsole | grep $(xdotool getactivewindow))
    if [ “$yakuake” != “” ]; then
    xprop -f _KDE_NET_WM_BLUR_BEHIND_REGION 32c -set _KDE_NET_WM_BLUR_BEHIND_REGION 0 -id $yakuake
    fi
    if [ “$konsole” != “” ]; then
    xprop -f _KDE_NET_WM_BLUR_BEHIND_REGION 32c -set _KDE_NET_WM_BLUR_BEHIND_REGION 0 -id $konsole
    fi

    • Lobo

      I’m trying this in openSUSE 13, and it doesn’t work at all. I have xdotool installed.
      But opening konsole, it remains unblured, and prints out” Defaulting to search window name, class, and classname”

  7. Some versions of Ubuntu may display this error with this workaround:


    qdbus: could not find a Qt installation of ''

    To fix it perform the following:


    sudo apt-get install qt5-default qdbus-qt5

    cheers, and thank you very much for this workaround!

  8. Josh Abraham

    I created a slightly more robust script. This will get any Konsole process’s main window. I find that the process name of konsole changes if it autoload and, of course, when there is more than one running.


    #!/bin/bash
    konsolex=$(qdbus | grep konsole | cut -f 2 -d\ )
    if [ -n konsolex ]; then
    for konsole in $konsolex
    do
    xprop -f _KDE_NET_WM_BLUR_BEHIND_REGION 32c -set _KDE_NET_WM_BLUR_BEHIND_REGION 0 -id `qdbus $konsole /konsole/MainWindow_1 winId`;
    done
    fi

    Replace konsole with yakuake and the script will work for yakuake.

    • Lobo

      I’m using this on openSUSE 13. Yours works for the first konsole window, but still does not work for the second.

  9. vincent Barberet

    On my ubuntu, xdotool requires –class instead of -name:

    yakuake=$(xdotool search --class Yakuake | grep $(xdotool getactivewindow))
    konsole=$(xdotool search --class Konsole | grep $(xdotool getactivewindow))
    if [ "$yakuake" != "" ]; then
    xprop -f _KDE_NET_WM_BLUR_BEHIND_REGION 32c -set _KDE_NET_WM_BLUR_BEHIND_REGION 0 -id $yakuake
    fi
    if [ "$konsole" != "" ]; then
    xprop -f _KDE_NET_WM_BLUR_BEHIND_REGION 32c -set _KDE_NET_WM_BLUR_BEHIND_REGION 0 -id $konsole
    fi

  10. Henrik

    Doesnt work well with kf5, getting `Service ‘org.kde.konsole’ is not a valid name.
    usage: xprop [-options …] [[format [dformat]] atom] …` when starting Konsole.

  11. edros

    Hey this solution works very well for me!!, in every new open window and yakuake.

    And you dont need to put the code in the .bashrc, just create a file with the code and make KDE execute in the start.

    Works very nice!! thanks.

  12. Franklin Lisboa

    How can I do this in a Cinammon Environment?

    • Jason "moofang"

      You’ll have to check with the Cinammon guys and see if they have something like this I think. This method only applies if you’re at least using Kwin I believe.

  13. Lobo

    Hi! Thanks for sharing this.

    The code works for the first window, but does not work for subsequent windows. Did you ever figure out how to get it to work with more than just the first?

    Also, how can I get this to work with the Super User Mode terminal? I tried putting the code into /etc/bash.bashrc and it does not apply even to the first window.

    I’m using konsole in openSUSE 13.

    Thanks!

    • Jason "moofang"

      Hi Lobo,

      I recently updated to KF5 on OpenuSUSE 13.2, and it looks like the konsole dbus interface is a little different now. I’ve quickly fixed up the script based on what I’m seeing here. Give the following a try:


      #!/bin/bash
      konsolex=$(qdbus | grep konsole | cut -f 2 -d\ )
      if [ -n konsolex ]; then
      for konsole in $konsolex
      do
      for (( c=1; ; c++ ))
      do
      konsolewindows=$(qdbus org.kde.konsole | grep MainWindow_$c )
      if [ -n "$konsolewindows" ]; then
      xprop -f _KDE_NET_WM_BLUR_BEHIND_REGION 32c -set _KDE_NET_WM_BLUR_BEHIND_REGION 0 -id `qdbus $konsole /konsole/MainWindow_$c winId`;
      else
      break;
      fi
      done
      done
      fi
      if [ `qdbus | grep yakuake` ]; then
      xprop -f _KDE_NET_WM_BLUR_BEHIND_REGION 32c -set _KDE_NET_WM_BLUR_BEHIND_REGION 0 -name Yakuake;
      fi

      If your setup is like mine, then this should fix the “only first window” problem. I haven’t fiddled with the super user mode one. Will look into it when I next have time.

  14. MST

    THX, looks awesome!

  15. Did not grab the window and errored with ‘no org.kde.console’
    Replaced with $konsolex variable set at the beginning.

    orig: konsolewindows=$(qdbus org.kde.konsole | grep MainWindow_$c )
    chg: konsolewindows=$(qdbus $konsolex | grep MainWindow_$c )

  16. I am modified this for my FreeBSD server/desktop:

    i put this script in .cshrc (becouse csh is mine default admin user shell) for autoload:

    #!/usr/local/bin/bash
    konsolex=$(qdbus | grep konsole | cut -f 2 -d\ )
    if [ -n konsolex ]; then
    for konsole in $konsolex
    do
    xprop -f _KDE_NET_WM_BLUR_BEHIND_REGION 32c -set _KDE_NET_WM_BLUR_BEHIND_REGION 0 -id $(xprop -r
    done
    fi

  17. excuse me… no EDIT button here…

    so this is the xript

    konsolex=$(qdbus | grep konsole | cut -f 2 -d\ )
    if [ -n konsolex ]; then
    for konsole in $konsolex
    do
    xprop -f _KDE_NET_WM_BLUR_BEHIND_REGION 32c -set _KDE_NET_WM_BLUR_BEHIND_REGION 0 -id $(xprop -root _NET_ACTIVE_WINDOW | cut -d ‘ ‘ -f 5)
    done
    fi

  18. islam

    Adapted version for Arch Linux + KDE Plasma 5(konsole):
    konsole_windows=$(qdbus org.kde.konsole | grep konsole/MainWindow_ |cut -f 3 -d/ | sort -u)
    for wnd in $konsole_windows
    do
    xprop -f _KDE_NET_WM_BLUR_BEHIND_REGION 32c -set _KDE_NET_WM_BLUR_BEHIND_REGION 0 -id `qdbus org.kde.konsole /konsole/$wnd winId`;
    done

    • islam

      update: i found out that my version is not correct. Here’s correct version.
      IFS=$’\r\n’ GLOBIGNORE=’*’ command eval “konsole_services=($(qdbus | grep org.kde.konsole))”
      for konsole_service in “${konsole_services[@]}”
      do
      IFS=$’\r\n’ GLOBIGNORE=’*’ command eval “konsole_windows=($(qdbus $konsole_service | grep konsole/MainWindow_ |cut -f 3 -d/ | sort -u))”
      for wnd in “${konsole_windows[@]}”
      do
      xprop -f _KDE_NET_WM_BLUR_BEHIND_REGION 32c -set _KDE_NET_WM_BLUR_BEHIND_REGION 0 -id `qdbus $konsole_service /konsole/$wnd winId`;
      done
      done

  19. Lobo Rojo

    I’ve recently upgraded to Linux Maui from Netrunner 17, both running KDE Plasma 5. My version of Yakuake is currently 3.0.2.
    Netrunner 17 had Yakuake v 2.9.9.

    I had been using the following to create transparency blur in Konsole and Yakauke.
    konsolex=$(qdbus | grep konsole | cut -f 2 -d\ )
    if [ -n konsolex ]; then
    for konsole in $konsolex
    do
    for (( c=1; ; c++ ))
    do
    konsolewindows=$(qdbus org.kde.konsole | grep MainWindow_$c )
    if [ -n "$konsolewindows" ]; then
    xprop -f _KDE_NET_WM_BLUR_BEHIND_REGION 32c -set _KDE_NET_WM_BLUR_BEHIND_REGION 0 -id `qdbus $konsole /konsole/MainWindow_$c winId`;
    else
    break;
    fi
    done
    done
    fi
    if [ `qdbus | grep yakuake` ]; then
    xprop -f _KDE_NET_WM_BLUR_BEHIND_REGION 32c -set _KDE_NET_WM_BLUR_BEHIND_REGION 0 -name Yakuake;
    fi

    This is not completely functional anymore. Konsole still blurs, but Yakuake does not. Upon opening, both display the following error:
    xprop: error: No window with name Yakuake exists!

    When I use xprop, I get the following values for the Yakauke window:
    WM_NAME(STRING) =
    _NET_WM_NAME(UTF8_STRING) = "Yakuake"
    ...
    WM_CLASS(STRING) = "yakuake", "yakuake"

    xprop shows basically the same for Konsole, except that WM_NAME(STRING) isn’t blank like it is for Yakuake.

    Any ideas on what’s going on here and how I can fix it?

    Thank you

    • Lobo Rojo

      I remembered I have another computer still running Netrunner 17 and Yakuake 2.9.9.
      On that, xprop shows the WM_NAME(STRING) is not blank for Yakuake.
      Maybe that’s a regression the Yakuake team introduced somehow when they went to version 3+.

    • Ed

      Had this same issue, just figured out a fix, its a bit hacky though and uses xdotool. The idea is to open and keep yakuake open until the script gets its ID (which is relatively quick) , then close it.
      So at the bottom chunk of your code i’d make the changes:
      xdotool key F7 #or whatever you use to open yakuake
      if [ `qdbus | grep yakuake` ]; then
      xdotool key F7 #retract yakuake
      xprop -f _KDE_NET_WM_BLUR_BEHIND_REGION 32c -set _KDE_NET_WM_BLUR_BEHIND_REGION 0 -name Yakuake;
      fi

    • Jason "moofang"

      I’ve edited new code that would work with the new yakuake in the post, take a look! You’ll also need xdotool to be installed.

      • Petross404

        Nice work over there, but can the menus be blurred and transparent too? Again, osx is the example to follow.

  20. Jarl Gjessing

    A workaround for kde version:
    Qt: 5.7.0
    KDE Frameworks: 5.29.0
    kf5-config: 1.0

    xprop -f _KDE_NET_WM_BLUR_BEHIND_REGION 32c -set _KDE_NET_WM_BLUR_BEHIND_REGION 0 -id `qdbus \`qdbus | grep org.kde.konsole\` /konsole/MainWindow_1 winId`

  21. Very useful article – I had to do some digging, as this article recently vanished from mysql.com for some reason. The formatting of this article on your blog is somewhat broken – it would be nice if you could clean this up so it’s legible again. Thanks!

  22. Adeeb

    Please make a blur effect for ubuntu default terminal too.

Leave a Reply to Jason "moofang" Cancel reply

Powered by WordPress & Theme by Anders Norén