Locking screen and turning off screen at same time

Reinstalled plasma to start fresh but forgot to backup that command I had assigned to Meta+L in order to lock the screen and turn it off right after. I’m not using a laptop so I can’t really rely on closing the lid.

After some googling, I found these 2 commands.
To lock the screen: xdg-screensaver lock
To turn off the screen: sleep 1 && xset dpms force off

They both work fine when used individually but I couldn’t make them to work together.

xdg-screensaver lock && sleep 1 && xset dpms force off
If I lock the screen first, the screen never turns off.

sleep 1 && xset dpms force off && xdg-screensaver lock
If I turn off the screen first, the screen comes back on as soon as the lock screen gets activated.

If there’s a different and easier way to do this I’m also all ears :slight_smile:

1 Like

Ahh a simple mistake to make && mean to run the command after the first one has run successfully…
You might have more luck with xdg-screensaver lock & xset dpms force off as & means to not to wait for the first command to finish and move on.

5 Likes

You’re the man!

Can’t believe it was that simple!

Thanks for the help :+1:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.