xdg-open-simple
is a minimal fork of the xdg-open
(the default utility of opening files and URLs on many Linux & Unix-like desktop operating systems).
-
Not an attempt to reinvent how
xdg-open
works.Adheres to the same XDG specifications as the original: "Desktop Entry Specification", "Association between MIME types and applications".
-
Some of the
xdg-open
features and behaviors have been REMOVED:-
Auto-forwarding target paths without a known MIME handler to a web browser. (Not in specifications.)
Reasons:
- Obfuscates that there is a missing MIME handler on the system.
- Often just results in creating the target file copies in the browser downloads directory.
-
Handling the
$BROWSER
variable. (Not in specifications.)Reasons:
- A legacy convention of setting the default web browser on some Linux systems.
- Redundant, overlaps with the core functionality of
xdg-open
.
-
Handling any
mimeapps.list
and Desktop file search paths that have been deprecated. (In specifications.) -
Desktop environment specific integrations:
- Auto-forwarding target paths to desktop environment specific file openers. (Not in specifications.)
- Use of
<lowercased DE name>-mimeapps.list
(in specifications),<lowercased DE name>-mimeinfo.cache
(not in specifications).
Reasons:
- Temporal work-arounds and data mappings are needed to identify the desktop environments, due to the lack of desktop environment vendor adherence to, or the lack of the definition in the XDG specifications.
- Not required for providing the core functionality of this tool.
-
Substituting
Name
(%c
) andIcon
(%i
) field codes within theExec
key to pass program icon identifiers and localized program names to the applications. (In specifications.)Reason:
- Unlikely to be in use anymore. Out of the 100 Desktop files on my Linux system, none use these field codes.
-
-
Support of the relative target file paths and URLs has been added.
-
From
xdg-utils
system package substitutes only thexdg-open
, not it's other tools. Retains the original applicablexdg-open
exit codes.
Add this line to some shell initialization script (e.g. $HOME/.profile
for Bash, $HOME/.zshenv
for ZSH):
PATH="$HOME/.local/bin:$PATH"
Run:
mkdir -p "$HOME/.local/opt/" "$HOME/.local/bin"
git clone "https://github.com/andis-sprinkis/xdg-open-simple/" "$HOME/.local/opt/xdg-open-simple"
cd "$HOME/.local/bin"
ln -s "../opt/xdg-open-simple/xdg-open" "xdg-open"
- xdg / xdg-utils · GitLab
- Association between MIME types and applications
- Desktop Entry Specification
- xdg-utils - ArchWiki
Tips for dealing with the Linux file-type vs. application associations. Not specific to this project itself - will work with the stock xdg-utils
too.
$HOME/.config/mimeapps.list
:
[Default Applications]
x-scheme-handler/msteams=Teams.desktop
video/mp4=video.desktop
...
The system .desktop
files are in /usr/share/applications
.
$HOME/.local/share/applications/video.desktop
:
[Desktop Entry]
Type=Application
Name=Video player
Exec=mpv --player-operation-mode=pseudo-gui -- %U
file --brief --dereference --mime-type ./image.jpg
image/jpeg
The URLs get the x-scheme-handler/*
MIME type, with the URL prefix as the suffix.
find /usr/share/mime/ -type f -name '*.xml' | sed -e 's/\/usr\/share\/mime\///g' -e "s/\.xml$//g" | less
application/andrew-inset.xml
application/annodex.xml
application/appinstaller.xml
...
echo > "$HOME/.mozilla/firefox/PROFILE.default-release/handlers.json'
This clears the handlers.json
file, which removes the downloaded file custom handlers configured in Firefox.