Skip to content

Instantly share code, notes, and snippets.

@adnan360
Created May 14, 2019 15:53
Show Gist options
  • Save adnan360/8c5b019682a08baa2cfd85ca7aac6992 to your computer and use it in GitHub Desktop.
Save adnan360/8c5b019682a08baa2cfd85ca7aac6992 to your computer and use it in GitHub Desktop.
Restart DE without reboot (good for fixing minor glitches, applying modified settings etc.) for Linux
#!/bin/bash
# Restarts the running DE without rebooting
# Save this file as a .sh file (e.g. restart-de.sh)
# run: chmod +x restart-de.sh
# then to restart DE: ./restart-de.sh
# Supports: LxQt, Openbox, KDE Plasma, GNOME, Mate, JWM, Budgie
xprop_session=$(xprop -id $(xprop -root -notype | awk '$1=="_NET_SUPPORTING_WM_CHECK:"{print $5}') | grep _NET_WM_NAME | awk '{print $3}' | tr -d '"')
if [[ "$DESKTOP_SESSION" =~ "lxqt" ]]; then
killall lxqt-panel && lxqt-panel &
elif [[ "$DESKTOP_SESSION" =~ "openbox" ]]; then
openbox --restart &
elif [[ "$DESKTOP_SESSION" =~ "plasma" ]]; then
kquitapp5 plasmashell && kstart5 plasmashell &
elif [[ "$DESKTOP_SESSION" =~ "gnome" ]]; then
# killall gnome-panel
killall -3 gnome-shell && gnome-shell --replace &
elif [[ "$DESKTOP_SESSION" =~ "mate" ]]; then
mate-panel --replace &
elif [[ "$xprop_session" =~ "JWM" ]]; then
jwm -restart &
elif [[ "$xprop_session" =~ "Mutter(Budgie)" ]]; then
budgie-panel --replace &
else
echo "Error: The DE currently running is not yet supported"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment