diff --git a/launchd/Library/LaunchAgents/com.hungryroot.celery.plist b/launchd/Library/LaunchAgents/com.hungryroot.celery.plist index 286eb25..37c2407 100644 --- a/launchd/Library/LaunchAgents/com.hungryroot.celery.plist +++ b/launchd/Library/LaunchAgents/com.hungryroot.celery.plist @@ -20,10 +20,6 @@ RunAtLoad - - KeepAlive - - WorkingDirectory /Users/colin.powell/src/github.com/hungryroot/hungryroot diff --git a/launchd/Library/LaunchAgents/com.hungryroot.django.plist b/launchd/Library/LaunchAgents/com.hungryroot.django.plist index 9b9ca39..1354fb1 100644 --- a/launchd/Library/LaunchAgents/com.hungryroot.django.plist +++ b/launchd/Library/LaunchAgents/com.hungryroot.django.plist @@ -19,10 +19,6 @@ RunAtLoad - - KeepAlive - - WorkingDirectory /Users/colin.powell/src/github.com/hungryroot/hungryroot diff --git a/launchd/Library/LaunchAgents/com.hungryroot.flower.plist b/launchd/Library/LaunchAgents/com.hungryroot.flower.plist index bc1175d..7b74795 100644 --- a/launchd/Library/LaunchAgents/com.hungryroot.flower.plist +++ b/launchd/Library/LaunchAgents/com.hungryroot.flower.plist @@ -20,10 +20,6 @@ RunAtLoad - - KeepAlive - - WorkingDirectory /Users/colin.powell/src/github.com/hungryroot/hungryroot diff --git a/swiftbar/.config/swfitbar/celery-toggle.3s.sh b/swiftbar/.config/swfitbar/celery-toggle.3s.sh new file mode 100755 index 0000000..1e77617 --- /dev/null +++ b/swiftbar/.config/swfitbar/celery-toggle.3s.sh @@ -0,0 +1,54 @@ +#!/bin/bash +set -euo pipefail + +# --- CONFIG --- +MATCH="manage.py runserver" +PLIST="$HOME/Library/LaunchAgents/com.hungyroot.celery.plist" +ICON="πŸ₯•" + +# --- Helpers --- +is_running() { + /bin/ps waux | /usr/bin/grep -F "$MATCH" | /usr/bin/grep -v grep >/dev/null 2>&1 +} + +# --- Menu bar title --- +if is_running; then + echo "$ICON 🟒" +else + echo "$ICON πŸ”΄" +fi + +echo "---" + +# --- Actions --- +if is_running; then + echo "Stop | bash='$0' param1=stop terminal=false refresh=true" + echo "Restart | bash='$0' param1=restart terminal=false refresh=true" +else + echo "Start | bash='$0' param1=start terminal=false refresh=true" +fi + +echo "---" +echo "Show matching processes | bash='$0' param1=ps terminal=true" +echo "Open plist | bash='/usr/bin/open' param1='$PLIST' terminal=false" + +# --- Handler --- +ACTION="${1:-}" +case "$ACTION" in +start) + /bin/launchctl bootstrap "gui/$(id -u)" "$PLIST" 2>/dev/null || true + /bin/launchctl kickstart -k "gui/$(id -u)/$(/usr/bin/plutil -extract Label raw -o - "$PLIST")" 2>/dev/null || true + ;; +stop) + # Kill only matching Celery runserver processes + /bin/ps waux | /usr/bin/grep -F "$MATCH" | /usr/bin/grep -v grep | /usr/bin/awk '{print $2}' | /usr/bin/xargs -r kill + ;; +restart) + "$0" stop + sleep 0.5 + "$0" start + ;; +ps) + /bin/ps waux | /usr/bin/grep -F "$MATCH" | /usr/bin/grep -v grep || echo "(no matches)" + ;; +esac diff --git a/swiftbar/.config/swfitbar/colima-toggle.3s.sh b/swiftbar/.config/swfitbar/colima-toggle.3s.sh new file mode 100755 index 0000000..fca7b4e --- /dev/null +++ b/swiftbar/.config/swfitbar/colima-toggle.3s.sh @@ -0,0 +1,64 @@ +#!/bin/bash +set -euo pipefail + +# --- CONFIG --- +ICON="🐳" +# Use your preferred match; consider "colima start" if "-f" isn't always present +MATCH='colima start -f' + +# If brew is not in PATH for SwiftBar, hardcode it: +BREW="/opt/homebrew/bin/brew" +[[ -x "$BREW" ]] || BREW="/usr/local/bin/brew" + +is_running() { + /bin/ps waux | /usr/bin/grep -F "$MATCH" | /usr/bin/grep -v grep >/dev/null 2>&1 +} + +pids() { + /bin/ps waux | /usr/bin/grep -F "$MATCH" | /usr/bin/grep -v grep | /usr/bin/awk '{print $2}' +} + +# --- Menu bar title --- +if is_running; then + echo "$ICON 🟒" +else + echo "$ICON πŸ”΄" +fi + +echo "---" + +# --- Actions --- +if is_running; then + echo "Stop (brew services) | bash='$0' param1=stop terminal=false refresh=true" + echo "Restart | bash='$0' param1=restart terminal=false refresh=true" +else + echo "Start (brew services) | bash='$0' param1=start terminal=false refresh=true" +fi + +echo "---" +echo "Debug (brew services info) | bash='$0' param1=info terminal=true" +echo "Show matching processes | bash='$0' param1=ps terminal=true" + +ACTION="${1:-}" +case "$ACTION" in +start) + "$BREW" services start colima || true + ;; +stop) + "$BREW" services stop colima || true + ;; +restart) + "$BREW" services restart colima || true + ;; +info) + echo "BREW: $BREW" + echo + "$BREW" services info colima 2>&1 || true + echo + echo "=== brew services list (filtered) ===" + "$BREW" services list 2>&1 | /usr/bin/grep -i colima || true + ;; +ps) + /bin/ps waux | /usr/bin/grep -F "$MATCH" | /usr/bin/grep -v grep || echo "(no matches)" + ;; +esac diff --git a/swiftbar/.config/swfitbar/django-toggle.3s.sh b/swiftbar/.config/swfitbar/django-toggle.3s.sh new file mode 100755 index 0000000..2cccf23 --- /dev/null +++ b/swiftbar/.config/swfitbar/django-toggle.3s.sh @@ -0,0 +1,77 @@ +#!/bin/bash +set -euo pipefail + + +PLIST="$HOME/Library/LaunchAgents/com.hungryroot.django.plist" +ICON="πŸ”Œ" +MATCH="manage.py runserver" + +LABEL="$(/usr/bin/plutil -extract Label raw -o - "$PLIST" 2>/dev/null || true)" +UID_NUM="$(/usr/bin/id -u)" +DOMAIN="gui/$UID_NUM" +TARGET="$DOMAIN/$LABEL" + +is_running() { + /bin/ps waux | /usr/bin/grep -F "$MATCH" | /usr/bin/grep -v grep >/dev/null 2>&1 +} + +pids() { + /bin/ps waux | /usr/bin/grep -F "$MATCH" | /usr/bin/grep -v grep | /usr/bin/awk '{print $2}' +} + +# --- Title --- +if is_running; then + echo "$ICON 🟒" +else + echo "$ICON πŸ”΄" +fi + +echo "---" + +if is_running; then + echo "Stop | bash='$0' param1=stop terminal=false refresh=true" + echo "Restart | bash='$0' param1=restart terminal=false refresh=true" +else + echo "Start | bash='$0' param1=start terminal=false refresh=true" +fi + +echo "---" +echo "Open http://0.0.0.0:8000 | href=http://0.0.0.0:8000" +echo "Debug | bash='$0' param1=debug terminal=true" +echo "Open plist | bash='/usr/bin/open' param1='$PLIST' terminal=false" + +ACTION="${1:-}" +case "$ACTION" in +start) + [[ -n "${LABEL:-}" ]] || { + echo "ERROR: couldn't read Label from $PLIST" >&2 + exit 1 + } + /bin/launchctl bootstrap "$DOMAIN" "$PLIST" 2>/dev/null || true + /bin/launchctl kickstart -k "$TARGET" 2>/dev/null || true + ;; +stop) + # THIS is the important part: unload the LaunchAgent so it won’t restart. + [[ -n "${LABEL:-}" ]] || exit 0 + /bin/launchctl bootout "$TARGET" 2>/dev/null || true + + # Optional cleanup: kill any remaining process that matches + pids | /usr/bin/xargs -r kill -TERM 2>/dev/null || true + ;; +restart) + "$0" stop + sleep 0.5 + "$0" start + ;; +debug) + echo "PLIST: $PLIST" + echo "LABEL: $LABEL" + echo "TARGET: $TARGET" + echo + echo "=== launchctl print (may fail in SwiftBar, still useful) ===" + /bin/launchctl print "$TARGET" 2>&1 || true + echo + echo "=== matching processes ===" + /bin/ps waux | /usr/bin/grep -F "$MATCH" | /usr/bin/grep -v grep || echo "(no matches)" + ;; +esac