Xdg open linux установка

How To Install xdg-open on Ubuntu 21.04

In this guide, we’ll discuss How To Install xdg-open on Ubuntu 21.04. Also, we will demonstrate how to uninstall and update xdg-open .

One-liner install command

For those in a hurry, here’s a one-line installation command:

sudo apt-get update && sudo apt -y install xdg-utils

But if you are interested in the detailed steps with descriptions, the following information is for you.

What is xdg-open and what are the ways to install it?

Short description: desktop integration utilities from freedesktop.org

Before beginning this tutorial, you will need access to a server or computer running Ubuntu 21.04. This guide was written specifically with a server running Ubuntu 21.04 in mind, although it should also work on older, supported versions of the operating system.

Also, make sure you are running a regular, non-root user with sudo privileges configured on your server. When you have an account available, log in as your non-root user to begin.

There are several ways to install xdg-open on Ubuntu 21.04. You can use (links are clickable):

In the following sections, we will describe each method in detail. You can choose one of them or refer to the recommended one.

Install xdg-open using apt-get

First, update apt database with apt-get using the following command.

After updating apt-get database, You can install xdg-open using apt by running the following command:

sudo apt -y install xdg-utils

Install xdg-open using apt

Because xdg-open is available in Ubuntu 21.04’s default repositories, it is possible to install it from these repositories using the apt packaging system.

To begin, update apt database with apt using the following command.

After updating apt database, You can install xdg-open using apt by running the following command:

sudo apt -y install xdg-utils

Install xdg-open using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Ubuntu 21.04. Update apt database with aptitude using the following command.

After updating aptitude database, You can install xdg-open by running the following command:

sudo aptitude -y install xdg-utils

How to upgrade (update) a single package xdg-open using apt-get?

First, you will need to update packages index. Run update command as usual:

Читайте также:  Linux is for noobs

Next, to upgrade only the xdg-open, e.g. single package, you should use the following format with the apt-get command/apt command:

sudo apt-get --only-upgrade install xdg-utils

Note that this command will not install any new packages! If you wish to install the package if it doesn’t exist you may leave out —only-upgrade part.

It’s Good to Know:

sudo apt-get install xdg-utils

This will upgrade the package even if is already installed.

How To Uninstall xdg-open from Ubuntu 21.04

To uninstall only the xdg-open package you can execute the following command:

sudo apt-get remove xdg-utils

Uninstall xdg-open and all its dependencies

To uninstall xdg-open and its dependencies that are no longer needed by Ubuntu 21.04, you can use the command below:

sudo apt-get -y autoremove xdg-utils

Remove xdg-open with all configurations and data

To remove xdg-open configuration and data from your system you can run the following purge command:

sudo apt-get -y purge xdg-utils

Remove xdg-open completely (configurations, data and all of its dependencies)

And lastly, you can run the next command to remove absolutely everything related to xdg-open package, e.g.: configurations, data and all of its dependencies. Just use this command:

sudo apt-get -y autoremove --purge xdg-utils

Extra info and code examples

xdg-utils contains utilities for integrating applications with the desktop environment, regardless of which desktop environment is used. They are part of freedesktop.org’s Portland project. The following utilities are included: * xdg-desktop-menu — Install desktop menu items * xdg-desktop-icon — Install icons on the user’s desktop * xdg-email — Compose a new email in the user’s preferred email client, potentially with subject and other info filled in * xdg-icon-resource — Install icon resources * xdg-mime — Query and install MIME types and associations * xdg-open — Open a URI in the user’s preferred application that handles the respective URI or file type * xdg-screensaver — Enable, disable, or suspend the screensaver * xdg-settings — Get or set the default web browser and URI handlers If you are running GNOME, make sure that the gvfs-bin package is installed.

  • Maintainer: Debian freedesktop.org maintainers
  • Sources url:https://www.freedesktop.org/wiki/Software/xdg-utils/
  • Section/Category:utils

Conclusion

