Skip to content

Instantly share code, notes, and snippets.

@bodzioslav
Last active July 30, 2022 21:35
Show Gist options
  • Save bodzioslav/a41c807d7a9f6eea6cdfd9550befe6e8 to your computer and use it in GitHub Desktop.
Save bodzioslav/a41c807d7a9f6eea6cdfd9550befe6e8 to your computer and use it in GitHub Desktop.
systemd-sleep kwin hook
#!/bin/bash
#
# Restart kwin on resume after suspend
case "${1}" in
post)
KWIN_PID=$(pidof kwin)
KWIN_X11_PID=$(pidof kwin_x11)
if [ -n "${KWIN_PID}" ] ; then
KWIN_USER=$(ps -o euser= "${KWIN_PID}")
su "${KWIN_USER}" -c "DISPLAY=:0 kwin --replace &"
echo "kwin was successfully restarted after waking up..."
elif [ -n "${KWIN_X11_PID}" ] ; then
KWIN_X11_USER=$(ps -o euser= "${KWIN_X11_PID}")
su "${KWIN_X11_USER}" -c "DISPLAY=:0 kwin_x11 --replace &"
echo "kwin_x11 was successfully restarted after waking up..."
else
echo "kwin/kwin_x11 is not running..."
exit 1
fi
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment