#!/bin/bash
# This is an universal script, allowing Firefox as localapp to launch applications to view
# clicked-upon files automatically without having to install these applications
# to the chroot. It calles ltsp-remoteapps remote-open.sh which has to be a script
# for handling any filetype, e.g. gnome-open or gvfs-open.
# the client chroot (ex: /usr/local/bin/remote-app.sh) and requires the server
# to enable remoteapps (lts.conf):
#
#    REMOTE_APPS = True

# Define and create directory
TMP_NEW=~/tmp

if ! [ -d $TMP_NEW ]; then
mkdir $TMP_NEW
fi

# Copy file to new directory
cp "$1" $TMP_NEW

# Extract basename, filename, and extension
BASE=$(basename "$1")

# Build path
FILE="$TMP_NEW"/"$BASE"

# Invoke app on server pointing to path
/usr/bin/ltsp-remoteapps remote-open.sh "$FILE"
