#!/bin/bash
# Remove and recreate the named pipe
rm -f /tmp/napp-xdg-open.pipe
mkfifo /tmp/napp-xdg-open.pipe

# Function to handle each URL request
handle_request() {
    local scheme="$1"
    echo "Opening $scheme"
    xdg-open "$scheme"
    # Optional: wait for xdg-open to complete if needed
    # wait $!
}

# Process each scheme read from the pipe
while true; do
    if read -r scheme < /tmp/napp-xdg-open.pipe; then
        handle_request "$scheme" &
    fi
done

