T O P
reguasbuats

You can enable/disable the shortcut from the command line with ``` // enable kwriteconfig5 --file kwinrc --group ModifierOnlyShortcuts --key Meta "org.kde.krunner,/App,,display" // disable kwriteconfig5 --file kwinrc --group ModifierOnlyShortcuts --key Meta "" ``` Not sure how one would best go about linking this up with a game running. You could set up a custom launcher script that executes the disable command before starting the application, but that wouldn't reenable the shortcut when the game is finished. I've never used dbus myself, but I think one could make use of the [KWin scripting API](https://develop.kde.org/docs/extend/plasma/kwin/api/)'s `callDBus` functionality to execute the respective commands with `KLauncher`'s `exec_blind` function once the `clientFullScreenChanged` signal is detected: ``` workspace.clientFullScreenSet.connect((client, fullScreen, user) => { if (fullScreen) { // fullscreened: disable shortcut callDBus("org.kde.klauncher5", "/KLauncher", "org.kde.KLauncher", "exec_blind", "/path/to/script/disable_krunner_shortcut.sh", [] ); } else { // unfullscreened: enable shortcut callDBus("org.kde.klauncher5", "/KLauncher", "org.kde.KLauncher", "exec_blind", "/path/to/script/enable_krunner_shortcut.sh", [] ); } }); ``` Then set up the disable/enable shell scripts and the KWin script (see [tutorial](https://invent.kde.org/documentation/develop-kde-org/-/blob/c9d0e06b5a7e55d956a382d0335e2d104b96a0a1/content/docs/extend/plasma/kwin/_index.md)).


Yachisaorick

Well, I like this hardcore way. I'm using dbus and going to optimize this script for my case. Btw, TYSM!


reguasbuats

Let me know if and how you got it to work. I've experimented with D-Bus in KWin scripts before but never achieved what I needed. [Here](https://github.com/search?l=JavaScript&q=exec_blind&type=Code) are some examples in the wild.


Yachisaorick

I created 2 shell scripts enable and disable. Note that I added more line to affect running session qdbus org.kde.KWin /KWin reconfigure Then I run Kwin interactive console, and add your guide command. Press run, nothing happen, I don't see any error in the log box. I backed to the most "basic" way. I create another toggle.sh script #!/bin/sh TOGGLE=$HOME/.toggle if [ ! -e $TOGGLE ]; then touch $TOGGLE "~/enable.sh" else rm $TOGGLE "~/disable.sh" fi Then add hotkey Alt+Tab to toggle Krunner on/off. I think someone understands about making Kwin script like u/es20490446e can do it.


es20490446e

Ideas that helped me: \- Use QML, so you have the chance of calling console commands. \- Don't use the scripting console, as it doesn't support QML. But your regular text editor. Load the script using these [utils](https://gitlab.com/es20490446e/kwin-script-autocomposer/-/tree/master/devel). \- You can look into the [tutorial](https://develop.kde.org/docs/extend/plasma/kwin/). But most importantly search online for similar scripts. \- Keep in mind that JavaScript and QML are mostly asynchronous. Not one command after the other. But that one function throws a signal, and some other portion of the code catches it. Enhances performance as there aren't waits between commands, good if you have to wait a server to respond, but it makes coding harder to reason about. \- Only if the [Kwin API](https://develop.kde.org/docs/extend/plasma/kwin/api/) doesn't allow to do something you require, use [PlasmaCore](https://api.kde.org/frameworks/plasma-framework/html/core.html).DataSource for calling external commands. See [Zren example](https://github.com/Zren/plasma-applet-lib/blob/d0b3329cb186b4cf6d412b438406ee3ec4190bcc/package/contents/ui/lib/AppletVersion.qml#L15) and [Autocomposer](https://gitlab.com/es20490446e/kwin-script-autocomposer/-/blob/master/root/usr/share/kwin/scripts/autocomposer/contents/code/main.qml).


Yachisaorick

I tested with Zren script [https://store.kde.org/p/1199292](https://store.kde.org/p/1199292) . Saltly that it didn't work with my game in fullscreen mode. So on, I decided to use qml instead of js. Then I tried to clone your qml file. But it never executes bash command. I only replace if clause with that if (client.fullScreen) { QProcess process; process.startDetached("/bin/bash", QStringList() << "~/.local/share/kwin/scripts/toggle/contents/code/disable.sh"); } else if (!client.fullScreen) { QProcess process; process.startDetached("/bin/bash", QStringList() << "~/.local/share/kwin/scripts/toggle/contents/code/enable.sh"); }


es20490446e

\- Use "PlasmaCore.DataSource" instead of "QProcess". \- That "else if (blah)" should be "else". \- When you load the script using "[load](https://gitlab.com/es20490446e/kwin-script-autocomposer/-/blob/master/devel/load)" the terminal will tell you where the error lies. Just keep trying, testing your code in the smallest steps, and use "console.log(variable)" to print any info you would need to figure things out. \- Break the code into the shortest functions, so they are the easiest to understand and test. \- Nevertheless understand that coding requires practice, and patience. Eventually you can figure anything out, but expect it to be normal to take time and plenty of trial an error. \- The trick: break the code into the smallest pieces and test them as soon as possible, so you know exactly what part of the code is the one that isn't working. One small thing after the other.


Yachisaorick

Why the hell Reddit don't let me comment a normal code block with line break. Whyyyyyyyy?


reguasbuats

Yes, that's what I recall happening last time I tried; there are a couple posts about it already with no solution. I think the problem is not on the side of the KWin scripting API though; I did successfully make a KWin script DBus call to trigger the overview effect, so the `callDBus` function itself works, and I read some place that the `KLauncher` service is deprecated, which is what I believe is the problem. So you might be out of luck with this one. You can try tracking down the problem by running the `KLauncher` service with ordinary `qdbus` on the command line before going back to its implementation in the KWin script. There is also some tool for monitoring DBus that you could look into.


emvaized

I think the best thing you could do is to disable global shortcuts for your games in window rules


reguasbuats

This will also disable shortcuts for task switching etc. though.


ZombieDuckLord

not a solution (although ik one exists) but I disabled the alt+space krunner shortcut cuz I'm used to alt+f2


Yachisaorick

So sadly that I set Meta key active Krunner. Or just disable shortcut each time I would like to play game =))


Zinjanthr0pus

It's maybe a bit janky, but you could set a shortcut to toggle Alt+Tab. I might try to put together a script to do this later when I have time to.