It looks like these scripts are identical other than the service restart command at the end of the script. If that's the case, shouldn't it be possible to simply detect the display manager and consolidate these two scripts into a single one?
eg:
DISPLAY_MANAGER = $(tail /etc/X11/default-display-manager);
if [[ $DISPLAY_MANAGER = *"gdm"* ]]; then
service gdm restart;
elif [[ $DISPLAY_MANAGER = *"lightdm"* ]]; then
service lightdm restart;
else
echo "Unknown display manager."
fi
It looks like these scripts are identical other than the
service restartcommand at the end of the script. If that's the case, shouldn't it be possible to simply detect the display manager and consolidate these two scripts into a single one?eg: