GNOME Lock Screen From Command Line/Bash Script
2
votes
0
answers
577
views
I'm attempting to make a new top bar for my system (Pop OS 22.04) using [polybar](https://github.com/polybar/polybar) . I have it all mostly working, and am attempting to make a power menu. I have the logout, power and restart buttons all working, but am struggling on the lock button.
I have a label with the
-click
action set a bash script. I have confirmed that the script is getting executed as if I have script launch Firefox it does. The problem is that that I have not been able to find a working command. I have tried
-screensaver-command --lock
-screensaver lock
-send --type=method_call --dest=org.gnome.ScreenSaver/org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock
They all work when run in the terminal, but not in a bash script. I think it may have somthing to do with polybar running them as root, so I tried running them as my user, but that did not solve it.
Is there some command that locks the screen of a specified user/desktop environment?
Thanks. Just comment if any more info is needed.
All of the commands mentioned where taken from answers from [this](https://askubuntu.com/questions/7776/how-do-i-lock-the-desktop-screen-via-command-line) question.
Asked by Elijah Crum
(21 rep)
Sep 26, 2024, 12:51 PM
Last activity: Sep 28, 2024, 06:02 PM
Last activity: Sep 28, 2024, 06:02 PM