#!/bin/bash

FICHFUNCS="/usr/bin/vx-funcs-bash"
[ -f "${FICHFUNCS}" ] && . "${FICHFUNCS}"

! vx-check_user_root && exit 1

if [ -z "${1}" ] ; then
    if vx-detectar_gui ; then
        RECURSO=$(vx-yad-file-select)
    else
        TEXTO="Indica la ruta del archivo o directorio a abrir como Root: "
        read -p "${TEXTO}" RECURSO
    fi
else
    RECURSO="${1}"
fi

( ! [ -f "${RECURSO}" ] && ! [ -d "${RECURSO}" ] ) && vx-mensaje_y_salir \
  "Abrir como Root" \
  "Debes introducir un fichero o directorio correcto como parámetro ..." "1"

MIMETYPE="$(file -b --mime-type "${RECURSO}")"

xdg-open "${RECURSO}"