I configured AutoLogin on my Linux Mint Mate system because I am using it as a small home server for file sharing, etc. And some app don't work well if the user is not logged in. But I don't want the system to be unprotected, someone can access it if it logins automatically. So how to AutoLock immediately after AutoLogin ?


Answering my own question:

I was trying some commands on startup like: mate-screensaver-command -l

but it was not working as mate-screensaver could not be running yet

So I tried:

sleep 1
mate-screensaver-command -l

but with no success either, so I discovered that the problem was that on starting the mate-screensaver, it was not returning until the process ended, and it would not happen.

So the final solution is to make a file like this:

sleep 1
/usr/bin/mate-screensaver-command -l
sleep 2
/usr/bin/mate-screensaver-command -l
sleep 3
/usr/bin/mate-screensaver-command -l
sleep 4
/usr/bin/mate-screensaver-command -l

I made the command 4 times just to be absolutely sure that it is going to lock because the command may fail if screensaver has not successfully started. There could be a more professional approach like checking if it has locked with mate-screensaver-command --query.

after saving the file, make it executable on its properties or chmod and put it on startup, (just type start on mate menu to find it), then disable the mate-screensaver entry on the startup apps as you are already starting it on this script.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.