#!/usr/bin/fish

# Run hyprlock and spawn fullscreen video windows to be shown behind the lockscreen

set LOCKPROG hyprlock

set video ~/hämtningar/video-screensavers/4k/comp_GMT329_117NC_401C_1037_IRELAND_TO_ASIA_v48_SDR_PS_FINAL_20180725_F0F6300_SDR_4K_HEVC.mov


# check if lock program is running
if ps -e | grep " $LOCKPROG\$"
    echo "$LOCKPROG is already running"
    exit 1
end

# Spawn an mpv instance for each monitor
for workspace in (hyprctl -j monitors | jq '.[] | .activeWorkspace.id')
	# Thi "WORKSPACE n" title is read by hyprland to position the window correctly
	mpv --fs --loop-file=inf --panscan=1.0 --title="WORKSPACE $workspace" $video &
end

$LOCKPROG

for pid in (jobs -p | tail -n +1)
	kill $pid
end
