Files
fish-config/functions/_fish_deps_marktext_appimage.fish
T
rootiest f153a3db87 feat(deps): add marktext and firejail as optional dependencies
Both back the new `md` wrapper and nothing else, so both land in the
Optional tier, skipped by `fish-deps install`/`sync` unless `--optional`
(or `--all`) is passed.

firejail is a plain system package everywhere, so it needs no special
handling. marktext is not: upstream ships an AUR package and its own
GitHub release assets, and no distro carries it under a common name. Its
`_fdc_pm` entry is therefore deliberately empty, and a `marktext-release`
special offers the AUR package via paru/yay where one is present and
otherwise installs upstream's AppImage to ~/.local/bin/marktext.

The release assets embed their version in the filename, so there is no
stable /releases/latest/download URL to fetch -- `_fish_deps_marktext_appimage`
reads the download URL from the GitHub API instead. Upstream builds the
Linux AppImage for x86_64 only, and the helper says so rather than
downloading an unusable binary.

`fish-deps update` refreshes marktext through the AUR where available, and
otherwise only when ~/.local/bin/marktext exists -- a distro-packaged
marktext belongs to that package manager, and dropping an AppImage into
~/.local/bin would shadow it.
2026-09-16 03:56:48 -04:00

67 lines
2.1 KiB
Fish

# Copyright (C) 2026 Rootiest
# SPDX-License-Identifier: AGPL-3.0-or-later
# SYNOPSIS
# _fish_deps_marktext_appimage
#
# DESCRIPTION
# Installs (or upgrades in place) MarkText as an AppImage at
# ~/.local/bin/marktext. This is the install path for systems whose
# package manager does not carry MarkText at all -- upstream ships only
# the AUR package (marktext-bin) and its own GitHub release assets, so
# apt/dnf/brew have nothing to offer.
#
# The release assets embed their version in the filename, so there is no
# stable /releases/latest/download URL; the download URL is read from the
# GitHub API instead.
#
# Upstream builds the Linux AppImage for x86_64 only.
#
# EXIT STATUS
# 0 MarkText installed at ~/.local/bin/marktext
# 1 Unsupported architecture, or the download or install failed
#
# EXAMPLE
# _fish_deps_marktext_appimage
#
# NOTES
# An AppImage needs FUSE to self-mount. Where FUSE is unavailable, run it
# as `marktext --appimage-extract-and-run`.
function _fish_deps_marktext_appimage
set -l arch (uname -m)
if test "$arch" != x86_64
echo " MarkText publishes a Linux AppImage for x86_64 only (this is $arch)." >&2
return 1
end
if not type -q curl
echo " curl is required to download the MarkText AppImage." >&2
return 1
end
set -l url (curl -fsSL https://api.github.com/repos/marktext/marktext/releases/latest |
string match -r '"browser_download_url":\s*"([^"]*-linux-[^"]*\.AppImage)"')[2]
if test -z "$url"
echo " Could not find a Linux AppImage in the latest MarkText release." >&2
return 1
end
set -l dest "$HOME/.local/bin/marktext"
set -l tmp (mktemp -d)
set -l ok 0
curl -fL "$url" -o "$tmp/marktext"
and mkdir -p (dirname $dest)
and chmod +x "$tmp/marktext"
# Replace via mv, not a write into $dest: overwriting a running AppImage
# in place corrupts the live mount.
and mv -f "$tmp/marktext" "$dest"
and set ok 1
rm -rf $tmp
if test $ok -eq 1
fish_add_path "$HOME/.local/bin"
end
test $ok -eq 1
end