#!/bin/sh # Get the current Xsession user _user=$(ps -o user= -p $(pgrep -f Xsession)) pkill slock # Run xlock as the Xsession user doas -u $_user env DISPLAY=:0 XAUTHORITY=/home/$_user/.Xauthority slock &