#!/bin/sh # # Written by Florian Diesch # # Updates may be available at # # # This script is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # You are free to do with it what ever you want. # set -x LNK="$1" CFGFILE=~/.openlnkrc DEFAULT_MOUNTPOINT="$(df -P "$LNK"|awk '{FS="% ";if (FNR==2)print $2}')" file="$(strings -an5 -eS "$LNK"|grep -m1 '^[A-Z]:\\[A-Za-z].*'|sed -e 's|\\|/|g')" if [ -e "$CFGFILE" ]; then while read drive dir; do file="$(echo "$file" | sed -e"s|^$drive|$dir|")" done < "$CFGFILE" fi file="$(echo "$file" | sed -e"s|^[A-Z]:|$DEFAULT_MOUNTPOINT|")" xdg-open "$file"