[SOLVED] wrapper script for launching unix programs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



just made a script to start gedit and mplayer when doubleclick file in TotalCommander or uTorrent. Handles full and relative paths. Not handles 'name=value' -like arguments

Hope it helps someone

usage example:

Code:
# winemultipath echo a "C:" '.\.java'   d='C:\'
a /home/il/.wine/dosdevices/c:/ /home/il/.wine/dosdevices/z:/home/il/.java d=C:\




winemultipath :

Code:
#!/bin/bash
# wrapper script for launching unix programs from wine
# converts all "C:\foo"-like arguments into valid unix paths
set -- "$@" _end_of_params_
while true; do
  [ "$1" = _end_of_params_ ] && { shift; break; }
  a="$1"
  # -a "${1//\\/}" != "$1"
  if [ ! -f "$1" -a ! -d "$1" ]; then
    b="`winepath -u "$1"`"

    # either the file exists or $1 looks like "C:\foo"
    [ -f "$b" -o -d "$b" -o "${1/#[a-zA-Z]:/}" != "$1" ] && a="$b"
  fi
  set -- "$@" "$a"
  shift
done

#echo "$@" >&2
exec "$@"




sample shell assoc, shell-open.reg :

Code:

REGEDIT4

[HKEY_CLASSES_ROOT\mmediafile\shell\open\command]
@="z:\\usr\\bin\\winemultipath mplayer \"%1\""

[HKEY_CLASSES_ROOT\.flv]
@="mmediafile"
"Content Type"="video/flv"

[HKEY_CLASSES_ROOT\.mp4]
@="mmediafile"
"Content Type"="video/mp4"

[HKEY_CLASSES_ROOT\.avi]
@="mmediafile"
"Content Type"="video/avi"

[HKEY_CLASSES_ROOT\.mkv]
@="mmediafile"
"Content Type"="video/x-matroska"

[HKEY_CLASSES_ROOT\.mp3]
@="mmediafile"
"Content Type"="audio/mp3"

[HKEY_CLASSES_ROOT\.wav]
@="mmediafile"
"Content Type"="audio/wav"

[HKEY_CLASSES_ROOT\.ogg]
@="mmediafile"
"Content Type"="audio/ogg"

[HKEY_CLASSES_ROOT\geditfile\shell\open\command]
@="z:\\usr\\bin\\winemultipath gedit \"%1\""

[HKEY_CLASSES_ROOT\.c]
@="geditfile"
"Content Type"="text/x-csrc"

[HKEY_CLASSES_ROOT\.cpp]
@="geditfile"
"Content Type"="text/x-csrc"









[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux