Do have this right for common linux installations of KDE and Gnome?

Another method for gnome.

Code:
xdg-screensaver lock
Code:
               #lock screen
               if [[ "$LockScreenCommand" == '1' ]];then
                    #printf "Desktop:  %s\n" $XDG_CURRENT_DESKTOP
                    if [[ $(wmctrl -m | grep KWin) ]]; then
                         loginctl unlock-session 1
                    fi
                    if [[ $(wmctrl -m | grep GNOME) ]]; then     
                         gnome-screensaver-command --lock
                    fi
               fi