You now have a full guide on how to install xdg-open using apt, apt-get and aptitude tools. Also, we showed how to update as a single package and different ways to uninstall the xdg-open from Ubuntu 21.04.

Источник

User:larivact/xdg-open

xdg-open is a desktop-independent tool to open a file or URL in the user’s default application. Many applications invoke the xdg-open(1) command internally.

Inside a desktop environment (like GNOME, KDE, or Xfce), xdg-open simply passes the arguments to those desktop environment’s file-opener application (eg. gio(1) open, kde-open, or exo-open(1) ). which means that the associations are left up to the desktop environment.

When no desktop environment is detected (for example when one runs a standalone window manager like eg. Openbox), xdg-open will use its own configuration files.

Installation

xdg-open is part of the xdg-utils package available in the official repositories. It is for use inside a desktop session only, and should not be run as root.

Читайте также:  Kali linux драйвер сетевой карты

If you run xdg-open without a desktop environment, you should also install perl-file-mimeinfo , or xdg-utils-mimeo AUR and mimeo AUR from the AUR for a faster alternative.

Configuration

xdg-open is configured by the files mentioned in Default applications. xdg-mime modifies the local file ~/.config/mimeapps.list and ~/.local/share/applications/mimeapps.list (deprecated).

To query the mime type used by an existing file, use

$ xdg-mime query filetype file.ext 

Reversely, to query the default desktop entry associated with a specific mime type, run

$ xdg-mime query default mime/type 

Examples for mime/type can be:

inode/directory (file browser) image/jpeg (JPEG images) application/pdf (PDF viewer) or others

To change an associated desktop entry, use:

$ xdg-mime default application.desktop mime/type 

For example set Thunar as the default file browser just run:

$ xdg-mime default Thunar.desktop inode/directory

Note that you should not specify the complete path, but only the name of the .desktop file.

This command can take multiple mime-types, allowing related files to be handled by the same program. The example below associates Emacs to all known source files:

$ xdg-mime default emacs.desktop $(grep '^text/x-*' /usr/share/mime/types)

Set the default browser

Internet protocols are using x-scheme-handler as first part of MIME-type. To show all available x-scheme-handler MIME-types and related to them *.desktop files in your system use tool lsdesktopf AUR .

lsdesktopf --gm | grep x-scheme-handler

To set the default application for http(s):// web URLs, write

$ xdg-mime default browser.desktop x-scheme-handler/http $ xdg-mime default browser.desktop x-scheme-handler/https
$ xdg-mime default browser.desktop text/html
$ xdg-settings set default-web-browser browser.desktop

To test if this was applied successfully, try to open an URL with xdg-open as follows:

perl-file-mimeinfo

xdg-open uses perl-file-mimeinfo as a fallback («generic») method if no desktop environment is detected. It can be invoked directly with:

You are asked which application to use when opening /path/to/file :

Please choose a default application for files of type text/plain 1) notepad (wine-extension-txt) 2) Leafpad (leafpad) 3) OpenOffice.org Writer (writer) 4) gVim (gvim) 5) Other.

Your answer becomes the default handler for that type of file. Mimeopen is installed as /usr/bin/vendor_perl/mimeopen .

Drop-in replacements and useful tools

xdg-open replacements

Name/Package Method Based on Configuration file
busking-git AUR Regular expressions perl-file-mimeinfo custom
linopen AUR file custom
mimeo AUR MIME-type, regular expressions file mimeapps.list , defaults.list ; custom is optional
mimi-git AUR file custom
whippet AUR MIME-type, name, regular expressions SQLite database or file , perl-file-mimeinfo , etc custom SQLite database or mimeapps.list
ayr AUR MIME-type, name, regular expressions file or perl-file-mimeinfo , etc mimeapps.list , defaults.list
sx-open AUR Regular expressions file , bash regex custom
ranger (rifle command) MIME-type, name, regular expressions custom

Note: Some of the above packages replace xdg-utils . Those that do not can be symbolically linked to xdg-open in the user’s $PATH above /usr/bin , but some applications hard-code the absolute path /usr/bin/xdg-open . In this case, install xdg-utils-no-open AUR from the AUR and copy the replacement to /usr/bin/xdg-open .

mailcap

This article or section needs expansion.

Reason: When using run-mailcap AUR , xdg-open may refer to it.[1] It should then clearly not be combined with the below file to prevent endless loops. (Discuss in User talk:Larivact/xdg-open)

Читайте также:  Linux network activity monitor

The .mailcap file format is used by mail programs such as mutt and sylpheed . To have those programs use xdg-open, edit ~/.mailcap :

mimetype

mimetype in perl-file-mimeinfo package can display some mimetype-related information about a file.

returns the mimetype of a file,

returns a description of that mimetype.

When xdg-open fails to detect one of the desktop environments it knows about, it normally falls back to using file -i , which uses only file contents to determine the mimetype, resulting in some file types not being detected correctly. With mimetype available, xdg-open will use that instead, with better detection results, as mimetype uses the information in the shared mime info database.

Environment variables

Some environment variables, such as BROWSER , DE , and DESKTOP_SESSION , will change the behaviour of the default xdg-open. See Environment variables for more information.

Источник

Русские Блоги

Используйте команду xdg-open для эффективного открытия файлов в Ubuntu

Оригинальный текст впервые был опубликован на личном сайте:Спасаться бегством
Публичный номер: [DreamHub]

фон

Как правило, вы можете использовать команды для управления различными текстовыми файлами в терминале. Но если вам нужно манипулировать некоторыми нетекстовыми файлами, такими как pdf , doc И т.д. Обычная практика:

  1. Откройте файловый менеджер;
  2. Послойно войдите в соответствующий каталог и найдите соответствующий файл;
  3. Дважды щелкните, чтобы открыть;

Проблема с этим методом заключается в том, что он громоздок и неэффективен в использовании, особенно когда путь к файлу глубокий и в нескольких папках много файлов. Итак, как я могу повысить свою операционную эффективность?

В этой статье представлены три разных подхода, которые вы можете выбрать в соответствии со своими потребностями:

Метод 1: управление файлами nautilus

nautilus — это файловый менеджер по умолчанию в ubuntu. В консоли вы можете использовать команду nautilus, чтобы открыть файловый менеджер прямо по указанному пути, без двойного щелчка мышью слой за слоем!

После открытия файлового менеджера дважды щелкните мышью, чтобы открыть целевой файл.

Если ты не можешь вспомнить nautilus , Вы можете добавить к нему alias

Метод 2: откройте команду напрямую

Большинство программ можно вызвать из командной строки для запуска, поэтому непосредственно вызывайте соответствующее приложение, чтобы открыть соответствующий файл. Например

$ wps xxx.doc $ FoxitReader xxx.pdf 

Метод 3: xdg-open

Сравните два вышеуказанных метода:

  • Первую легко запомнить, команда для открытия файлового менеджера, но вам все равно нужно дважды щелкнуть, чтобы открыть соответствующий файл.
  • Второй тип открывает целевой файл за один шаг, но его сложно запомнить: нужно запомнить соответствующее название программы для каждого формата.

Итак, вот лучшие xdg-open команда! Вам не нужно использовать два вышеуказанных метода!

установка

sudo apt-get update sudo apt-get install xdg-utils 

использование

xdg-open Использование очень простое. Просто передайте параметры прямо в файл, который нужно открыть, что эквивалентно двойному щелчку мыши для открытия. Система автоматически вызовет соответствующую программу в соответствии с типом файла, например

xdg-open xxx.doc xdg-open xxx.pdf xdg-open xxx.png 

Если вы укажете путь, используйте файловый менеджер, чтобы открыть

xdg-open . xdg-open ~/Downloads 

Вы также можете передать URL

Если вы чувствуете, что команда длиннее, чтобы было удобнее, вы можете подумать о добавлении чего-то, что вам подходит. alias :

alias dakai='xdg-open' alias включать='xdg-open' 

Источник

Оцените статью
Adblock
detector