25 lines
733 B
Bash
25 lines
733 B
Bash
#!/usr/bin/env bash
|
|||
|
|
set -u
|
||
|
|
|
||
|
|
service=ollama.service
|
||
|
|
|
||
|
|
# The shared Waybar config is also used by hosts without Ollama.
|
||
|
|
if ! systemctl --user cat "$service" >/dev/null 2>&1; then
|
||
|
|
exit 0
|
||
|
|
fi
|
||
|
|
|
||
|
|
if [[ ${1:-} == toggle ]]; then
|
||
|
|
if systemctl --user is-active --quiet "$service"; then
|
||
|
|
systemctl --user stop "$service"
|
||
|
|
else
|
||
|
|
systemctl --user start "$service"
|
||
|
|
fi
|
||
|
|
exit $?
|
||
|
|
fi
|
||
|
|
|
||
|
|
if systemctl --user is-active --quiet "$service"; then
|
||
|
|
printf '%s\n' '{"text":"<span foreground=\"#9ece6a\">●</span> Local AI","tooltip":"Ollama is running. Click to stop it.","class":"running"}'
|
||
|
|
else
|
||
|
|
printf '%s\n' '{"text":"<span foreground=\"#f7768e\">●</span> Local AI","tooltip":"Ollama is stopped. Click to start it.","class":"stopped"}'
|
||
|
|
fi
|