openurl

Version, currently 0.2.02 versions

github.com/jo1gi/openurl

Opens urls in the specified program

2 stars
0 dependents
License: MIT

Installation

# Add this to your shard.yml
dependencies:
  openurl:
    github: jo1gi/openurl
    version: ~> 0.2.0

Then run:

shards install

shard.yml

Crystal
0.35.1
License
MIT
Author
Joakim Holm
Target
  • openurl from src/openurl.cr

Dependencies

This version declares no dependencies.

README

openurl

GitHub release GitHub top language License Build

Opens urls based on rules in a yaml file.

Usage

To run, just execute the program with a url as the argument. The program will expect a config file located at $XDG_CONFIG_HOME/openurl/config.yaml. The program will then open the url with the command specified in the config.

Configuration

The Configuration file specifies which programs should open which urls. It consists of a list of rules for opening urls.

Here is an example where youtube is opened in vlc, all other websites are opened through firefox, and gemini capsules are opened in amfora.

- protocol: https?
  command: firefox
  subrules:
    - domain: youtube.com
      command: vlc

- protocol: gemini
  command: amfora

The program checks each rule one by one. When it finds a rule set that matches the url, it will check if any subrules match the url. When the first matching rule is found, the corresponding command will be run with the url appended.

Each rules is comprised of a list of attributes that can be tested. Each attribute corresponds with a part of the url. This part will be checked to see if the given regex matches.

AttrubuteDescriptionExample
protocolCommunication protocolhttps://channels.nixos.org/nixos-21.05/latest-nixos-gnome-x86_64-linux.iso
domainWebsite domain name and subdomainhttps://channels.nixos.org/nixos-21.05/latest-nixos-gnome-x86_64-linux.iso
last_fileLast part of pathhttps://channels.nixos.org/nixos-21.05/latest-nixos-gnome-x86_64-linux.iso
filetypeFile extension if it existshttps://channels.nixos.org/nixos-21.05/latest-nixos-gnome-x86_64-linux.iso
pathAnything after the domain and before parametershttps://channels.nixos.org/nixos-21.05/latest-nixos-gnome-x86_64-linux.iso
urlMatches everythinghttps://channels.nixos.org/nixos-21.05/latest-nixos-gnome-x86_64-linux.iso