updated xdg-open
This commit is contained in:
@@ -1,3 +1,117 @@
|
|||||||
|
Certainly! Here's a comprehensive guide on xdg-open and ~/.config/mimeapps.list:
|
||||||
|
|
||||||
|
## xdg-open
|
||||||
|
|
||||||
|
`xdg-open` is a command-line utility that is part of the `xdg-utils` package. It is used to open files or URLs using the default application associated with the file type or URL scheme. `xdg-open` follows the XDG (X Desktop Group) specifications for interoperability between applications.
|
||||||
|
|
||||||
|
### Usage
|
||||||
|
|
||||||
|
To open a file or URL using `xdg-open`, simply provide the file path or URL as an argument:
|
||||||
|
|
||||||
|
```
|
||||||
|
xdg-open [file|URL]
|
||||||
|
```
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
- Open a file: `xdg-open document.pdf`
|
||||||
|
- Open a URL: `xdg-open https://www.example.com`
|
||||||
|
|
||||||
|
`xdg-open` determines the default application to use based on the MIME type of the file or the URL scheme. It looks for associations defined in the `~/.config/mimeapps.list` file and falls back to system-wide associations if not found.
|
||||||
|
|
||||||
|
### Advanced Options
|
||||||
|
|
||||||
|
- `--help`: Display help information and usage instructions.
|
||||||
|
- `--manual`: Display the manual page for `xdg-open`.
|
||||||
|
- `--version`: Print the version information of `xdg-open`.
|
||||||
|
- `--mime-type MIME/TYPE`: Explicitly specify the MIME type to use for opening the file.
|
||||||
|
- `--app APPLICATION`: Specify the application to use for opening the file or URL.
|
||||||
|
|
||||||
|
## ~/.config/mimeapps.list
|
||||||
|
|
||||||
|
The `~/.config/mimeapps.list` file is a user-specific configuration file that defines associations between MIME types and default applications. It allows you to customize the default applications used for opening different types of files and URLs.
|
||||||
|
|
||||||
|
### File Structure
|
||||||
|
|
||||||
|
The `mimeapps.list` file consists of three main sections:
|
||||||
|
|
||||||
|
1. `[Default Applications]`: Specifies the default applications for each MIME type or URL scheme.
|
||||||
|
2. `[Added Associations]`: Lists additional associations for MIME types, allowing multiple applications to be associated with a single MIME type.
|
||||||
|
3. `[Removed Associations]`: Specifies associations that should be removed or overridden.
|
||||||
|
|
||||||
|
### Syntax
|
||||||
|
|
||||||
|
The syntax for each section in the `mimeapps.list` file is as follows:
|
||||||
|
|
||||||
|
```
|
||||||
|
[Default Applications]
|
||||||
|
mime/type=application.desktop
|
||||||
|
x-scheme-handler/scheme=application.desktop
|
||||||
|
|
||||||
|
[Added Associations]
|
||||||
|
mime/type=application1.desktop;application2.desktop;
|
||||||
|
|
||||||
|
[Removed Associations]
|
||||||
|
mime/type=application.desktop
|
||||||
|
```
|
||||||
|
|
||||||
|
- `mime/type` represents the MIME type of the file, such as `text/plain` or `image/jpeg`.
|
||||||
|
- `x-scheme-handler/scheme` represents the URL scheme, such as `http` or `file`.
|
||||||
|
- `application.desktop` refers to the desktop file of the application, typically located in `/usr/share/applications` or `~/.local/share/applications`.
|
||||||
|
|
||||||
|
### Setting Default Applications
|
||||||
|
|
||||||
|
To set a default application for a MIME type or URL scheme, add an entry in the `[Default Applications]` section:
|
||||||
|
|
||||||
|
```
|
||||||
|
[Default Applications]
|
||||||
|
text/html=google-chrome.desktop
|
||||||
|
video/mp4=vlc.desktop
|
||||||
|
```
|
||||||
|
|
||||||
|
In this example, Google Chrome is set as the default application for opening HTML files, and VLC is set as the default video player for MP4 files.
|
||||||
|
|
||||||
|
### Adding Multiple Associations
|
||||||
|
|
||||||
|
To associate multiple applications with a MIME type, add an entry in the `[Added Associations]` section:
|
||||||
|
|
||||||
|
```
|
||||||
|
[Added Associations]
|
||||||
|
image/jpeg=gimp.desktop;shotwell.desktop;
|
||||||
|
```
|
||||||
|
|
||||||
|
In this example, GIMP and Shotwell are associated with JPEG image files, in addition to the default application.
|
||||||
|
|
||||||
|
### Removing Associations
|
||||||
|
|
||||||
|
To remove or override associations defined in other configuration files or system-wide settings, add an entry in the `[Removed Associations]` section:
|
||||||
|
|
||||||
|
```
|
||||||
|
[Removed Associations]
|
||||||
|
text/plain=gedit.desktop
|
||||||
|
```
|
||||||
|
|
||||||
|
In this example, the association of the Gedit text editor with plain text files is removed.
|
||||||
|
|
||||||
|
### Updating and Applying Changes
|
||||||
|
|
||||||
|
After modifying the `mimeapps.list` file, save the changes. The modifications will take effect immediately for new file associations, but existing associations may require a restart of the application or the desktop environment.
|
||||||
|
|
||||||
|
## System-wide Associations
|
||||||
|
|
||||||
|
In addition to the user-specific `~/.config/mimeapps.list` file, system-wide associations can be defined in the `/etc/xdg/mimeapps.list` file or other configuration files in the `/etc/xdg` directory. System-wide associations apply to all users on the system.
|
||||||
|
|
||||||
|
It's generally recommended to make user-specific changes in the `~/.config/mimeapps.list` file to avoid affecting other users and to keep your customizations separate from system-wide settings.
|
||||||
|
|
||||||
|
## Conclusion
|
||||||
|
|
||||||
|
`xdg-open` and the `~/.config/mimeapps.list` file provide a powerful mechanism for managing default applications and file associations in Linux desktop environments. By understanding their usage and syntax, you can customize your system to open files and URLs with your preferred applications.
|
||||||
|
|
||||||
|
Remember to use the correct MIME types, URL schemes, and desktop file names when modifying the `mimeapps.list` file. Refer to the XDG specifications and documentation for more advanced configurations and options.
|
||||||
|
|
||||||
|
If you encounter any issues or need further assistance, consult the `xdg-open` manual page (`man xdg-open`) or seek help from the Linux community forums or resources specific to your desktop environment.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
Certainly! Here's a comprehensive user guide for xdg-open, including its advanced features:
|
Certainly! Here's a comprehensive user guide for xdg-open, including its advanced features:
|
||||||
|
|
||||||
## xdg-open User Guide
|
## xdg-open User Guide
|
||||||
|
|||||||
Reference in New Issue
Block a user