I made a little script to add files/folders in foobar from the Nautilus context menu. You should install the Nautilus-actions extension to add customized entries to the context menu.
I'm sure it's not perfect but it works on my linux (ubuntu) perhaps on yours too
CODE
#!/bin/bash
#foobar2000.sh
# your installation directory
cd ~/.foobar2000/
if [ "$1" != "" ]; then
i="$@"
else
echo "No files"
exit 0
fi
#files
#add extensions if you want
for ext in .aac .mp3 .mp4 .ogg .flac .m4a .wma .mpc .wav .rar .zip; do
files=`echo $i | sed "s/$ext /$ext\" \"z:/g"`
i=$files
done
#folder
files=`echo \"z:$i | sed "s/ \//\" \"z:\//g"`
eval wine foobar2000.exe /add "$files\""
echo "Action: adding Directory or Files \"z:${files}\" to foobar2000"
exit 0
#foobar2000.sh
# your installation directory
cd ~/.foobar2000/
if [ "$1" != "" ]; then
i="$@"
else
echo "No files"
exit 0
fi
#files
#add extensions if you want
for ext in .aac .mp3 .mp4 .ogg .flac .m4a .wma .mpc .wav .rar .zip; do
files=`echo $i | sed "s/$ext /$ext\" \"z:/g"`
i=$files
done
#folder
files=`echo \"z:$i | sed "s/ \//\" \"z:\//g"`
eval wine foobar2000.exe /add "$files\""
echo "Action: adding Directory or Files \"z:${files}\" to foobar2000"
exit 0
Save this script in where you want with the name: foobar2000.sh. and make it executable.
After, create a context menu item using the Nautilus Actions Configuration tool. Click on Add in the Nautilus Action configuration window, and in the Add a New Action dialog box, fill in the field like this:
Label: Send to foobar2000 (or what you want)
Tooltip: Send to foobar2000 (or what you want)
Path: /your/directory/foobar2000.sh
Parameters: %M
Next, click on the Conditions tab.:
Filenames: *
Mimetypes: */*
Check "both"
and check "appears if selection has multiple files or folders"
After, click on the Advanced conditions:
Check "smb (windwos file)"
Finally, click OK and close the Nautilus Actions Configuration tool. Now, when you right-click on a file or folder, you'll see the "Send to foobar2000, and clicking on it will add file and/or folder to foobar2000.
Okay, this is how I do it... shouldn't need any additional scripts, it passes on as many options as you'd like. So "foobar2000 -add file1 file2 directory3 -hide" acts just like "foobar2000.exe /add file1 file2 directory3 /hide" would.
Inspired by plukin's script.
You can add as many custom options as you want, see comment inside second "case" block.
Edit : minor readability change.
CODE
#!/bin/bash
# launches fb2k w/ options
# set path to foobar executable
FB2K="C:\Program Files\foobar2000\foobar2000.exe"
# set Internal Field Separator : character should not appear in filepaths uris or options
IFS='|'
# gives the absolute z: path usable by wine
winepath () {
case "$1" in
/*) # absolute path
file="$1"
;;
~*) # unexpanded home-relative (?)
file="$HOME${1:1}"
# HOME + ~/path, stripping ~
;;
*) # relative path
file="$(pwd)/$1"
;;
esac
file=`echo "z:$file" | sed -e '
s%/[^/]\+/\.\./%/%g # replaces /somedir/../ by /
s%\./%%g # removes ./
s%/%\\\\%g # replace / by \
'`
}
# list of arguments separated by IFS instead of space to prevent string splitting
args=""
# go through all parameters given to script and transform them for wine use if needed
until [ -z "$1" ] ; do
case "$1" in
-h|-help)
echo "Usage : `basename $0` [options] [file1 [file2 [...]]]"
echo "Available switches: -add, -play, -pause, -playpause, -prev, -next, -rand, -stop, -exit, -show, -hide, -config -command:
# launches fb2k w/ options
# set path to foobar executable
FB2K="C:\Program Files\foobar2000\foobar2000.exe"
# set Internal Field Separator : character should not appear in filepaths uris or options
IFS='|'
# gives the absolute z: path usable by wine
winepath () {
case "$1" in
/*) # absolute path
file="$1"
;;
~*) # unexpanded home-relative (?)
file="$HOME${1:1}"
# HOME + ~/path, stripping ~
;;
*) # relative path
file="$(pwd)/$1"
;;
esac
file=`echo "z:$file" | sed -e '
s%/[^/]\+/\.\./%/%g # replaces /somedir/../ by /
s%\./%%g # removes ./
s%/%\\\\%g # replace / by \
'`
}
# list of arguments separated by IFS instead of space to prevent string splitting
args=""
# go through all parameters given to script and transform them for wine use if needed
until [ -z "$1" ] ; do
case "$1" in
-h|-help)
echo "Usage : `basename $0` [options] [file1 [file2 [...]]]"
echo "Available switches: -add, -play, -pause, -playpause, -prev, -next, -rand, -stop, -exit, -show, -hide, -config -command:
Inspired by plukin's script.
You can add as many custom options as you want, see comment inside second "case" block.
Edit : minor readability change.
沒有留言:
張貼留言