So in Cosmic the process is now gnome-session-binary which is greater than 15 characters and per the pgrep man page:
"The process name used for matching is limited to the 15 characters present in the output of /proc/pid/stat. Use the -f option to match against the complete command line, /proc/pid/cmdline."
So this needs to be updated to the new binary name and the match should be switched from -x to -f so the code is clear about that which we are searching for.
So in Cosmic the process is now gnome-session- binary which is greater than 15 characters and per the pgrep man page:
"The process name used for matching is limited to the 15 characters present in the output of /proc/pid/stat. Use the -f option to match against the complete command line, /proc/pid/cmdline."
So this needs to be updated to the new binary name and the match should be switched from -x to -f so the code is clear about that which we are searching for.