Files

113 lines
3.0 KiB
Bash
Raw Permalink Normal View History

2026-09-18 09:17:14 -04:00
#!/usr/bin/env bash
# Link the front ends into place. Nothing is copied, so a `git pull` updates
# what you are running.
set -euo pipefail
src="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
config="${XDG_CONFIG_HOME:-$HOME/.config}"
binhome="${HOME}/.local/bin"
usage() {
cat <<USAGE
2026-09-18 10:52:56 -04:00
menologion-install [quickshell|waybar|eww|bin|all]
2026-09-18 09:17:14 -04:00
2026-09-18 10:52:56 -04:00
quickshell link quickshell/ into a quickshell config as menologion/
2026-09-18 09:17:14 -04:00
waybar link the bar script and print the module to merge
eww link eww/ into your eww config
2026-09-18 10:52:56 -04:00
bin link menologion-waybar into ~/.local/bin
2026-09-18 09:17:14 -04:00
all bin + whichever of the three are already configured
USAGE
}
2026-09-18 10:29:37 -04:00
# Set when something was skipped, so the run can report it in its exit status
# without `set -e` tearing the rest of the install down.
skipped=0
2026-09-18 09:17:14 -04:00
link() {
local from="$1" to="$2"
mkdir -p "$(dirname "$to")"
if [ -e "$to" ] && [ ! -L "$to" ]; then
echo " ! $to exists and is not a link — leaving it alone" >&2
2026-09-18 10:29:37 -04:00
skipped=1
return 0
2026-09-18 09:17:14 -04:00
fi
ln -sfn "$from" "$to"
echo " $to -> $from"
}
do_bin() {
2026-09-18 10:52:56 -04:00
link "$src/bin/menologion-waybar" "$binhome/menologion-waybar"
2026-09-18 09:17:14 -04:00
case ":$PATH:" in
*":$binhome:"*) ;;
*) echo " note: $binhome is not on your PATH" >&2 ;;
esac
}
do_quickshell() {
2026-09-18 10:52:56 -04:00
link "$src/quickshell" "$config/quickshell/menologion"
2026-09-18 09:17:14 -04:00
cat <<'NOTE'
Add to your shell.qml:
2026-09-18 10:52:56 -04:00
import qs.menologion.modules
2026-09-18 09:17:14 -04:00
...
2026-09-18 10:52:56 -04:00
Menologion {}
2026-09-18 09:17:14 -04:00
Or run it on its own:
2026-09-18 10:52:56 -04:00
quickshell -p ~/.config/quickshell/menologion/shell.qml
2026-09-18 09:17:14 -04:00
NOTE
}
do_waybar() {
2026-09-18 10:52:56 -04:00
link "$src/waybar/style.css" "$config/waybar/menologion.css"
2026-09-18 09:17:14 -04:00
cat <<'NOTE'
Add "custom/typikon" to a modules list, merge waybar/config.jsonc into
2026-09-18 10:52:56 -04:00
your config, and @import "menologion.css" from your style.css.
2026-09-18 09:17:14 -04:00
NOTE
}
do_eww() {
2026-09-18 10:52:56 -04:00
link "$src/eww" "$config/eww/menologion"
2026-09-18 09:17:14 -04:00
cat <<'NOTE'
2026-09-18 10:52:56 -04:00
Add to your eww.yuck: (include "menologion/menologion.yuck")
Add to your eww.scss: @import "menologion/menologion.scss";
Then put (menologion) in a window, or (menologion-bar) in a bar.
2026-09-18 09:17:14 -04:00
NOTE
}
2026-09-18 10:29:37 -04:00
require_typikon() {
command -v typikon >/dev/null 2>&1 && return 0
2026-09-18 10:52:56 -04:00
echo "menologion: typikon is not on PATH." >&2
echo " cargo install --git https://git.pumpin.online/funkpower/typikon" >&2
2026-09-18 09:17:14 -04:00
exit 1
}
2026-09-18 10:29:37 -04:00
# --help must not be gated behind the dependency it tells you about.
case "${1:-all}" in
-h|--help|help) usage; exit 0 ;;
esac
require_typikon
2026-09-18 09:17:14 -04:00
case "${1:-all}" in
quickshell) do_bin; do_quickshell ;;
waybar) do_bin; do_waybar ;;
eww) do_bin; do_eww ;;
bin) do_bin ;;
all)
do_bin
2026-09-18 10:29:37 -04:00
# `[ -d x ] && f` as the last statement of the script would make a
# perfectly good run exit 1 under `set -e` whenever the directory is
# absent. Hence the `|| true`, and the explicit exit below.
[ -d "$config/quickshell" ] && do_quickshell || true
[ -d "$config/waybar" ] && do_waybar || true
[ -d "$config/eww" ] && do_eww || true
2026-09-18 09:17:14 -04:00
;;
*) usage; exit 2 ;;
esac
2026-09-18 10:29:37 -04:00
exit "$skipped"