Drag-and-drop to script?

Forum rules
Before you post please read how to get help

Drag-and-drop to script?

Postby Bisto on Wed Mar 19, 2014 8:01 am

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
Bisto
Level 1
Level 1
 
Posts: 26
Joined: Tue Mar 26, 2013 7:41 am

Linux Mint is funded by ads and donations.
 

Re: Drag-and-drop to script?

Postby tigrezno on Wed Mar 19, 2014 6:22 pm

Try using quotation marks: "$1" so bash doesn't cut names with spaces into several parameters ($1 $2 $3...)
tigrezno
Level 1
Level 1
 
Posts: 12
Joined: Sat Mar 08, 2014 1:58 pm

Re: Drag-and-drop to script?

Postby Bisto on Thu Mar 20, 2014 9:00 am

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?
Bisto
Level 1
Level 1
 
Posts: 26
Joined: Tue Mar 26, 2013 7:41 am

Re: Drag-and-drop to script?

Postby Pilosopong Tasyo on Thu Mar 20, 2014 10:31 am

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.
Image
o Give a man a fish and he will eat for a day. Teach him how to fish and he will eat for a lifetime!
o If an issue has been fixed, please edit your first post and add the word [SOLVED].
User avatar
Pilosopong Tasyo
Level 6
Level 6
 
Posts: 1206
Joined: Mon Jun 22, 2009 3:26 am
Location: Philippines


Return to Scripts & Bash

Who is online

Users browsing this forum: No registered users and 3 guests