I compiled mplayer from source on Ubuntu. I didn\'t want to use a GUI but I wanted to make a executable bash file that gets the path from an file that gets dropped onto the
Try:
#!/bin/bash
mplayer "$1"
The file path of the dropped file will be passed to the script file as the 1th command line argument.
You can access arguments passed to the script with $1
(for the first argument). And also you should make a .desktop
file so Nautilus (or your desktop manager) know what to do and use %u
to pass the dropped path to the script.
For example you can create a file named DropOverMe.desktop
:
[Desktop Entry]
Encoding=UTF-8
Name=Drop Over Me
Comment=Execute the script with the file dropped
Exec=gnome-terminal -e "/folder/to/the/script/launchme.sh \"%u\""
Icon=utilities-terminal
Type=Application
I use gnome-terminal
as I have Ubuntu on my PC, use your preferred terminal application.
And the script could be something like:
#! /bin/bash
echo "Launched with $1" >> /tmp/history.log
By using mate-terminal, gnome-terminal or konsole, you could use drag'n drop into oppened window.
This will send URL as tipped, with a space added, but without endline.
For this, run mplayer, I wrote this little loop function:
while IFS=$' \t\r\n' read -d '' -p "Wait for URL to play: " -rsn 1 str &&
[ "$str" ];do
while IFS= read -d '' -rsn 1 -t .02 char
do str+="$char"
done
if [ "$str" ] ;then
read -a req <<<"$str"
echo $req
mplayer $req
fi
done
read -a req
will split string to consider only 1st part