September 8, 2011 2 Comments
KWin’s Desktop Effects work well and I usually have them enabled, only disabling compositing temporarily while I play a game (I’m a sucker for old arcade games running in GMAMEUI).
One way to enable/disable compositing in KWin 4.7.0 is via System Settings > Desktop Effects > tick/untick ‘Enable desktop effects at startup’ > Apply. This change only takes effect when you restart KDE. A way to toggle compositing on/off is to use a keyboard shortcut. The default keyboard shortcut for this in KWin is Alt-Shift-F12, but KDE on my machine tells me that Qt does not like the use of the Alt key in this shortcut, so I used System Settings > Desktop Effects to change the shortcut to Ctrl+Shift+U, which does toggle compositing on/off.
A toggle icon on the Desktop is another way of achieving the same thing, and is handy if you are using your mouse at the time. Now, a Plasma widget called Toggle-Compositing exists and is a nice way of enabling/disabling compositing at the click of a mouse. However, it has to be compiled — which some users may feel reluctant to do — and it requires the user to know the
$KDEDIR, and I’ll wager some users don’t.
Below I describe one way of adding an icon to your Desktop that you can use to toggle compositing in KWin and that does not require any compiling, so it should be more straightforward to implement by a newcomer to KDE.
Use your preferred text editor to create the following Desktop Configuration File named
toggle_compositing_in_KWin in your Desktop directory:
[Desktop Entry] Comment[en_GB]=toggles compositing in KWin Comment=toggles compositing in KWin Exec=sh /home/fitzcarraldo/toggle_compositing_in_KWin.sh GenericName[en_GB]=toggles compositing in KWin GenericName=toggles compositing in KWin Icon=kwin MimeType= Name[en_GB]=toggle_compositing_in_KWin Name=toggle_compositing_in_KWin Path= StartupNotify=true Terminal=true TerminalOptions= Type=Application X-DBUS-ServiceName= X-DBUS-StartupType=none X-KDE-SubstituteUID=false X-KDE-Username=
(Replace “fitzcarraldo” with your user name, of course.)
Then create a text file
~/toggle_compositing_in_KWin.sh containing the following:
#!/bin/bash echo -n "Current compositing state: " qdbus org.kde.kwin /KWin compositingActive echo -n "Changing compositing state..." qdbus org.kde.kwin /KWin toggleCompositing echo -n "Current compositing state: " qdbus org.kde.kwin /KWin compositingActive echo -n "All done. Press ENTER to close window: " read ENTRY
Finally, open a Konsole window and enter the following command under your own user account:
And there you have it. You’ll have an icon on your Desktop that looks something like the following:
All you need to do is double-click (or single-click, if you have configured KDE that way) on the icon toggle_compositing_in_KWin on your Desktop and a window will pop-up telling you:
To re-enable compositing, just double-click the icon again. And so on.
And now the final touch…
Actually, it’s not necessary to include the last two lines:
echo -n "All done. Press ENTER to close window: " read ENTRY
in the Bash script above; I just put them in to display the current compositing state. If you omit those two lines then toggling compositing on and off simply becomes a double-click on the icon on the Desktop (or a single click if you have configured KDE that way). In fact, if you also change
StartupNotify=false in the Desktop Configuration File, then you won’t even see a Konsole window pop-up briefly: compositing will just be toggled on and off seamlessly, so to speak. Just like the keyboard shortcut, only easier to remember!