#!/bin/bash
# Si no recibe argumentos (ruta vacía), salimos para no abrir el HOME
if [ -z "$1" ] || [ "$1" == "{mount_path}" ]; then
    exit 0
fi

# Evitamos ejecuciones múltiples (Lock)
LOCKFILE="/tmp/nemo_mount.lock"
if [ -f "$LOCKFILE" ]; then
    exit 0
fi
touch "$LOCKFILE"

# Abrimos Nemo en la ruta recibida
# Importante: "$1" entre comillas por si hay espacios en el nombre del USB
xdg-open "$1" 2>/dev/null &

sleep 2
rm "$LOCKFILE"