Repository: esjeon/kwin-forceblur Branch: master Commit: 1f92ed59d4e4 Files: 9 Total size: 12.0 KB Directory structure: gitextract_ohvpcgjx/ ├── .gitignore ├── LICENSE ├── README.md ├── contents/ │ ├── config/ │ │ └── main.xml │ └── ui/ │ ├── config.ui │ └── main.qml ├── install.sh ├── metadata.desktop └── pack.sh ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ forceblur.kwinscript ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) 2019 Eon S. Jeon Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ Force Blur ========== A KWin script to force-enable KWin Blur effect on user-specified windows. ![](image.png) This is more useful than shell script hacks, because KWin script receives event notification and window info from KWin. This can also fix tray-based apps, which loses blur hints when restored from system tray. System Requirement ------------------ * Operating System: - (K)Ubuntu 18.10 or newer - Fedora 29 or newer - Arch Linux - kwin 5.14 or newer * Make sure you're using "Blur" desktop effect, which can be enabled through System Settings. * This script internally calls `xprop` command, which would be already installed on your system. * X11 display server (the script does not support wayland applications) How to Use ---------- 1. Install the script. 2. Run the following in terminal, to enable script configuration: mkdir -p ~/.local/share/kservices5/ cp ~/.local/share/kwin/scripts/forceblur/metadata.desktop ~/.local/share/kservices5/forceblur.desktop 3. Open `Kwin Scripts` page in `System Settings`. 4. Enable `Force Blur` script by checking the checkbox next to it. 5. Change script settings. Note that the script can only match with window classes. 6. Click `OK` to enable the script. 7. Whenever settings are changed, you must disable and re-enable the script. (Uncheck -> `Apply` -> Check -> `Apply`) GTK CSD Shadow -------------- Some GTK applications render client-side shadows, which look ugly if blurred. To prevent this, you can enable "**Blur only the content of window**" option. This works by updating the blur region info whenever a window is resized, so might have some performance impacts. Use with caution. Authors ------- * Eon S. Jeon - main author * Aaron Miller (https://github.com/aaronm-cloudtek) - blacklist mode ================================================ FILE: contents/config/main.xml ================================================ yakuake urxvt keepassxc true false false ================================================ FILE: contents/ui/config.ui ================================================ ForceBlurConfigForm 0 0 400 400 400 350 Form Window Matching <html><head/><body><p><span style=" font-weight:600;">&lt;&lt;Example&gt;&gt;</span></p><p>yakuake</p><p>keepassxc</p><p>urxvt</p></body></html> <html><head/><body><p>Enter window class names, <span style=" text-decoration: underline;">one per line</span>.</p></body></html> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'Fira Sans Book'; font-size:11pt; font-weight:232; font-style:normal;"> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Enter the class names of the windows you want to enable/disable blurring.</p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Class names can be obtained by using <span style=" font-weight:600;">xprop</span> utility in terminal. (xprop WM_CLASS)</p></body></html> Blur only matching Blur all except matching Options <html><head/><body><p>Enabling this option prevents blurring behind the non-content regions of window, like <span style=" font-weight:600;">CSD shadows in GTK</span>.</p><p>This <span style=" text-decoration: underline;">might</span> cause performance issues and flickers, thus users should be careful about turning this on.</p></body></html> Blur only the content of window ================================================ FILE: contents/ui/main.qml ================================================ import QtQuick 2.0 import org.kde.plasma.core 2.0 as PlasmaCore; import org.kde.plasma.components 2.0 as Plasma; import org.kde.kwin 2.0; Item { id: root readonly property var patterns: ( KWin.readConfig("patterns", "yakuake\nurxvt\nkeepassxc") .split("\n") .map(function(rule) { return rule.trim().toLowerCase(); }) ) readonly property var blurMatching: ( KWin.readConfig("blurMatching", true) ) readonly property var blurContent: ( KWin.readConfig("blurContent", false) ) PlasmaCore.DataSource { id: shell engine: 'executable' connectedSources: [] function run(cmd) { shell.connectSource(cmd); } onNewData: { shell.disconnectSource(sourceName); } } function onClientAdded(client) { if (!shell) return; var cls = client.resourceClass.toString().toLowerCase(); var name = client.resourceName.toString().toLowerCase(); var clsMatches = root.patterns.indexOf(cls) >= 0 || root.patterns.indexOf(name) >= 0; if (clsMatches == root.blurMatching) { if (root.blurContent) { registerHintUpdater(client); } else { var wid = "0x" + client.windowId.toString(16); shell.run("xprop -f _KDE_NET_WM_BLUR_BEHIND_REGION 32c -set _KDE_NET_WM_BLUR_BEHIND_REGION 0 -id " + wid); } } } function registerHintUpdater(client) { var prevWidth = client.geometry.width; var prevHeight = client.geometry.height; var handler = function() { try { if (!root) return; } catch(e) { client.geometryChanged.disconnect(handler); throw e; } root.onClientGeometryChanged(client, prevWidth, prevHeight); prevWidth = client.geometry.width; prevHeight = client.geometry.height; } client.geometryChanged.connect(handler); root.onClientGeometryChanged(client, 0, 0); } function onClientGeometryChanged(client, prevWidth, prevHeight) { if (!shell) return; /* Skip if window *size* isn't really changed */ if (client.geometry.width === prevWidth && client.geometry.height === prevHeight) return; var wid = "0x" + client.windowId.toString(16); var region = "0,0," + client.geometry.width + "," + client.geometry.height; var cmd = "xprop -id " + wid + " -f _KDE_NET_WM_BLUR_BEHIND_REGION 32c -set _KDE_NET_WM_BLUR_BEHIND_REGION " + region shell.run(cmd); } Component.onCompleted: { console.log("FORCE-BLUR: starting the script"); console.log(JSON.stringify(root.patterns)); var clients = workspace.clientList(); for (var i = 0; i < clients.length; i++) { root.onClientAdded(clients[i]); } workspace.onClientAdded.connect(root.onClientAdded); } } ================================================ FILE: install.sh ================================================ #!/bin/sh set -euf if [[ ! -f forceblur.kwinscript ]]; then echo "Error: can't find package file: $PWD/forceblur.kwinscript" echo "Please run 'pack' first" exit 1 fi >&2 plasmapkg2 -i forceblur.kwinscript || plasmapkg2 -u forceblur.kwinscript mkdir -pv ~/.local/share/kservices5/ cp -vf metadata.desktop ~/.local/share/kservices5/forceblur.desktop ================================================ FILE: metadata.desktop ================================================ [Desktop Entry] Name=Force Blur Comment=Force-enable Blur effect for certain windows Icon=preferences-system-windows-script-test X-Plasma-API=declarativescript X-Plasma-MainScript=ui/main.qml X-KDE-PluginInfo-Author=Eon S. Jeon X-KDE-PluginInfo-Email=esjeon@hyunmu.am X-KDE-PluginInfo-Name=forceblur X-KDE-PluginInfo-Version=0.6 X-KDE-PluginInfo-License=MIT Type=Service X-KDE-ServiceTypes=KWin/Script X-KDE-ConfigModule=kwin/effects/configs/kcm_kwin4_genericscripted ================================================ FILE: pack.sh ================================================ #!/bin/sh set -eu if ! type zip >&/dev/null; then echo "Error: Can't find 'zip' command." echo " Please install 'zip' command first." exit 1 fi >&2 file=forceblur.kwinscript rm -rvf "$file" exec zip -r9 "$file" \ README.md \ LICENSE \ metadata.desktop \ contents \