[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Looking for a generic drag and drop gui for custom commands



On Tue, 2020-09-08 at 17:15 +0200, Christoph K. wrote:
[...]
> It doesn't work for me. Am I doing something wrong?
> 
> Anyway, this wouldn't be an optimal solution. In some cases I need to
> pass multiple arguments in a specific order. For example an audio and
> video file that should be combined into a single .mp4 file.

It works for me, though I found that multiple files launches multiple
copies of the script, one for each file. To get around that you can use
and explicit %F in the desktop file's Exec command, see [1].

This is what I did to test, including some code to distinguish audio
files from extension. (The 'file' command would probably be best for
testing file type properly, never used this though.)

#------------------------------------------------
~$ cat Desktop/test.desktop 
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Application
Terminal=true
Exec=/home/tixy/test.sh %F
Name=Test launcher
Icon=/home/tixy/test.svg

#------------------------------------------------
~$ cat test.sh
#!/bin/bash

if [ -z "$1" ] || [ -z "$2" ]
then
	echo Expected two files
	sleep 2
	exit 1
fi

audiofile=$1
videofile=$2

if [ "${videofile##*.}" = "mp3" ]
then
	# files in wrong order, swap them
	audiofile=$2
	videofile=$1
fi

echo Audio=$audiofile Video=$videofile

sleep 2

#------------------------------------------------
~$ touch audio.mp3
~$ touch video.avi
~$ ./test.sh video.avi audio.mp3
Audio=audio.mp3 Video=video.avi

#------------------------------------------------

If using the GUI file manager I highlight the audio.mp3 and video.avi
files and drag them onto "Test launcher" then I get a terminal window
open up with the same output as I got above using the commandline.

You don't have to rely on the GUIs default terminal. If you set
"Terminal=false" in the .desktop file you can launch your script how
you want, e.g. I've used something...

Exec=lxterminal --geometry=80x30 -e "sh -c /my/script"

To have my preferred terminal at a preferred size,

[1] https://specifications.freedesktop.org/desktop-entry-spec/latest/ar01s07.html

-- 
Tixy



Reply to: