handlr (with examples)

handlr (with examples)

Handlr is a command-line tool that allows you to manage your default applications on your operating system. Whether you want to open a specific file type in a particular application or check what the default application is for a specific file type, Handlr has got you covered. In this article, we will explore different use cases of the Handlr command, providing code examples and explanations for each.

Opening a URL in the Default Application

The open command in Handlr allows us to open a URL in the default application set for web links. The following code demonstrates how to use this command:

handlr open https://example.com

Motivation: This use case is helpful when you want to quickly open a URL without specifying which application to use. By utilizing Handlr’s open command, the default web browser will automatically launch and navigate to the specified URL.

Argument Explanation:

  • open is the command to instruct Handlr to open a URL.
  • https://example.com is the URL of the website we want to open.

Example Output: The default web browser will launch and load the https://example.com website.

Opening a PDF in the Default PDF Viewer

The open command can also be used to open specific file types. In this example, we will open a PDF file in the default PDF viewer. Here’s the code:

handlr open path/to/file.pdf

Motivation: By using Handlr’s open command for specific file types, we can avoid the hassle of manually selecting the appropriate application each time we want to open a file. It ensures a seamless experience by automatically launching the default application for the given file type.

Argument Explanation:

  • open instructs Handlr to open a specific file.
  • path/to/file.pdf is the path to the PDF file we want to open.

Example Output: The default PDF viewer will launch and display the contents of the path/to/file.pdf document.

Setting a Default Application for a Specific File Type

Handlr’s set command allows us to set a default application for a specific file type. This is useful when you want to ensure that a particular program always opens a specific file type. Here’s an example of how to use the set command:

handlr set .png imv.desktop

Motivation: Sometimes, operating systems might not have the desired default application for a specific file type. By using Handlr’s set command, we can easily set our preferred application for the corresponding file type.

Argument Explanation:

  • set is the command to instruct Handlr to set a default application for a specific file type.
  • .png is the file type or extension for which we want to set the default application.
  • imv.desktop is the desktop file of the application we want to set as the default for .png files.

Example Output: The default application for .png files is updated to the specified application (imv.desktop).

Setting a Default Application for All Files of a Specific Type

Not only can we set a default application for a specific file type, but Handlr also allows us to set a default application for all files of a specific type. Let’s set MPV as the default application for all audio files using the set command:

handlr set 'audio/*' mpv.desktop

Motivation: When you have a preferred multimedia player and want it to open all audio files by default, Handlr’s ability to set a default application for all files of a specific type comes in handy. It saves you the hassle of manually selecting the appropriate application for each audio file.

Argument Explanation:

  • set is the command to instruct Handlr to set a default application for a specific file type.
  • 'audio/*' is a wildcard pattern that matches all file types starting with audio/, effectively covering all audio files.
  • mpv.desktop is the desktop file of the application we want to set as the default for all audio files.

Example Output: All audio files will now be opened by the specified application (mpv.desktop).

Listing All Default Applications

Sometimes, it is useful to view all the default applications set on your operating system. Handlr provides a convenient list command for this purpose. Here’s an example:

handlr list

Motivation: This use case helps you to quickly get an overview of all the default applications set for different file types on your system. It enables you to verify and manage default applications efficiently.

Example Output:

.pdf: evince.desktop
.jpg: eog.desktop
.png: imv.desktop
audio/*: mpv.desktop

The output will display a list of file types with their corresponding default applications.

Printing the Default Application for a Specific File Type

To check the default application set for a specific file type, the get command in Handlr can be used. Here’s an example:

handlr get .png

Motivation: It is sometimes necessary to verify the default application set for a particular file type. By using Handlr’s get command, you can quickly obtain the default application information.

Argument Explanation:

  • get is the command to instruct Handlr to retrieve the default application for a specific file type.
  • .png is the file type or extension for which we want to retrieve the default application.

Example Output: The output will display the desktop file or name of the default application set for .png files.

With the various use cases presented in this article, you now have a comprehensive understanding of how to utilize Handlr to manage your default applications effectively. Whether it is opening URLs or files in default applications, configuring specific or all file types, or simply listing and retrieving default application information, Handlr provides a powerful and flexible command-line interface for easy management.

Related Posts

How to use the command 'systemd-cat' (with examples)

How to use the command 'systemd-cat' (with examples)

The systemd-cat command is a utility in systemd that allows you to connect a pipeline or program’s output streams with the systemd journal.

Read More
Using the ebuild command (with examples)

Using the ebuild command (with examples)

The ebuild command is a low-level interface to the Gentoo Portage system.

Read More
How to use the command 'puppet apply' (with examples)

How to use the command 'puppet apply' (with examples)

The ‘puppet apply’ command allows you to apply Puppet manifests locally.

Read More