Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 08-21-2005, 07:00 PM   #1
Registered: Jun 2005
Posts: 64

Rep: Reputation: 15
make irfanview default image viewer

I want to click an image in nautilus to have it loaded in Irfanview.
I use Gnome and when I want to open an image in irfanview with wine, I right-click the image in nautilus and choose 'Open with other application' - in 'Use a custom command' I write 'wine /path/to/irfanview.exe'. This will open up irfanview but the image isn't loaded. So I have to open the image from Irfanview - annoying!
If I use command line $ wine /path/to/irfanview.exe IMG_0261.jpg,
it will load the image when Irfanview starts.

I want to make a script so I can just click the image in nautilus, the script is run and the image loaded, but I don't know how. So far I wrote a script called that contains the command line input:

wine /path/to/irfanview.exe

executing $ ./ IMG_2304.JPG
only starts irfanview but not the image. I need to get the image in there somehow.
Help with basic scripting would be greatly appreciated!

Old 08-22-2005, 04:09 PM   #2
Registered: Jul 2004
Location: Palo Alto, CA
Distribution: #! Korora
Posts: 472

Rep: Reputation: 30
I don't know how GNOME works. But in KDE, you
need to change the file association. You would
need to change this in the

control center -> ??? -> file association .

Does GNOME has a control center?

Also, some window managers have their own configurations.
Look around (i.e., tools -> ???, etc)

Old 08-22-2005, 06:16 PM   #3
Registered: Aug 2003
Location: Norway
Distribution: FC4
Posts: 83

Rep: Reputation: 20
Add $@ to your script, like this: wine /path/to/irfanview.exe $@
Old 08-22-2005, 07:40 PM   #4
Registered: Jun 2005
Posts: 64

Original Poster
Rep: Reputation: 15
Thanks your help!
Adding $@ to my script makes it work in command line, but when I click an image in nautilus irfanview is started but no image is loaded. I don't know how nautilus passes the command to the script. If I change the script to just contain the line 'gqview' it will load the image in gqview.
Any more suggestions?
Old 08-23-2005, 03:58 AM   #5
Registered: Aug 2003
Location: Norway
Distribution: FC4
Posts: 83

Rep: Reputation: 20
I forgot you were talking about wine yesterday, obviously IrfanView expects a path in windows form.

Doesn't work:
wine Program\ Files/IrfanView/i_view32.exe "/home/jss/Pictures/2005, June, 13/dscn0349.jpg"
wine Program\ Files/IrfanView/i_view32.exe "Z:/home/jss/Pictures/2005, June, 13/dscn0349.jpg"

wine Program\ Files/IrfanView/i_view32.exe "Z:\\home\\jss\\Pictures\\2005, June, 13\\dscn0349.jpg"

Try this wrapper script.
IRFANVIEW="C:\\Program Files\Irfanview\i_view32.exe"
for arg
	wine "$IRFANVIEW" "${ROOT_DRIVE}$(echo "$arg" | sed 's/\//\\/g')"
Old 08-23-2005, 04:47 PM   #6
Registered: Jun 2005
Posts: 64

Original Poster
Rep: Reputation: 15
I can't believe it. It worked!
Thanks alot dub.wav!

I would like to learn a bit of scripting. What does does the code mean?
Could you recommend a good place to start to learn some basic scripting?
Old 02-10-2008, 12:34 PM   #7
Registered: Aug 2006
Posts: 50

Rep: Reputation: 15
I'd advise [1] for learning about scripting. It is aimed at bash, but there is a lot of similarity between bash and sh I think. And a lot of it applies to any shell. csh is a bit different though...

> #!/bin/sh
This is the program that is used to run this script. All scripts should have a "shebang" line at the top, eg "#!/usr/bin/perl" for perl, something similar for python (not my language) or "#!/bin/bash" for bash.

> IRFANVIEW="C:\\Program Files\Irfanview\i_view32.exe"
These are just setting the variables, which are used later.

> for arg
> do
> ...
> done
For every argument passed to the script (ie things typed after the script name, eg for "$ script file1 file2", the args are file1 and file2)

> wine "$IRFANVIEW" "${ROOT_DRIVE}$(echo "$arg" | sed
> 's/\//\\/g')"
Run wine. Pass it the value of the IRFANVIEW variable (set earlier) for the first argument. For the second argument, concatenate the root drive with $(echo "$arg" | sed 's/\//\\/g').
That bit takes the arguments passed to the script (a file name) and uses "sed" to convert any "/" into a "\".

PS Does Linux have anything similar to Irfan? Though this script sort of does do it...


Last edited by yitzle; 02-10-2008 at 12:37 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
image viewer thinhla Linux - Software 4 07-05-2005 11:24 PM
what about new image viewer ckult Linux - General 1 04-06-2004 07:34 AM
Best image viewer for very large image files? andvaranaut Linux - Software 1 02-21-2004 10:01 AM
how can i make a simple image viewer in JAVA? JIV Programming 2 08-20-2003 05:26 AM
Image Viewer Goll Linux - Software 2 06-24-2003 06:57 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:06 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration