Hi all,
I know this is probably the wrong place to ask, but I figured if anyone would know, it’ll be you. And according to m e, it is a relatively simple problem.
My challenge:
I’m trying to build a little script for locking my screen, which that is easy enough, and works flawlessly.
The problem I’m running into is running the command
sudo --reset-timestamp
from the script before the screen is locked. I’ve also tried:
sudo --reset-timestamp --non-interactive
…to no avail.
The strange thing is, running the script from the terminal, with:
sudo --reset-timestamp
works fine, but running it with:
sudo --reset-timestamp --non-interactive
does nothing. But it makes kinda sense, though.
The big problem is, whenever I set the script to be run with a keypress shortcut, the
sudo --reset-timestamp
…or
sudo --reset-timestamp --non-interactive
…doesn’t work. Instead, it goes straight to the qdbus
command for locking the screen.
Here is my complete, and simple script up to this point:
#!/usr/bin/env bash
[[ $(sudo --reset-timestamp --non-interactive) ]] && echo "Successfully reset sudo timestamp before locking screen." | systemd-cat --identifier=Mirdarthos --priority=info || echo "Failed to reset sudo timestamp before locking screen." | systemd-cat --identifier=Mirdarthos --priority=err
[[ $(qdbus org.kde.ksmserver /ScreenSaver org.freedesktop.ScreenSaver.Lock) ]] && echo "Successfully locked workstation." | systemd-cat --identifier=Mirdarthos --priority=info || echo "Failed to lock workstation." | systemd-cat --identifier=Mirdarthos --priority=err
I’ve also tried /usr/bin/sudo
instead of just sudo
but it made no difference.
I’ve also set the !requiretty
default for my user:
$ cat /etc/sudoers.d/mirdarthos
[...]
Defaults:mirdarthos timestamp_timeout=-1
Defaults:mirdarthos !requiretty
Does anybody know why this is happening?