I did not, but that flag seems to set the behaviour on closing the lid right? I want the computer to remain open so the webcam can record any malicious activity.
In that case, I donāt know if thatās the answer. It might be, and it also might not. As I understand it, you need that to use ālock.targetā. So maybe donāt use it.
Rather look on how to change/modify/customize the lock shortcut/command and run motion that wayā¦
Iāve started out with the grapical-session.target as a requisite, but to my own suprise got:
systemctl enable --now my-lock.service
Unit /etc/systemd/system/my-lock.service is added as a dependency to a non-existent unit lock.target.
Failed to start my-lock.service: Unit graphical-session.target not found.
using the same command with the user flag yields:
systemctl --user enable --now my-lock.service
Failed to enable unit: Unit file my-lock.service does not exist.
So it might need to be set in the .config folder?
In any case I have full acess rights to the machine, so I donāt think Iāll have a problem in having the services in /etc/systemd/system/my-lock.service and not using the user flag.
(Again if anyone as any idea where in the system is the lock command executed, meaning from what file or folder, I would really appreciate it)
ps: I also created a symbolic link to have the AUR service for all users in /etc/systemd/system/, with no effect.
I am! And I tried your code in a custom keyboard hotkey, but I donāt seem to have gnome-screensaver. The locking maybe comes from gdm? I really donāt know. I think this would fix the problem for sure! If I can find it Iāll post the final solution on an edit of the first post.
It would be cool if you could edit standard shortcuts in gnome. That way you could just add the programs you want to run directly before the system defaults. But this is most likely a gnome level thing.
Create own shortcut and name it as you want. Command line ādm-tool lockā, shortcut āSuper + Lā (or what you want).
Maybe you have to install dm-tool with yay
In former times there was a toll called light-locker and a gui tool light-locker-settings to configure. Sadly it does not work any more (for me).
Also, you could see if itās not possible with Gnome Tweak Tool.
I then will set a custom shortcut that runs this program directly (located on /usr/bin).
The problem I have now is that as soon as the screen is locked the camera stops recording (the camera light goes off).
I did not encounter this problem on sway where I set the keybind directly on the sway .config. It worked in a very satisfactory manner.
I donāt know if there is some permission I have to set on gnome to allow the locking program to be able to access the camera. Does anyone have any idea?
Okay so I got a temporary and very breakable solution, but seems to work okay. The problem was the command xdg-screensaver lock exits immediately after locking, as opposed to swaylock.
I had to figure out how to check the locked status somehow and loop on it. And I got this in my lock script:
#!/usr/bin/bash
trap 'kill $PID;exit' EXIT
motion &> /tmp/motion.log &
PID=$!
xdg-screensaver lock
lock=true
dbus-monitor --session "type='signal',interface='org.gnome.ScreenSaver'" | \
(
while $lock; do
read X
if echo $X | grep "member=WakeUpScreen" &> /dev/null; then
echo SCREEN_LOCKED;
lock=true
elif echo $X | grep "member=ActiveChanged" &> /dev/null; then
echo SCREEN_UNLOCKED;
lock=false
fi
done
)
I think this is really a bad looking hack/workaround, since I am not even sure if the dbus-monitor command is the best for this purpose, or if the strings I am grepping on are the ones that make sense, etc., etc.
But it works for now.
ps: I got inspiration for the lock checking mechanism here