Skip to content

Instantly share code, notes, and snippets.

@DomingoMontoya
Created March 10, 2021 21:42
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 DomingoMontoya/9017ebe9b5b5a8a5064970f53614ec22 to your computer and use it in GitHub Desktop.
Save DomingoMontoya/9017ebe9b5b5a8a5064970f53614ec22 to your computer and use it in GitHub Desktop.
Script to have KDE autostart on login to restart compositor on crash (due to removing monitors or suspend/resume)
#!/bin/sh
while true; do
# Check if opengl marked as unsafe, set to safe, and restart kwin
if grep "OpenGLIsUnsafe=true" ~/.config/kwinrc ; then
sed -i "s/OpenGLIsUnsafe=true/OpenGLIsUnsafe=false/g" ~/.config/kwinrc
nohup kwin_x11 --replace &
fi
# Check if compositor is disabled, and enable by invoking shortcut to toggle it
if [ $(qdbus org.kde.KWin /Compositor active) == "false" ] ; then
qdbus org.kde.kglobalaccel /component/kwin invokeShortcut "Suspend Compositing"
fi
sleep 2s
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment