LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   bash alltray wine utorrent (https://www.linuxquestions.org/questions/programming-9/bash-alltray-wine-utorrent-642547/)

shinystuffrox 05-16-2008 12:20 AM

bash alltray wine utorrent
 
I found a nifty script online using google that would launch wine utorrent paramater IF a parameter was passed to the bash script
otherwise it would just launch utorrent w/o the parameter. Well, for some odd reason the System Tray Icon for utorrent stopped displaying properly in xfce4 for me so I found a program called alltray.
if you've installed alltray and have done alltray --help then you know the following is how you use alltray

usage: alltray [options] ["] <program_name> [program parameter] ["]

so I changed the script a bit, the old script had

wine /path/to/utorrent.exe "$var"
else
wine /path/to/utorrent.exe &

this worked great, but like I said, fubar'd sys tray requires me to use alltray now.

the problem, I THINK, is my double quotes. the value of $var is not being passed correctly to utorrent. utorrent complains the /path/to/the/dot/torrent/file is not found. and utorrent displays it like so: Z:tmpNAME_OF_TORRENT.torrent

I think it should look like Z:tmp\name_of_torrent.torrent or Z:\tmp\name_of_torrent.torrent

the thing that is weird is I never changed the sed line, if it was parsing it properly before I don't see why it isn't now.

additional information: in winecfg Z: is set to /

so, where have I gone wrong in the following script?

-thanks


#!/bin/sh
if [ "$1" != "" ]; then
var="`echo $1 | sed 's/\//\\\/g'`"
var="Z:${var}"
alltray --icon /home/<user name>/.wine/drive_c/Program\ Files/uTorrent/uTorrent.png "wine /home/<user name>/.wine/drive_c/Program\ Files/uTorrent/uTorrent.exe "$var""
else
alltray --icon /home/<user name>/.wine/drive_c/Program\ Files/uTorrent/uTorrent.png "wine /home/<user name>/.wine/drive_c/Program\ Files/uTorrent/uTorrent.exe &"
fi

itz2000 05-17-2008 02:36 AM

May I ask for, why don't you use native torrent engines such as Azureus?

you wouldn't need wine to run that

BryanFRitt 06-27-2008 10:38 PM

Playing with Scripts
 
This works (can be put in a file /usr/bin/uTorrent with sudo)
#!/bin/sh
cd ~/".wine/drive_c/Program Files/uTorrent/"
if [ "$1" != "" ]; then
var="`echo $1`"
var="${var}"
wine ~/".wine/drive_c/Program Files/uTorrent/uTorrent.exe" "$var"
else
wine ~/".wine/drive_c/Program Files/uTorrent/uTorrent.exe"
fi
---
This one also worked for me:
(putting this in a file /usr/bin/uTorrent with sudo)
#!/bin/sh
cd ~/".wine/drive_c/Program Files/uTorrent/"
if [ "$1" != "" ]; then
var="`echo $1 | sed 's%/%\/%g'`"
var="l:${var}"
wine ~/".wine/drive_c/Program Files/uTorrent/uTorrent.exe" "$var"
else
wine ~/".wine/drive_c/Program Files/uTorrent/uTorrent.exe"
fi
'l' is my '/', change var="l:${var}" or wine, so that '/' and it's drive letter match the letter here, as well as match the paths to uTorrent, etc...
The above code worked for me, while the codes I found for this on the internet didn't
These only work for passing 0 or 1 torrents to uTorrent
Wine will work in both formats(Windows, and Linux) for paths, so the conversion work part from above isn't necessary (and may reduce flexibility?)
the cd ~/".wine/drive_c/Program Files/uTorrent/" is also optional
On my computer uTorrent has a tray icon without doing anything special
--
Test your scripts by playing around with something like:
#!/bin/sh
if [ "$1" != "" ]; then
var="`echo $1 | sed 's%/%\/%g'`"
echo $var
fi
messing with the var= part, until it echoes what you want
-
KUbuntu 8.04_x64, Wine 1.0, uTorrent 1.7.7


All times are GMT -5. The time now is 08:54 AM.