Replaced DESKTOP_SESSION switch with if/else statements because in some desktop environments DESKTOP_SESSION is not set. Also replaced /dev/stderr with &2, these should be the same but /dev/stderr symlink is owned by root and throws errors when used as cron job &2 does not.