Skip to main content
remove extra code commands
Source Link
#!/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) 
#!/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 locking) 
#!/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 # ... (what to do after unlocking) 
more details on versions which lead to success
Source Link

I found another solution to achieve it under Debian 12 with XFCE4 DE (v4tested with Debian 11/XFCE4 v4.16 and with Debian 12/XFCE4 v4.18).

The word of end : with Debian 11, I discovered that the --set parameter of xfconf-query must not embed inner quotes in any case nor multiple command (i.e. CMD1 ; CMD2) because the if statement will considers an empty string. In this case to use a script with spaces in its name we can escape them with backslash prepended. This behavior seems different with Debian 12 with XFCE4 DE (v4.18)

I found another solution to achieve it under Debian 12 with XFCE4 DE (v4.18).

The word of end : with Debian 11, I discovered that the --set parameter of xfconf-query must not embed inner quotes in any case nor multiple command (i.e. CMD1 ; CMD2) because the if statement will considers an empty string. In this case to use a script with spaces in its name we can escape them with backslash prepended. This behavior seems different with Debian 12 with XFCE4 DE (v4.18)

I found another solution to achieve it under Debian (tested with Debian 11/XFCE4 v4.16 and with Debian 12/XFCE4 v4.18).

The word of end : with Debian 11, I discovered that the --set parameter of xfconf-query must not embed inner quotes in any case nor multiple command (i.e. CMD1 ; CMD2) because the if statement will considers an empty string. In this case to use a script with spaces in its name we can escape them with backslash prepended. This behavior seems different with Debian 12.

added 6 characters in body
Source Link

The word of end : with Debian 11, I discovered that the --set parameter of xfconf-query must not embed inner quotes in any case nor multiple command (i.e. CMD1 ; CMD2) because the if statement will considers an empty string. In this case to use a script with spaces in its name we can escape them with ''backslash prepended. This behavior seems different with Debian 12 with XFCE4 DE (v4.18)

The word of end : with Debian 11, I discovered that the --set parameter of xfconf-query must not embed inner quotes in any case nor multiple command (i.e. CMD1 ; CMD2) because the if statement will considers an empty string. In this case to use a script with spaces in its name we can escape them with '' prepended. This behavior seems different with Debian 12 with XFCE4 DE (v4.18)

The word of end : with Debian 11, I discovered that the --set parameter of xfconf-query must not embed inner quotes in any case nor multiple command (i.e. CMD1 ; CMD2) because the if statement will considers an empty string. In this case to use a script with spaces in its name we can escape them with backslash prepended. This behavior seems different with Debian 12 with XFCE4 DE (v4.18)

execution of the external script after unlock is not yet relevant
Source Link
Loading
execution of script and not eval for command
Source Link
Loading
different behaviors between debian 11 and debian 12
Source Link
Loading
better explaining for the impossiblity to use quotes and the value of return for my first attempt
Source Link
Loading
note about the xflock4 which will replaced on upgrade
Source Link
Loading
mispelling
Source Link
Loading
test utile en fait
Source Link
Loading
test utile en fait
Source Link
Loading
test inutile
Source Link
Loading
Source Link
Loading