Page 1 of 1

Drag-and-drop to script?

Posted: Wed Mar 19, 2014 8:01 am
by Bisto
Hi all,

I want a script that says "adb sideload $1" so I can drag and drop roms onto the script to sideload to my android without having to type the long-winded names in correctly.
So far I have this:

Code: Select all

#!/bin/bash
#Set environment var for adb to work
export PATH=$PATH:/mnt/userdata/seb/adb:/mnt/userdata/seb/adb/lib:/mnt/userdata/seb/adb/platform-tools
#Sideload command
adb sideload $1
Pretty sure it's a good script (if I manually invoke $1 it outputs correctly) but can't get drag-and-drop to work.
Any ideas? Is this something nemo doesn't support?

I am using lm16 cinnamon 64

Re: Drag-and-drop to script?

Posted: Wed Mar 19, 2014 6:22 pm
by tigrezno
Try using quotation marks: "$1" so bash doesn't cut names with spaces into several parameters ($1 $2 $3...)

Re: Drag-and-drop to script?

Posted: Thu Mar 20, 2014 9:00 am
by Bisto
Thanks for your input, that's a good idea for handling filenames with spaces in.
I still get no drag and drop though :(

I'm thinking it's something to do with nemo as it's obviously not being called to run with what I'm dropping as "$1". It doesn't even try to run the script as far as I can tell.

I've also tried making a link to the script and using that to drag and drop. No joy that way either. Surely there's a way? Anyone?

Re: Drag-and-drop to script?

Posted: Thu Mar 20, 2014 10:31 am
by Pilosopong Tasyo
Bisto wrote:I've also tried making a link to the script and using that to drag and drop. No joy that way either. Surely there's a way? Anyone?
Yup there is. What you need to do is create an application launcher (AKA a .desktop file) that calls your script. Then you can drag-and-drop your ROMs over the launcher. For example:

/home/administrator/my-scripts/drag-and-drop.bash

Code: Select all

#! /bin/bash
notify-send "Content of parameter is..." "$1"
/home/administrator/Desktop/Drag-N-Drop.desktop

Code: Select all

[Desktop Entry]
Type=Application
Name=Drag-N-Drop
Exec=/home/administrator/my-scripts/drag-and-drop.bash %F
Both .bash and .desktop files have their execute bit set. So, when a file is dropped over the launcher, it calls the shell script passing the path and file name to it, which in turn displays an on-screen notification:

Image

Resources for .desktop files: click here.

HTH.