3
I wrote a bash script that processes a video file and I'd like to open videos into it without having to navigate to them in terminal.
$ ~/script.sh video.mp4
is how it's run in from terminal.
I've tried opening a video with gnome-terminal -e ~/home/user/script.sh
but it doesn't seem to be capturing the filename/path. I'm using Nemo file manager.
I haven't been able to come up with anything while searching for solutions.
In case it's relevant, this is how I'm passing the filename argument to the script. (likely not the best way)
#!/bin/bash
args=("$@")
in_file=${args[0]}
Update: I've created this .desktop file.
[Desktop Entry]
Comment=
Terminal=true
Name=fixvideo
Exec=/home/user/fixvideo.sh %f
Type=Application
Icon=/usr/share/icons/gnome/48x48/apps/gnome-settings-theme.png
Encoding=UTF-8
If I drop a video file on the desktop icon, it works properly. Using "Open With" in Nemo (or Nautilus) doesn't work, though.
Have you tried %u or %U instead? – Tom Yan – 2016-02-15T12:04:50.190
I tried %u and it also worked. I wasn't sure of the difference between a filename with path and a url so I stuck with %f for filename. I don't think my script would appreciate being thrown multiple urls so I didn't try %U. – leetwanker – 2016-02-16T19:06:23.320
@leetwanker Do you mean with
%u
"Open With" works or is it only the drag and drop too? – Tom Yan – 2016-02-16T21:26:34.007%u and %f seemed to work the same for both as far as I could tell. – leetwanker – 2016-02-18T05:50:43.560
Oh so
Using "Open With" in Nemo (or Nautilus) doesn't work, though.
becauseI had to "Reset to System Defaults" in order to add this to the list of "Recommended Applications" for .mp4 files.
? – Tom Yan – 2016-02-18T08:06:03.000Open with wasn't working initially because I wasn't editing the .desktop file that gnome was using, I was editing the one I'd made on my desktop. Not being able to add the program to the recommended apps list I think was some other sort of problem with Gnome (and only with .mp4's, .mkv's worked fine) which was fixed when I used Reset to System Defaults. It allowed me to do so after that. – leetwanker – 2016-02-19T09:41:49.567