1

I have written a python wrapper for vlc that sits as an appindicator and monitors keystrokes to vlc and loads next/prev files in folder. I have the script working from nautilus scripts. Now I need this script to be the default opening program for video files. How do I have achieve this?
I have already made a .desktop file and put it in
~/.local/share/applications

This is the contents of the desktop file.

[Desktop Entry]
Name=vlcwrapy-nix
Icon=vlc
Type=Application
Exec=/home/thekindlyone/projects/vlcwrapy-nix/vlcwrapy-nix.py

The desktop file shows up on Dash fine.
But in the open with context menu of nautilus of a file, vlcwrapy-nix does not show up.
Please help.
PS: I need my script to get the name of the file that was double clicked as argument.. and the working directory to be the directory the double clicked file is in(just like nautilus-scripts behaves)

1

I'm not sure about getting Nautilus to change it's default open-with program (on Thunar it's in the right-click menu, open with other, change default, but that doesn't really help here)...

I have a bunch of .desktop files in /usr/share/applications/, tried copying your .desktop file into there? Or ~/.local/share/applications/ ?

I also have a file in my home ~/.local/share/applications/defaults.list that has many listings like this:

[Default Applications]
audio/mpeg=vlc.desktop
video/x-theora+ogg=vlc.desktop
application/pdf=evince.desktop

After you get your custom .desktop file into the right place, editing this defaults.list file to use the new .desktop might be the way to go.


OR you could change your /usr/bin/vlc file to be your script (or a link to it) instead of the real vlc? Then you'd probably have to change the script to run the new "real" vlc (renamed to /usr/bin/vlc-real for example. Then anytime anything tries to run vlc they'll run your custom script instead.

  • Nautilus has open with too, but my custom .desktop does not show up there. Other resources on the internet seem to suggest it should. swapping the real vlc with my script is a hack i am not too keen at, will reserve as last ditch attempt. – thekindlyone Dec 14 '14 at 12:59
  • Tried the edit I added, about /usr/share/applications? – Xen2050 Dec 14 '14 at 13:19
  • A local .desktop file always overrules the global one. – Jacob Vlijm Dec 14 '14 at 13:25
  • In this case it would be a new unique .desktop file, but where are the local ones kept? XFCE only has a few under ~/.local for a sendto menu, or in the home for autostart – Xen2050 Dec 14 '14 at 13:29
  • should be in ~/local/share/applications but there are not necessarily many there. – Jacob Vlijm Dec 14 '14 at 13:34
1

OK, Solved it!. The problem was with the desktop file. in the exec line, I had to add a %f for nautilus to show it in open with menu.

Exec=/home/thekindlyone/projects/vlcwrapy-nix/vlcwrapy-nix.py %f

Here is a video demonstration, if anyone is interested.

  • For whatever it's worth, my /usr/share/applications/vlc.desktop file has Exec=/usr/bin/vlc --started-from-file %U – Xen2050 Dec 14 '14 at 17:54
  • I think that is for a list of arguments, like if I select multiple files and then open with vlc. My app makes that pointless as basically all files in the directory are in the wrapper's 'playlist' – thekindlyone Dec 14 '14 at 18:13
  • So you've made a "play whole folder" script. If I were to try that, I'd use Thunar's "Send to" menu since I probably wouldn't use it very often, dropping the .desktop file in ~/home/mint/.local/share/Thunar/sendto/ . Or adding an entry to ~/.config/Thunar/uca.xml should add to the main right-click menu... but it appears Nautilus is a little different than this. – Xen2050 Dec 14 '14 at 18:25
  • My script does more.. it scans the directory every time so newly added files(finished downloads) also get enqueued, allowing me to marathon anime. It also remember the last played file in every directory and loads it with a keystroke. – thekindlyone Dec 14 '14 at 21:29
  • Sounds useful. Similarly (possibly useful) apparently vlc has some sort of LUA addons, one guy was trying to do a similar thing here forum.videolan.org/viewtopic.php?f=7&t=106236#p360372 not sure if he ever did though – Xen2050 Dec 15 '14 at 4:59
0

I use ubuntu tweak to edit file associations:

sudo add-apt-repository ppa:tualatrix/ppa

sudo apt-get update

sudo apt-get install ubuntu-tweak

Let me know if it works for you.

  • I think that is not what OP is looking for. The command to run vlc needs to be redirected. – Jacob Vlijm Dec 14 '14 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.