-2

I want to set default a specific program for open ANY files absolutely ANY(*.*), any extension, any mime type. ABSOLUTELY ALL

I build a python program to automated choose the program for any file. the app-chooser.py content:

#!/usr/bin/python
import sys, os, os.path
filename = sys.argv[1];
extension = os.path.splitext(filename)[1];

if extension == "txt":
  os.system("gedit " + filename);

if extension == "mp4":
  os.system("vlc " + filename);

if extension == "html":
  os.system("opera " + filename);

if extension == ".py":
  os.system("python " + filename);

if extension == ".sh":
  os.system("bash " + filename);

if extension == ".exe":
  os.system("wine " + filename);

exit()

The app-chooser.py are compiled in a standalone linux executable, located in "/usr/bin/app-chooser".

1 Answers1

0

You can define a new mimetype for your program:

  1. Create a file e.g. ~/.local/share/mime/packages/application-x-app-chooser.xml with the following content:

    <?xml version="1.0" encoding="UTF-8"?>
    <mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
        <mime-type type="application/x-app-chooser">
            <comment>mime type matching all files with an extension</comment>
            <icon name="application-x-app-chooser"/>
            <glob-deleteall/>
            <glob pattern="*.*"/>
        </mime-type>
    </mime-info>
    
  2. Update the MIME database:

    update-mime-database ~/.local/share/mime
    
  3. Set the .desktop file used to open the matched files:

    xdg-mime default /path/to/file.desktop application-x-app-chooser
    

Using ~/.local/share/mime installs it as a user-specific mime type, replace this path with /usr/share/mime for a system-wide installation.

dessert
  • 40,956