portable rewrite of mimi
Go to file
yosh f317ec831e use conf terminal first, add mimeopen 2023-08-10 21:44:31 -05:00
LICENSE Initial Commit 2023-06-17 18:33:48 -05:00
Makefile Initial Commit 2023-06-17 18:33:48 -05:00
README.md silly me that's the correct repo 2023-07-18 23:14:16 -05:00
mimeopen use conf terminal first, add mimeopen 2023-08-10 21:44:31 -05:00
xdg-email Initial Commit 2023-06-17 18:33:48 -05:00
xdg-open use conf terminal first, add mimeopen 2023-08-10 21:44:31 -05:00

README.md

Mimix

What is mimix?

mimix is a 99.9% portable rewrite of mimi. I made this because I like rewriting stuff in posix shell.

Changes from mimi

Probably-breaking changes are bolded.

  • The script is now in POSIX shell as well as (mostly) conforming to POSIX utility usage.
    • The only utility usage not conforming to POSIX is grep -m -R, but that is supported by GNU coreutils, NetBSD, OpenBSD, FreeBSD, and busybox utils, so I think all bases are covered there.
  • I removed the setting and usage of the $protocol variable, rather opting to simply set $mime to x-scheme-handler/$rematch if a protocol is matched. All .desktop files use the x-scheme-handler/ MimeType anyway, and I don't think anyone relied on their config having only the protocol and not x-scheme-handler. This simply solves conflicts.
  • mimix does not use $TERM for determining your terminal, rather $TERMINAL. $TERM is usually reserved for terminfo databases and such, and 99% of the time isn't executable, so it felt weird to interpret it as an executable. $TERMINAL, while informal, is generally more used as a variable people use to set an executable terminal, hence why I changed it to use that now.
  • I removed $MENUARGS, since I found it redundant as most menu arguments people will use won't use spaces anyway (except prompt, but the prompt gets set manually, so it is irrelevant). put all your menu args in $MENU
  • The .desktop Exec line and your mimix.conf will be treated as a shell command, not a program with arguments. This follows the xdg spec and what xdg-open does. It also allows for slightly more flexibility. Take extra care on avoiding word globbing (use quotes if unsure) and escaping special characters, and write as one would in the shell. The argument to mimix will be escaped for you, so no need to worry about that.
  • Extensions are prefixed with a . now. This is to avoid quick-glance ambiguity with general MIMEs.

Installation

  • Clone the repository: git clone https://git.unix.dog/mimix

You now have two options for installing: user-wide or system-wide.

User-wide

  • Place xdg-open and xdg-email in a PATH that comes before the system-level $PATH e.g. $HOME/.local/bin.

System-wide

  • To replace the system's xdg-open and xdg-email, just do make install as root.

Example configuration

# This is a comment, and also shows setting the TERMINAL variable.
TERMINAL: urxvt

MENU: fzfmenu

# The "End of arguments" signifier is not passed by default, as there might be programs that do not support it.
# These environment variables are unquoted because I know they will never contain spaces. Remember, treat these lines like a shell.
text/: $TERMINAL -e $VISUAL --
audio/: mpv --player-operation-mode=pseudo-gui --
video/: mpv --player-operation-mode=pseudo-gui --
image/: nsxiv-rifle --

# Specific mimetypes are processed before general mimetypes, so these will take priority over the general ones above.
inode/directory: $TERMINAL -e nnn --
image/x-xcf: gimp --
application/pdf: zathura -- 
application/epub+zip: zathura --
image/vnd.djvu: zathura --
x-scheme-handler/magnet: $TERMINAL -e aria2c --
application/x-bittorrent: $TERMINAL -e aria2c --

# Specific extensions are processed before mimes, so specific extensions can be treated specially
.log: some-special-log-viewer-program --

x-scheme-handler/http: palemoon --
x-scheme-handler/https: palemoon -- 
x-scheme-handler/chrome: palemoon --
text/html: palemoon --
application/x-extension-htm: palemoon --
application/x-extension-html: palemoon --
application/x-extension-shtml: palemoon --
application/xhtml+xml: palemoon --
application/x-extension-xhtml: palemoon --
application/x-extension-xht: palemoon --

Tips and tricks

  • You can set MENU in order to use a dmenu alternative. For instance, to use rofi:
MENU: rofi -dmenu

Alternatives

Bash scripts

Rust

Node.js