Using toolbar custom button to run bash script

Ask for help and post your question on how to use XnView MP.

Moderators: helmut, XnTriq, xnview

Post Reply
noldo
Posts: 6
Joined: Wed Dec 30, 2020 9:53 pm

Using toolbar custom button to run bash script

Post by noldo »

Hi,
I am looking for a way to run a bash or python script. The easiest way I come across is creating a custom button. But I am not able to get it working attaching .sh file to the command. Is it somehow possible? I believe that exe and bat files won't work for me as I work on unix(Fedora). Thank you.
User avatar
xnview
Author of XnView
Posts: 46328
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Using toolbar custom button to run bash script

Post by xnview »

are you able to assiociate your button to the script?
Pierre.
noldo
Posts: 6
Joined: Wed Dec 30, 2020 9:53 pm

Re: Using toolbar custom button to run bash script

Post by noldo »

No I am not. After selecting .sh file, marked as executable and working using terminal, it doesn't give me any sort of error message, but it still shows only _cmd_ . This should change when correctly associated with the script, right? Thanks.
User avatar
xnview
Author of XnView
Posts: 46328
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Using toolbar custom button to run bash script

Post by xnview »

no, you 'll see only __cmd__, you can check in your toolbar.ini
Pierre.
noldo
Posts: 6
Joined: Wed Dec 30, 2020 9:53 pm

Re: Using toolbar custom button to run bash script

Post by noldo »

Okey, I am not able to find toolbar.ini, but I found .bar file and it says:
_cmd_=mylabel;/home/user/somepath/test.sh;
It seems that is is associated with the button.

Edit:
Actually, I am not sure how to find out that the script executed. I used echo(prints to stdout) and touch(creates new file). Is there stdin configured? What should be the pwd(path working directory) of the script? Thanks a lot.
noldo
Posts: 6
Joined: Wed Dec 30, 2020 9:53 pm

Re: Using toolbar custom button to run bash script

Post by noldo »

Any help would be appreciated :), thanks a lot.
User avatar
xnview
Author of XnView
Posts: 46328
Joined: Mon Oct 13, 2003 7:31 am
Location: France
Contact:

Re: Using toolbar custom button to run bash script

Post by xnview »

noldo wrote: Fri Jan 08, 2021 7:51 am Any help would be appreciated :), thanks a lot.
it uses the current working folder, so not necessarily the folder of selected file.
Pierre.
noldo
Posts: 6
Joined: Wed Dec 30, 2020 9:53 pm

Re: Using toolbar custom button to run bash script

Post by noldo »

In my case it uses home folder(Fedora linux). I guess that running python script directly is not possible? I am trying to open a new terminal window to allow me further communication with the python script or seeing the result. I am using bash command:
gnome-terminal -e 'sh -c "python3 /path/python_script.py;read"'
This works for me when I run in from terminal, but doesn't work from clicking the button. Do you have any idea why? Thanks.
noldo
Posts: 6
Joined: Wed Dec 30, 2020 9:53 pm

Re: Using toolbar custom button to run bash script

Post by noldo »

Hi, I found out that after updating XnView MP to newest version everything started working. Thanks for help.
Post Reply