#!/bin/sh # MacSweat installer - https://macsweat.parthh.dev # # curl -fsSL https://macsweat.parthh.dev/install | sh # # Downloads MacSweat from GitHub Releases, checks it against the SHA-256 below, installs it to # /Applications (or ~/Applications if you can't write to /Applications) and opens it. # Run it again to update. Everything happens inside main(), so a partly downloaded script does nothing. # Keep this file plain ASCII: macOS's sh (bash 3.2) reads the first byte of a non-ASCII character # as part of a variable name when it follows one directly, e.g. "$VERSION" then an ellipsis. set -eu VERSION="1.0.0" SHA256="38ce42bf701ba22641422adf4cf33d8c910a3c7b880a2b76b76a2c387d8706a3" URL="${MACSWEAT_DOWNLOAD_URL:-https://github.com/Parrtth/macsweat/releases/download/v$VERSION/MacSweat.zip}" say() { printf '%s\n' "$*"; } fail() { printf 'MacSweat: %s\n' "$*" >&2; exit 1; } main() { [ "$(uname -s)" = "Darwin" ] || fail "MacSweat is a Mac app, and this isn't a Mac." macos=$(sw_vers -productVersion) [ "${macos%%.*}" -ge 13 ] || fail "MacSweat needs macOS 13 Ventura or later (this Mac has $macos)." tmp=$(mktemp -d) trap 'rm -rf "$tmp"' EXIT INT TERM say "Downloading MacSweat ${VERSION}..." curl -fsSL --retry 2 "$URL" -o "$tmp/MacSweat.zip" || fail "couldn't download $URL" actual=$(shasum -a 256 "$tmp/MacSweat.zip" | awk '{print $1}') [ "$actual" = "$SHA256" ] || fail "the download doesn't match its checksum, so nothing was installed. expected $SHA256 got $actual" say "Verified SHA-256: $actual" ditto -x -k "$tmp/MacSweat.zip" "$tmp/unpacked" [ -d "$tmp/unpacked/MacSweat.app" ] || fail "the download didn't contain MacSweat.app." dest=/Applications if [ ! -w "$dest" ]; then dest="$HOME/Applications" mkdir -p "$dest" fi if pgrep -x MacSweat >/dev/null 2>&1; then say "Quitting the running copy..." pkill -x MacSweat 2>/dev/null || true tries=0 while pgrep -x MacSweat >/dev/null 2>&1 && [ "$tries" -lt 20 ]; do sleep 0.25; tries=$((tries + 1)); done fi rm -rf "$dest/MacSweat.app" ditto "$tmp/unpacked/MacSweat.app" "$dest/MacSweat.app" say "Installed $dest/MacSweat.app" open "$dest/MacSweat.app" say "" say "MacSweat is running - look for the little sweating face in your menu bar." say "If you don't see it on macOS 26 or later, allow MacSweat in System Settings > Menu Bar." say "Update: run this command again. Uninstall: curl -fsSL https://macsweat.parthh.dev/uninstall | sh" } main "$@"