Can't manually type commands or pass arguments

*** Please report new bugs here! ***

Moderators: XnTriq, helmut, xnview, Dreamer

beepboop
Posts: 5
Joined: Mon Sep 27, 2010 7:53 am

Can't manually type commands or pass arguments

Post by beepboop »

I'm using XNviewMP, most recent version 0.26 for Ubuntu linux.

I want to use qiv (a command line image viewer) to set my wallpaper. I currently use Gthumb and I have a keyboard shortcut associated with this command: "qiv -t -m -x %f". That opens qiv and passes it specific arguments that resize the image and set it as desktop wallpaper.

I would like to to do the same thing in XnviewMP, but I am unable to manually type the command when I select "Open With" and then "Add Program". I can find the executable of the program and it will open in it, but the problem is that to set the image as wallpaper (which is what I want to do) I need to pass arguments to that program.

Is there a way to do that? If not, please allow people to add their own commands instead of requiring they select specific executable files.

I even tried putting the commands in a script and setting "open with" to that file (and yes, I did make it executable) but it wouldn't work.
marsh
XnThusiast
Posts: 2443
Joined: Sun May 15, 2005 6:31 am

Re: Can't manually type commands or pass arguments

Post by marsh »

Have you tried pointing to the script, xnview.sh (as substitute for program)?
beepboop
Posts: 5
Joined: Mon Sep 27, 2010 7:53 am

Re: Can't manually type commands or pass arguments

Post by beepboop »

I must not have made myself clear. I've already run xnview.sh. That script starts XnviewMP. I want to take the picture I'm viewing with XnviewMP and pass it to the program QIV, because qiv can set the picture as wallpaper. Xnview can't set images as wallpaper. Even if it could, I need to set the wallpaper on a system running openbox instead of KDE or Gnome.

I'm asking, how do I set my own commands in the "Open With" and then "Add Programs" menu option? It won't let me enter a command manually, it only lets me select a program, which prevents me from adding the commands that qiv needs to set the image as wallpaper.
beepboop
Posts: 5
Joined: Mon Sep 27, 2010 7:53 am

Re: Can't manually type commands or pass arguments

Post by beepboop »

Ok, someone on another forum helped me out. While it would still be nice to be able to open an image with another program and include arguments after the program from within XnviewMP, here's the workaround:

I created a script file. Just open a text editor and put the following:

#!/bin/bash

qiv -t -m -x $1

The trick was replacing the %f with $1. I don't really understand why that's necessary. I need to learn more about scripting in linux.

Anyway, save that file. I chose to save it as "wallpaper.sh" because it sets the wallpaper and most scripts I've seen end with .sh, but I don't think that matters.

Then I right clicked the file, edited properties, and made it executable.

Then I went into xnviewmp and clicked Tools > Open With > Add Program.

I went to my home/user directory where I saved wallpaper.sh and selected it. Then when I select Wallpaper from "open with" or press Alt+1, it passes the current image to wallpaper.sh, which runs qiv with the modifiers and passes the image to that, which then sets the image as my desktop wallpaper.

FYI, this won't work if you're running a desktop such as KDE or Gnome. I'm using openbox with no desktop manager (therefor no desktop icons).