#!/bin/bash # Manage the locker of session (make this script executable). # Note : `loginctl list-sessions --no-legend | grep -c lightdm` # is my solution to determine when the session is locked ; # it was found by tries and is probably not the better solution # - # Observed : # - unlocked when lightdm is missing in the return of loginctl # - locked when lightdm is present in the return of loginctl # Here the session is unlocked # ... (what to do before locking) # Lock before continue (here the command may vary) light-locker-command --lock # Here the session is locked # ... (what to do after locking) while [ 1 ] ; do is_locked=$( loginctl list-sessions --no-legend \ | grep -c lightdm ) if [[ $is_locked -eq 0 ]] ; then break fi sleep 0.1s done # Here the session is unlocked again # Execute after unlocking # ... (what to do after lockingunlocking) Le Nain Jaune
- 177
- 1
- 12
Le Nain Jaune
- 177
- 1
- 12
better explaining for the impossiblity to use quotes and the value of return for my first attempt
Le Nain Jaune
- 177
- 1
- 12
Le Nain Jaune
- 177
- 1
- 12