]> git.r.bdr.sh - rbdr/r.bdr.sh/blob - swiftbar/monitorcito.1m.sh
Add fediverse creator meta tag
[rbdr/r.bdr.sh] / swiftbar / monitorcito.1m.sh
1 #!/usr/bin/env bash
2 # This plugin lists your monitorcito entries, with an overview if they're ok or
3 # not.
4 #
5 # <xbar.title>Monitorcito Status</xbar.title>
6 # <xbar.version>v1.0.0</xbar.version>
7 # <xbar.author>Rubén Beltrán del Río</xbar.author>
8 # <xbar.desc>Shows the status of your running services via monitorcito.</xbar.desc>
9 # <xbar.dependencies>curl,jq</xbar.dependencies>
10 # <xbar.abouturl>https://r.bdr.sh/swiftbar_scripts.html</xbar.abouturl>
11 # <xbar.var>string(VAR_MONITORCITO_URL): Your monitorcito API URL.</xbar.var>
12 # <xbar.var>string(VAR_RUN_ON_FOCUS): Focus in which to run.</xbar.var>
13 # <xbar.var>string(VAR_HALT_ON_FOCUS): Focus in which to halt.</xbar.var>
14 # <swiftbar.hideRunInTerminal>true</swiftbar.hideRunInTerminal>
15 # <swiftbar.environment>VAR_MONITORCITO_URL=no, VAR_RUN_ON_FOCUS=, VAR_HALT_ON_FOCUS=</swiftbar.environment>
16
17 ###############################################################################
18 # The Variables
19 ###############################################################################
20 VAR_MONITORCITO_URL=${VAR_MONITORCITO_URL:-'https://monitor.srv.bdr.sh/api'}
21 VAR_RUN_ON_FOCUS=
22 VAR_HALT_ON_FOCUS=
23
24 ###############################################################################
25 # Focus Check
26 ###############################################################################
27
28 if [[ -f "${BASH_SOURCE%/*}/focus.utils.sh" ]]; then
29 source "${BASH_SOURCE%/*}/focus.utils.sh"
30 focus_check
31 fi
32
33 ###############################################################################
34 # The Code
35 ###############################################################################
36
37 curl \
38 -H 'Content-Type: application/json' \
39 $VAR_MONITORCITO_URL 2>/dev/null | \
40 jq -r '(if (. | to_entries | map(.value) | all) then ":circle:" else ":xmark:" end), "---",
41 (to_entries | .[] | "\(.key) \(if .value then ":circle:" else ":xmark:" end)" + " | refresh=true")'