Drag-and-drop to script?

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
Bisto

Drag-and-drop to script?

Post 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
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
tigrezno

Re: Drag-and-drop to script?

Post by tigrezno »

Try using quotation marks: "$1" so bash doesn't cut names with spaces into several parameters ($1 $2 $3...)
Bisto

Re: Drag-and-drop to script?

Post 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?
User avatar
Pilosopong Tasyo
Level 6
Level 6
Posts: 1432
Joined: Mon Jun 22, 2009 3:26 am
Location: Philippines

Re: Drag-and-drop to script?

Post 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.
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].
Locked

Return to “Scripts & Bash”