m1gin 255

#ubuntu #defaultapp #fileextension #cli #changedefaultapp #openwith

Get mimetype from file:

  • xdg-mime query filetype /home/user/test.jpg

Check the default program for a mimetype:

  • xdg-mime query default image/jpeg

Set an association:

  • xdg-mime default gpicview.desktop image/jpeg

Example:

  • xdg-mime query filetype /home/bob/Downloads/vid1.avi
  • xdg-mime query default video/x-msvideo
  • xdg-mime default vlc.desktop video/x-msvideo

Check all user mimetypes:

  • scite ~/.local/share/applications/mimeapps.list

Open a file with default app:

  • xdg-open /home/user/test.jpg

 

ask and choose default app (another way... but didn't work well with me):

  • mimeopen -d /home/user/test.png

Reference: https://ubuntuforums.org/showthread.php?t=1910493

m1gin 0

Step 1: Create .desktop file: ~/.local/share/applications/mbpy.desktop

[Desktop Entry]
Name=mbf4t
Exec=python3 '/home/m1/Documents/script/bash/mb/tools/web/chrome_xdgopen.py' %u
Type=Application
NoDisplay=true
Categories=System;
MimeType=x-scheme-handler/mbpy;

Step 2: Update mime database

update-desktop-database ~/.local/share/applications

Step 3: Test if it is working:

xdg-open "mbpy://mbtest::::param1::::param2"

Step 4: To make it work in a website:

< a href="mbpy:mbtest::::param1" > Test < / a>

Test


Add to: