If you are using a Desktop Enviromnet andEnvironment or login manager, (GNOME,KDE,XFCE,LXDE) almost all of them have a lock screen function where you have to type in your password to get back to your programs.
However since that is really simple iI sense your problem is more complex / different.