Skip to content

Instantly share code, notes, and snippets.

@AloisJanicek
Last active February 10, 2022 15:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AloisJanicek/f5b3bd07b441cca7be706c82f1d3a12c to your computer and use it in GitHub Desktop.
Save AloisJanicek/f5b3bd07b441cca7be706c82f1d3a12c to your computer and use it in GitHub Desktop.
Toggle Grayscale Effect in Plasma Desktop KWin with adjusted gamma (X11)
#!/bin/bash
# PREREQUISITES
# - KWin Grayscale Effect
# https://store.kde.org/p/1263836/
# install it via System Settings -> Workspace Behavior -> Desktop Effects [Get New Desktop Effects...] and search for "Grayscale Effect"
# OR ALTERNATIVELY
# install it from command line:
# /usr/lib/kf5/kpackagehandlers/knshandler kns://plasmoids.knsrc/api.kde-look.org/1263836
#
# - xgamma command
# part of xorg-xgamma system package on Arch Linux
# If the KWin Grayscale effect is enabled, turn it off and set display gamma to 1.00
if [[ $(qdbus org.kde.KWin /Effects isEffectLoaded "kwin4_effect_grayscale") = true ]]; then
xgamma -gamma 1.00 -q
qdbus org.kde.KWin /Effects toggleEffect "kwin4_effect_grayscale"
else
# otherwise set gamma to 0.90 and enable the effect
xgamma -gamma 0.90 -q
qdbus org.kde.KWin /Effects toggleEffect "kwin4_effect_grayscale"
fi
# OPTIONAL BUT STRONGLY RECOMMENDED
# - place the script somewhere where you can find it, mark it as executable with "chmod +x scriptname.sh"
# - configure global custom shortcut in Plasma pointing to this script
# https://docs.kde.org/trunk5/en/kde-workspace/kcontrol/khotkeys/index.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment