Xfce Forum

Sub domains
 

You are not logged in.

#1 2020-10-13 10:04:04

einexperte
Member
From: Hamburg
Registered: 2017-01-06
Posts: 10

Drag and drop to desktop starter - no arguments found

Hello,

I would like to execute some program with a file as an argument by dragging that file on a starter.

Back in the times when I was using windows, it was a common way to start programs. For example I could just drag an image file on "some graphics editing program icon" and the program would open that file.

But I'm having difficulties getting that to work in xfce.

I'm checking for arguments and standard input with a little shell script:

#!/bin/bash

echo 'testdnd.sh'

echo 'First two arguments:'
echo -n '$1: '
echo $1
echo -n '$2: '
echo $2

echo 'Standard Input: '
while read line
do
  echo "$line"
done < "${VAR:-/dev/stdin}"

read

I created a starter for that script:

[Desktop Entry]
Version=1.0
Type=Application
Name=testdnd
Comment=
Exec=/home/christoph/testdnd.sh
Icon=
Path=/home/christoph
Terminal=true
StartupNotify=true
GenericName=testdnd
X-Desktop-File-Install-Version=0.23

When I drag some file from the destop to that starter icon, the mouse cursor changes and displays a plus symbol '+'. That leads me to the conclusion that the drop will be accepted.

When I actually drop the file on the starter, the script executes, but I get no arguments or standard input.

How do I get the filename of the file that was dropped?

Is my expected behaviour supported by xfce?

Thanks,
Christoph

Using xfce 4.12 on Debian buster.


XFCE 4.12 on Debian/Linux (Buster) in German (my translations may be inaccurate)

Offline

#2 2020-10-13 10:48:11

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,996

Re: Drag and drop to desktop starter - no arguments found

The Freedesktop Desktop Entry Specification is located here. Of importance are the "field codes" in the Exec section.

Specifically:

Exec=/home/christoph/testdnd.sh %U

...where %U will hold the dropped file path and name that can be processed via $1 in your script.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#3 2020-10-13 10:55:34

einexperte
Member
From: Hamburg
Registered: 2017-01-06
Posts: 10

Re: Drag and drop to desktop starter - no arguments found

ToZ wrote:
Exec=/home/christoph/testdnd.sh %U

Wow, that was quick and helpful :-)

Thanks so much!


XFCE 4.12 on Debian/Linux (Buster) in German (my translations may be inaccurate)

Offline

Board footer

Powered by FluxBB