What is needed:
Hello guys. I found it nessecary to have an icon on my desktop for Irfanview, which I could drag pictures onto and have them load. Or simply double-click on a picture, and have it load in IrfanView.
This is a problem with any Windows app, but today Matthew we will be using IrfanView.
Why it cant normally be done
The problem is that Irfanview is a Windows program, and you can't pass linux filepaths to Windows programs unless you convert them with winepath.
The end result
The end result after this HOWTO, is a icon on the desktop which launches Irfanview(in wine) when clicked, and I can also drag files onto it. Also, I have .gif files associated with Irfanview.
How to do it
This is done by having a quick script which accepts normal linux filepath arguments, and creates a SH script on the fly to convert it to a Windows-friendly path and launch IrfanView With it.
You then simply put a launcher to it on your desktop. And you can even register filetypes to open with the script.
So here is the script. Save it where ever. In this example it is ~/irfanview.sh:
Code:
#!/bin/sh
# This is a script to allow a launcher to open Irfanview with a file dragged onto it.
# It uses winepath -w to convert the file's path to the Windows version, and then
# creates a simple sh script to launch wine/irfanview/document with the correct syntax.
# Note: Yes I know the constructed shell script doesnt have #!/bin/sh at the beginning.
# Im not that good, and hey it works. So shoosh
#
#
# By Weblordpepe. Oct 3, 2007. 5:10am.
# (Finished: Oct 6, 2007. 11:25pm)
# Report to console the file wanted, clear temporary files.
rm -f ~/.wine/iprog3 ~/.wine/iprog2 ~/.wine/iprog
# Display to user whats going on
echo ---
echo Loading $1- into Irfanview.
echo Make Pepe a SANDWICH!
echo ---
# Begin command line making:
# Output (to text file) the command to launch Irfanview under Wine.
echo -n wine /usr/local/IrfanView/i_view32.exe\ >> ~/.wine/iprog
# Output Windows version of the file path to the same text file.
echo -n "\\042" >> ~/.wine/iprog # First doublequotes
winepath -w "$1" |tr 'h:' 'H:' | tr 'z:' 'Z:' >> ~/.wine/iprog # Replace lowercase driveletter to uppercase and output to file.
echo -n "\\042" >> ~/.wine/iprog # Second doublequotes
# Create new textfile but delete all 'new lines's so its all on one line.
less ~/.wine/iprog | tr -d '\n' >> ~/.wine/iprog2
# End of command file making
# Run the file text file which includes instruction to run Irfanview under wine with
# the Windows filepath on the end.
sh ~/.wine/iprog2
# clean up
rm -f ~/.wine/iprog3 ~/.wine/iprog2 ~/.wine/iprog
Now what you want to do is create a launcher on the desktop. I've only done this with Gnome. So KDE guys try it out & lemme know.
Create a launcher (type: application) on the desktop, and call it anything you like. The command should be gksu -u dork /home/dork/irfanview.sh where dork is your username. I think there's also a variable you can use.
There you have it. An icon you can drop files onto and have them loaded with Irfanview, or another Windows app.
To associate files, just right click any file, go to Properties, then 'Open With' and create a new entry. Select 'custom command' and put in sh /home/dork/irfanview.sh or wherever you've put the file.
And thats it. Filetypes opening with a windows application. No doubt there's a much easier way that I'm not aware of. But eh, it works so I'm happy.
Bookmarks