use lowercase functions, upgrade Makefile
This commit is contained in:
parent
11ef84029b
commit
808c672197
40
Makefile
40
Makefile
|
@ -1,30 +1,13 @@
|
|||
# fontctrl
|
||||
# Minimal font manager for GNU/Linux.
|
||||
# https://codeberg.org/speedie/fontctrl
|
||||
#
|
||||
# Copyright (C) 2022 speedie
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
include options.mk
|
||||
|
||||
help:
|
||||
@echo "make install Install ${NAME}."
|
||||
@echo "make uninstall Uninstall ${NAME}."
|
||||
@echo "make clean: Remove tarballs."
|
||||
@echo "make dist Create distro package for ${NAME}."
|
||||
@echo "make pkg_arch Create Arch package ${NAME}."
|
||||
|
||||
install:
|
||||
install: clean
|
||||
cp ${NAME} ${PREFIX}${DESTDIR}/bin
|
||||
chmod +x ${PREFIX}${DESTDIR}/bin/${NAME}
|
||||
|
||||
|
@ -32,10 +15,23 @@ uninstall:
|
|||
rm -rf ~/.config/${NAME}
|
||||
rm -f ${PREFIX}${DESTDIR}/bin/${NAME}
|
||||
|
||||
dist:
|
||||
clean:
|
||||
rm -f *.tar* *zst* *${NAME}-${VER}.PKGBUILD
|
||||
|
||||
dist: clean
|
||||
mkdir -p ${NAME}-${VER}
|
||||
cp ${NAME} README.md LICENSE Makefile ${NAME}-${VER}
|
||||
cp ${NAME} README.md LICENSE Makefile *.mk ${NAME}-${VER}
|
||||
[ -f "PKGBUILD" ] && cp -f PKGBUILD ${NAME}-${VER} || :
|
||||
tar -cf ${NAME}-${VER}.tar ${NAME}-${VER}
|
||||
gzip ${NAME}-${VER}.tar
|
||||
rm -rf ${NAME}-${VER}.tar ${NAME}-${VER}
|
||||
gpg --detach-sign --yes --local-user $$(whoami) ${NAME}-${VER}.tar.gz || :
|
||||
|
||||
pkg_arch: dist
|
||||
command -v makepkg > /dev/null || exit 1
|
||||
[ -f PKGBUILD ] || exit 1
|
||||
cp -f PKGBUILD PKGBUILD.orig
|
||||
sed -i "s/VERSION/${VER}/g; s/MD5SUM/$$(md5sum *.tar.gz | cut -d ' ' -f 1)/g" PKGBUILD
|
||||
makepkg -sfr --sign || exit 1
|
||||
rm -rf src/ pkg/
|
||||
cp PKGBUILD ${NAME}-${VER}.PKGBUILD; mv PKGBUILD.orig PKGBUILD
|
||||
|
|
14
PKGBUILD
14
PKGBUILD
|
@ -1,13 +1,17 @@
|
|||
pkgname=fontctrl
|
||||
pkgver=1.3
|
||||
pkgver=VERSION
|
||||
pkgrel=1
|
||||
epoch=
|
||||
pkgdesc="Minimal font manager for GNU/Linux"
|
||||
arch=(x86_64)
|
||||
url="https://speedie.gq/projects/fontctrl.php"
|
||||
url="https://git.speedie.site/speedie/fontctrl"
|
||||
license=('GPL')
|
||||
groups=()
|
||||
depends=(binutils)
|
||||
|
||||
depends=(
|
||||
binutils
|
||||
)
|
||||
|
||||
makedepends=()
|
||||
checkdepends=()
|
||||
optdepends=()
|
||||
|
@ -23,10 +27,10 @@ source=(
|
|||
#"https://ls.speedie.gq/releases/$pkgname/$pkgname-$pkgver.tar.gz"
|
||||
)
|
||||
noextract=()
|
||||
md5sums=('SKIP')
|
||||
md5sums=(MD5SUM)
|
||||
validpgpkeys=()
|
||||
|
||||
package() {
|
||||
cd "$pkgname-$pkgver"
|
||||
install -Dm755 fontctrl "${pkgdir}"/usr/bin/fontctrl
|
||||
install -Dm755 ${pkgname} "${pkgdir}"/usr/bin/${pkgname}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
Minimal font manager for GNU/Linux written in POSIX compliant shell script.
|
||||
|
||||
# License
|
||||
|
||||
Copyright (C) 2022-2023 speedie
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
|
247
fontctrl
247
fontctrl
|
@ -1,7 +1,7 @@
|
|||
#!/bin/sh
|
||||
# fontctrl
|
||||
# Minimal font manager for GNU/Linux.
|
||||
# https://codeberg.org/speedie/fontctrl
|
||||
# https://git.speedie.site/speedie/fontctrl
|
||||
#
|
||||
# Copyright (C) 2022-2023 speedie
|
||||
#
|
||||
|
@ -19,225 +19,222 @@
|
|||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
# hardcoded base directories, can however be overriden by exporting these
|
||||
[ -z "$FONTCTRL_BASEDIR_USER" ] && FONTCTRL_BASEDIR_USER="$HOME/.config/fontctrl"
|
||||
[ -z "$FONTCTRL_BASEDIR_GLOBAL" ] && FONTCTRL_BASEDIR_GLOBAL="/etc/fontctrl"
|
||||
[ -z "$FONTCTRL_VER" ] && FONTCTRL_VER="1.3"
|
||||
[ -z "$GLOBALFONTDIR" ] && GLOBALFONTDIR="/usr/share/fonts/fonts"
|
||||
[ -z "$USERFONTDIR" ] && USERFONTDIR="$HOME/.local/share/fonts"
|
||||
FONTCTRL_BASEDIR_USER="${FONTCTRL_BASEDIR_USER:-$HOME/.config/fontctrl}"
|
||||
FONTCTRL_BASEDIR_GLOBAL="${FONTCTRL_BASEDIR_GLOBAL:-/etc/fontctrl}"
|
||||
FONTCTRL_VER="${FONTCTRL_VER:-1.3}"
|
||||
GLOBALFONTDIR="${GLOBALFONTDIR:-/usr/share/fonts/fonts}"
|
||||
USERFONTDIR="${USERFONTDIR:-$HOME/.local/share/fonts}"
|
||||
|
||||
# wrapper functions to clean up codebase
|
||||
DIE() { STDERR "$@"; exit 1; }
|
||||
MSG() { [ -n "$*" ] && printf "%s\n" "$@"; }
|
||||
MSGN() { [ -n "$*" ] && printf "%s" "$@"; }
|
||||
STDERR() { MSG "$@" >&2; }
|
||||
ISNARG() { echo "$CARG" | grep -qE "$COPT|--global|--user|--raw" && return 1 || return 0; }
|
||||
die() { stderr "$@"; exit 1; }
|
||||
msg() { [ -n "$*" ] && printf "%s\n" "$@"; }
|
||||
msg_n() { [ -n "$*" ] && printf "%s" "$@"; }
|
||||
stderr() { msg "$@" >&2; }
|
||||
is_narg() { echo "$carg" | grep -qE "$copt|--global|--user" && return 1 || return 0; }
|
||||
|
||||
# help argument
|
||||
LIST_ARGS() {
|
||||
MSG "fontctrl - minimal font manager for POSIX compliant shells."
|
||||
MSG "usage: [STDIN] fontctrl [install FONT] [remove FONT] [list] [enable FONT] [disable FONT] [license] [help] [version] [arg]"
|
||||
MSG "--global perform the action as a superuser."
|
||||
MSG "--user perform the action as the current user."
|
||||
MSG "--raw print version without any extra information."
|
||||
ls_args() {
|
||||
msg "fontctrl - minimal font manager for POSIX compliant shells."
|
||||
msg "usage: [stdin] fontctrl [install FONT] [remove FONT] [list] [enable FONT] [disable FONT] [license] [help] [version] [arg]"
|
||||
msg "--global perform the action as a superuser."
|
||||
msg "--user perform the action as the current user."
|
||||
}
|
||||
|
||||
# create base for fontctrl
|
||||
CREATE_BASE() {
|
||||
mk() {
|
||||
# create base directories where font symlinks and configurations for fonts will be placed.
|
||||
[ "$(id -u)" = "0" ] && \
|
||||
mkdir -p $FONTCTRL_BASEDIR_GLOBAL/fonts && isroot=true; \
|
||||
mkdir -p "$FONTCTRL_BASEDIR_USER/fonts"
|
||||
|
||||
echo "$ARG" | grep -q "global" && isglobal=true
|
||||
echo "$arg" | grep -q "global" && isglobal=true
|
||||
|
||||
FAIL_NOROOT() {
|
||||
[ -z "$isroot" ] || return
|
||||
DIE "This action must be used as root."
|
||||
die "This action must be used as root."
|
||||
}
|
||||
|
||||
echo "$ARG" | grep -q "global" && FAIL_NOROOT
|
||||
echo "$arg" | grep -q "global" && FAIL_NOROOT
|
||||
}
|
||||
|
||||
# function to parse arguments and install fonts
|
||||
INSTALL_FONT() {
|
||||
EXITCODE=0 # exit code
|
||||
[ -z "$2" ] && DIE "You must specify a font to install."
|
||||
install_font() {
|
||||
exitcode=0 # exit code
|
||||
[ -z "$2" ] && die "You must specify a font to install."
|
||||
|
||||
# loop through arguments
|
||||
for i in $(seq "$ARGC"); do
|
||||
CARG="$(printf "%s\n" "$@" | sed -n "${i}","${i}"p)"
|
||||
COPT=install
|
||||
ISNARG || continue
|
||||
[ ! -e "$CARG" ] && EXITCODE=1 && STDERR "Font '$CARG' does not exist." && continue || ARG2="$CARG"
|
||||
[ ! -e "$CARG" ] && DIE "Failed to install '$CARG': Not a valid font, exiting." || MSG "Installing font '$CARG'."
|
||||
for i in $(seq "$argc"); do
|
||||
carg="$(printf "%s\n" "$@" | sed -n "${i}","${i}"p)"
|
||||
copt=install
|
||||
is_narg || continue
|
||||
[ ! -e "$carg" ] && exitcode=1 && stderr "Font '$carg' does not exist." && continue || arg2="$carg"
|
||||
[ ! -e "$carg" ] && die "Failed to install '$carg': Not a valid font, exiting." || msg "Installing font '$carg'."
|
||||
|
||||
# install the font
|
||||
[ "$isroot" != "true" ] && cp -f "$ARG2" "$FONTCTRL_BASEDIR_USER/fonts/" && MSG "Font '$ARG2' installed successfully for $(whoami)." && hi=true && continue
|
||||
[ "$isroot" = "true" ] && cp -f "$ARG2" "$FONTCTRL_BASEDIR_GLOBAL/fonts/" && MSG "Font '$ARG2' installed globally successfully." && hi=true && continue
|
||||
[ "$isroot" != "true" ] && cp -f "$arg2" "$FONTCTRL_BASEDIR_USER/fonts/" && msg "Font '$arg2' installed successfully for $(whoami)." && hi=true && continue
|
||||
[ "$isroot" = "true" ] && cp -f "$arg2" "$FONTCTRL_BASEDIR_GLOBAL/fonts/" && msg "Font '$arg2' installed globally successfully." && hi=true && continue
|
||||
done
|
||||
|
||||
[ "$hi" != "true" ] && DIE "Font does not exist."
|
||||
[ "$hi" != "true" ] && die "Font does not exist."
|
||||
|
||||
if [ "$isroot" != "true" ]; then
|
||||
MSG "Run fontctrl list --user followed by fontctrl enable <font> --user to enable the font."
|
||||
msg "Run fontctrl list --user followed by fontctrl enable <font> --user to enable the font."
|
||||
else
|
||||
MSG "Run fontctrl list --global followed by fontctrl enable <font> --global to enable the font."
|
||||
msg "Run fontctrl list --global followed by fontctrl enable <font> --global to enable the font."
|
||||
fi
|
||||
|
||||
return $EXITCODE # return the exit code
|
||||
return $exitcode # return the exit code
|
||||
}
|
||||
|
||||
# function to parse arguments and remove fonts
|
||||
REMOVE_FONT() {
|
||||
EXITCODE=0 # exit code
|
||||
[ -z "$2" ] && DIE "You must specify a font to remove."
|
||||
rm_font() {
|
||||
exitcode=0 # exit code
|
||||
[ -z "$2" ] && die "You must specify a font to remove."
|
||||
|
||||
for i in $(seq "$ARGC"); do
|
||||
CARG="$(printf "%s\n" "$@" | sed -n "${i}","${i}"p)"
|
||||
COPT=remove
|
||||
ISNARG || continue
|
||||
[ -z "$ARG2" ] && MSG "You must specify a font to remove." && exit 1
|
||||
for i in $(seq "$argc"); do
|
||||
carg="$(printf "%s\n" "$@" | sed -n "${i}","${i}"p)"
|
||||
copt=remove
|
||||
is_narg || continue
|
||||
[ -z "$arg2" ] && msg "You must specify a font to remove." && exit 1
|
||||
|
||||
# remove globally
|
||||
if [ "$isglobal" = "true" ]; then
|
||||
SELFONT="$(find "$FONTCTRL_BASEDIR_GLOBAL"/fonts/*"$CARG"* -type f 2>/dev/null | head -n 1)" # Head in case there are multiple matches
|
||||
[ ! -e "$SELFONT" ] && EXITCODE=1 && STDERR "No fonts matching '$CARG' found." && continue
|
||||
MSG "Removing font '$SELFONT' globally."
|
||||
selfont="$(find "$FONTCTRL_BASEDIR_GLOBAL"/fonts/*"$carg"* -type f 2>/dev/null | head -n 1)" # Head in case there are multiple matches
|
||||
[ ! -e "$selfont" ] && exitcode=1 && stderr "No fonts matching '$carg' found." && continue
|
||||
msg "Removing font '$selfont' globally."
|
||||
hi=true
|
||||
rm -f "$FONTCTRL_BASEDIR_GLOBAL/fonts/$SELFONT" && MSG "Font '$SELFONT' removed successfully. Run fontctrl list to see available fonts."
|
||||
rm -f "$FONTCTRL_BASEDIR_GLOBAL/fonts/$selfont" && msg "Font '$selfont' removed successfully. Run fontctrl list to see available fonts."
|
||||
else # for the user
|
||||
SELFONT="$(find "$FONTCTRL_BASEDIR_USER"/fonts/*"$CARG"* -type f 2>/dev/null | head -n 1)" # Head in case there are multiple matches
|
||||
[ ! -e "$SELFONT" ] && EXITCODE=1 && STDERR "No fonts matching '$CARG' found." && continue
|
||||
MSG "Removing font '$SELFONT' for $(whoami)"
|
||||
selfont="$(find "$FONTCTRL_BASEDIR_USER"/fonts/*"$carg"* -type f 2>/dev/null | head -n 1)" # Head in case there are multiple matches
|
||||
[ ! -e "$selfont" ] && exitcode=1 && stderr "No fonts matching '$carg' found." && continue
|
||||
msg "Removing font '$selfont' for $(whoami)"
|
||||
hi=true
|
||||
rm -f "$SELFONT" && MSG "Font '$SELFONT' removed successfully. Run fontctrl list to see available fonts."
|
||||
rm -f "$selfont" && msg "Font '$selfont' removed successfully. Run fontctrl list to see available fonts."
|
||||
fi
|
||||
done
|
||||
|
||||
[ "$hi" != "true" ] && DIE "Font does not exist."
|
||||
return $EXITCODE # return the exit code
|
||||
[ "$hi" != "true" ] && die "Font does not exist."
|
||||
return $exitcode # return the exit code
|
||||
}
|
||||
|
||||
# function to parse arguments and enable fonts
|
||||
ENABLE_FONT() {
|
||||
EXITCODE=0 # exit code
|
||||
[ -z "$2" ] && DIE "You must specify a font to enable."
|
||||
enable_font() {
|
||||
exitcode=0 # exit code
|
||||
[ -z "$2" ] && die "You must specify a font to enable."
|
||||
|
||||
for i in $(seq "$ARGC"); do
|
||||
CARG="$(printf "%s\n" "$@" | sed -n "${i}","${i}"p)"
|
||||
COPT=enable
|
||||
ISNARG || continue
|
||||
for i in $(seq "$argc"); do
|
||||
carg="$(printf "%s\n" "$@" | sed -n "${i}","${i}"p)"
|
||||
copt=enable
|
||||
is_narg || continue
|
||||
|
||||
if [ "$isglobal" != "true" ]; then # user
|
||||
SELFONT="$(find "$FONTCTRL_BASEDIR_USER"/fonts/*"$CARG"* -type f 2>/dev/null | head -n 1)" # Head in case there are multiple matches
|
||||
BASESELFONT="$(basename "$SELFONT")"
|
||||
[ ! -e "$SELFONT" ] && EXITCODE=1 && STDERR "No fonts matching '$CARG' found." && continue
|
||||
MSG "Enabling font '$BASESELFONT' for $(whoami)"
|
||||
selfont="$(find "$FONTCTRL_BASEDIR_USER"/fonts/*"$carg"* -type f 2>/dev/null | head -n 1)" # Head in case there are multiple matches
|
||||
b_selfont="$(basename "$selfont")"
|
||||
[ ! -e "$selfont" ] && exitcode=1 && stderr "No fonts matching '$carg' found." && continue
|
||||
msg "Enabling font '$b_selfont' for $(whoami)"
|
||||
mkdir -p "$USERFONTDIR/fontctrl-fonts"
|
||||
rm -f "$USERFONTDIR/fontctrl-fonts/$BASESELFONT"
|
||||
rm -f "$USERFONTDIR/fontctrl-fonts/$b_selfont"
|
||||
hi=true
|
||||
[ -e "$FONTCTRL_BASEDIR_USER/fonts/$BASESELFONT" ] && ln -s "$FONTCTRL_BASEDIR_USER/fonts/$BASESELFONT" "$USERFONTDIR/fontctrl-fonts/$BASESELFONT" && MSG "Font '$BASESELFONT' enabled successfully." && continue
|
||||
[ -e "$FONTCTRL_BASEDIR_USER/fonts/$b_selfont" ] && ln -s "$FONTCTRL_BASEDIR_USER/fonts/$b_selfont" "$USERFONTDIR/fontctrl-fonts/$b_selfont" && msg "Font '$b_selfont' enabled successfully." && continue
|
||||
exit 1
|
||||
else # global
|
||||
SELFONT="$(find "$FONTCTRL_BASEDIR_GLOBAL"/fonts/*"$CARG"* -type f 2>/dev/null | head -n 1)" # Head in case there are multiple matches
|
||||
BASESELFONT="$(basename "$SELFONT")"
|
||||
[ ! -e "$SELFONT" ] && STDERR "No fonts matching '$CARG' found." && EXITCODE=1 && continue
|
||||
MSG "Enabling font '$BASESELFONT' globally."
|
||||
selfont="$(find "$FONTCTRL_BASEDIR_GLOBAL"/fonts/*"$carg"* -type f 2>/dev/null | head -n 1)" # Head in case there are multiple matches
|
||||
b_selfont="$(basename "$selfont")"
|
||||
[ ! -e "$selfont" ] && stderr "No fonts matching '$carg' found." && exitcode=1 && continue
|
||||
msg "Enabling font '$b_selfont' globally."
|
||||
mkdir -p "$GLOBALFONTDIR/fontctrl-fonts"
|
||||
rm -f "$GLOBALFONTDIR/fontctrl-fonts/$BASESELFONT"
|
||||
rm -f "$GLOBALFONTDIR/fontctrl-fonts/$b_selfont"
|
||||
hi=true
|
||||
[ -e "$FONTCTRL_BASEDIR_GLOBAL/fonts/$SELFONT" ] && ln -s "$FONTCTRL_BASEDIR_GLOBAL/fonts/$SELFONT" "$GLOBALFONTDIR/fontctrl-fonts/$BASESELFONT" && MSG "Font '$SELFONT' enabled successfully." && continue
|
||||
[ -e "$FONTCTRL_BASEDIR_GLOBAL/fonts/$selfont" ] && ln -s "$FONTCTRL_BASEDIR_GLOBAL/fonts/$selfont" "$GLOBALFONTDIR/fontctrl-fonts/$b_selfont" && msg "Font '$selfont' enabled successfully." && continue
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
[ "$hi" != "true" ] && DIE "Font does not exist."
|
||||
return $EXITCODE # return the exit code
|
||||
[ "$hi" != "true" ] && die "Font does not exist."
|
||||
return $exitcode # return the exit code
|
||||
}
|
||||
|
||||
# function to parse arguments and disable fonts
|
||||
DISABLE_FONT() {
|
||||
EXITCODE=0 # exit code
|
||||
[ -z "$2" ] && DIE "You must specify a font to disable."
|
||||
disable_font() {
|
||||
exitcode=0 # exit code
|
||||
[ -z "$2" ] && die "You must specify a font to disable."
|
||||
|
||||
for i in $(seq "$ARGC"); do
|
||||
CARG="$(printf "%s\n" "$@" | sed -n "${i}","${i}"p)"
|
||||
COPT=disable
|
||||
ISNARG || continue
|
||||
for i in $(seq "$argc"); do
|
||||
carg="$(printf "%s\n" "$@" | sed -n "${i}","${i}"p)"
|
||||
copt=disable
|
||||
is_narg || continue
|
||||
|
||||
if [ "$isglobal" != "true" ]; then # user
|
||||
SELFONT="$(find "$FONTCTRL_BASEDIR_USER"/fonts/*"$CARG"* -type f 2>/dev/null | head -n 1)" # Head in case there are multiple matches
|
||||
BASESELFONT="$(basename "$SELFONT")"
|
||||
[ ! -e "$SELFONT" ] && EXITCODE=1 && STDERR "No fonts matching '$CARG' found." && continue
|
||||
MSG "Disabling font '$BASESELFONT' for $(whoami)"
|
||||
selfont="$(find "$FONTCTRL_BASEDIR_USER"/fonts/*"$carg"* -type f 2>/dev/null | head -n 1)" # Head in case there are multiple matches
|
||||
b_selfont="$(basename "$selfont")"
|
||||
[ ! -e "$selfont" ] && exitcode=1 && stderr "No fonts matching '$carg' found." && continue
|
||||
msg "Disabling font '$b_selfont' for $(whoami)"
|
||||
hi=true
|
||||
rm -f "$USERFONTDIR/fontctrl-fonts/$BASESELFONT" && MSG "Font '$SELFONT' disabled successfully." && continue
|
||||
rm -f "$USERFONTDIR/fontctrl-fonts/$b_selfont" && msg "Font '$selfont' disabled successfully." && continue
|
||||
exit 1
|
||||
else # global
|
||||
SELFONT="$(find "$FONTCTRL_BASEDIR_GLOBAL"/fonts/*"$CARG"* -type f 2>/dev/null | head -n 1)" # Head in case there are multiple matches
|
||||
BASESELFONT="$(basename "$SELFONT")"
|
||||
[ ! -e "$SELFONT" ] && EXITCODE=1 && STDERR "No fonts matching '$CARG' found." && continue
|
||||
MSG "Disabling font '$BASESELFONT' globally."
|
||||
selfont="$(find "$FONTCTRL_BASEDIR_GLOBAL"/fonts/*"$carg"* -type f 2>/dev/null | head -n 1)" # Head in case there are multiple matches
|
||||
b_selfont="$(basename "$selfont")"
|
||||
[ ! -e "$selfont" ] && exitcode=1 && stderr "No fonts matching '$carg' found." && continue
|
||||
msg "Disabling font '$b_selfont' globally."
|
||||
hi=true
|
||||
rm -f "$GLOBALFONTDIR/fontctrl-fonts/$BASESELFONT" && MSG "Font '$BASESELFONT' disabled successfully." && continue
|
||||
rm -f "$GLOBALFONTDIR/fontctrl-fonts/$b_selfont" && msg "Font '$b_selfont' disabled successfully." && continue
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
[ "$hi" != "true" ] && DIE "Font does not exist."
|
||||
return $EXITCODE # return the exit code
|
||||
[ "$hi" != "true" ] && die "Font does not exist."
|
||||
return $exitcode # return the exit code
|
||||
}
|
||||
|
||||
# list fonts
|
||||
LIST_FONT() {
|
||||
MSG "List of all installed fonts:"
|
||||
ls_font() {
|
||||
msg "List of all installed fonts:"
|
||||
[ "$isglobal" = "true" ] && basename "$(find "$FONTCTRL_BASEDIR_GLOBAL/fonts/" -type f)" || find "$FONTCTRL_BASEDIR_USER/fonts/" -type f -printf '%f\n'
|
||||
MSG "Use fontctrl enable/disable to enable/disable a font. See fontctrl help for more information." && return || exit 1
|
||||
msg "Use fontctrl enable/disable to enable/disable a font. See fontctrl help for more information." && return || exit 1
|
||||
}
|
||||
|
||||
# print version information
|
||||
PRINT_VER() {
|
||||
[ -z "$ARG3" ] || DIE "This option does not take a third argument."
|
||||
[ -n "$ARG2" ] && [ "$ARG2" != "--raw" ] && DIE "Invalid argument: '$ARG2'"
|
||||
[ "$ARG2" != "--raw" ] && MSG "fontctrl v$FONTCTRL_VER" || MSG "$FONTCTRL_VER"
|
||||
print_ver() {
|
||||
[ -z "$arg3" ] || die "This option does not take a third argument."
|
||||
[ -n "$arg2" ] && die "Invalid argument: '$arg2'"
|
||||
msg "$FONTCTRL_VER"
|
||||
}
|
||||
|
||||
# print license information
|
||||
PRINT_LICENSE() {
|
||||
[ -z "$ARG2" ] && MSG "fontctrl is free software, licensed under the GNU General Public License version 3.0. See https://codeberg.org/speedie/fontctrl for more information." || DIE "This option does not take an argument."
|
||||
print_license() {
|
||||
[ -z "$arg2" ] && msg "fontctrl is free software, licensed under the GNU General Public License version 3.0. See https://git.speedie.site/speedie/fontctrl for more information." || die "This option does not take an argument."
|
||||
}
|
||||
|
||||
# set everything up
|
||||
INIT() {
|
||||
main() {
|
||||
# convenient variables
|
||||
ARG="$*"
|
||||
ARG1="$1"
|
||||
ARG2="$2"
|
||||
ARG3="$3"
|
||||
arg="$*"
|
||||
arg1="$1"
|
||||
arg2="$2"
|
||||
arg3="$3"
|
||||
|
||||
CREATE_BASE "$@"
|
||||
mk "$@"
|
||||
|
||||
# arg count, this is used many times so why not set it here
|
||||
ARGC="$(printf "%s\n" "$@" | wc -l)"
|
||||
argc="$(printf "%s\n" "$@" | wc -l)"
|
||||
|
||||
case "$ARG1" in
|
||||
"install") ARG=recognized && INSTALL_FONT "$@" && exit 0 || exit 1 ;;
|
||||
"remove") ARG=recognized && REMOVE_FONT "$@" && exit 0 || exit 1 ;;
|
||||
"enable") ARG=recognized && ENABLE_FONT "$@" && exit 0 || exit 1 ;;
|
||||
"disable") ARG=recognized && DISABLE_FONT "$@" && exit 0 || exit 1 ;;
|
||||
"list") ARG=recognized && LIST_FONT "$@" && exit 0 || exit 1 ;;
|
||||
"help") ARG=recognized && LIST_ARGS "$@" && exit 0 || exit 1 ;;
|
||||
"version") ARG=recognized && PRINT_VER "$@" && exit 0 || exit 1 ;;
|
||||
"license") ARG=recognized && PRINT_LICENSE "$@" && exit 0 || exit 1 ;;
|
||||
"") ARG=recognized && LIST_ARGS "$@" && exit 0 || exit 1 ;;
|
||||
case "$arg1" in
|
||||
"install") arg=recognized && install_font "$@" && exit 0 || exit 1 ;;
|
||||
"remove") arg=recognized && rm_font "$@" && exit 0 || exit 1 ;;
|
||||
"enable") arg=recognized && enable_font "$@" && exit 0 || exit 1 ;;
|
||||
"disable") arg=recognized && disable_font "$@" && exit 0 || exit 1 ;;
|
||||
"list") arg=recognized && ls_font "$@" && exit 0 || exit 1 ;;
|
||||
"help") arg=recognized && ls_args "$@" && exit 0 || exit 1 ;;
|
||||
"version") arg=recognized && print_ver "$@" && exit 0 || exit 1 ;;
|
||||
"license") arg=recognized && print_license "$@" && exit 0 || exit 1 ;;
|
||||
"") arg=recognized && ls_args "$@" && exit 0 || exit 1 ;;
|
||||
esac
|
||||
|
||||
[ "$ARG" != "recognized" ] && MSG "Invalid argument: '$ARG1'" && DIE "Run fontctrl help or with no arguments for help."
|
||||
[ "$arg" != "recognized" ] && msg "Invalid argument: '$arg1'" && die "Run fontctrl help or with no arguments for help."
|
||||
}
|
||||
|
||||
# take stdin
|
||||
[ -p /proc/self/fd/0 ] && read STDIN && set -- "$@" $STDIN
|
||||
[ -p /proc/self/fd/0 ] && read stdin && set -- "$@" $stdin
|
||||
|
||||
INIT "$@"
|
||||
# ignore 2015, i don't think this will be a problem.
|
||||
# shellcheck disable=SC2015
|
||||
main "$@"
|
||||
|
|
19
options.mk
19
options.mk
|
@ -1,22 +1,3 @@
|
|||
# fontctrl
|
||||
# Minimal font manager for GNU/Linux.
|
||||
# https://codeberg.org/speedie/fontctrl
|
||||
#
|
||||
# Copyright (C) 2022-2023 speedie
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
VER = 1.3
|
||||
PREFIX = "/usr"
|
||||
NAME = fontctrl
|
||||
|
|
Loading…
Reference in a new issue