power menu, redshift, polybar
This commit is contained in:
31
.config/polybar/scripts/info-healthchecks.io/README.md
Normal file
31
.config/polybar/scripts/info-healthchecks.io/README.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# Script: info-healthchecks.io
|
||||
|
||||
Shows the health of your services registered with [healthchecks.io](https://healthchecks.io).
|
||||
|
||||

|
||||
|
||||
|
||||
## Dependencies
|
||||
|
||||
* `jq`
|
||||
* `curl`
|
||||
|
||||
|
||||
## Configuration
|
||||
|
||||
Modify any of the all-caps variables to configure the script:
|
||||
* `API_KEY`: Your [healthchecks.io](https://healthchecks.io) API key. These are project specific and can be generated on the project settings page.
|
||||
* `CHECK_ENDPOINT`: URL of the checks API endpoint. Change if self-hosting.
|
||||
* `STATES`: Array of states to monitor. Available options: `"up" "down" "new" "pending" "grace" "started" "paused"`
|
||||
* `COLORS`: Associative array that maps a color to each configured state. Defaults to white (#ffffff).
|
||||
* `SHOWN_TAGS`: Array of tags to show. Leave empty to disable filtering based on tags.
|
||||
|
||||
|
||||
## Module
|
||||
|
||||
```ini
|
||||
[module/info-healthchecks.io]
|
||||
type = custom/script
|
||||
exec = ~/polybar-scripts/info-healthchecks.io.sh
|
||||
interval = 60
|
||||
```
|
||||
@@ -0,0 +1,49 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Your API Key
|
||||
API_KEY=""
|
||||
# URL of the checks api endpoint. Change if self-hosting the service.
|
||||
CHECK_ENDPOINT="https://healthchecks.io/api/v1/checks/"
|
||||
|
||||
# States to track
|
||||
# Available options: up down new pending grace started paused
|
||||
STATES=("up" "down")
|
||||
# Color of each state. Defaults to white (#ffffff).
|
||||
declare -A COLORS=( [up]="#7cfc00" [down]="#ff0000" )
|
||||
# Leave empty to show all tags
|
||||
SHOWN_TAGS=()
|
||||
|
||||
function build_url {
|
||||
url=$CHECK_ENDPOINT
|
||||
next_sep="?"
|
||||
for tag in "${SHOWN_TAGS[@]}"; do
|
||||
url+="${next_sep}tag=${tag}"
|
||||
next_sep="&"
|
||||
done
|
||||
echo "$url"
|
||||
}
|
||||
|
||||
response=$(curl --silent --header "X-Api-Key: ${API_KEY}" "$(build_url)")
|
||||
|
||||
declare -A stati
|
||||
|
||||
for status in "up" "down"; do
|
||||
stati[$status]=0
|
||||
done
|
||||
|
||||
for status in $(echo "$response" | jq -r '.checks[].status'); do
|
||||
stati[$status]=$((stati[$status] + 1))
|
||||
done
|
||||
|
||||
output=""
|
||||
for status in "${STATES[@]}"; do
|
||||
count=${stati[$status]}
|
||||
if [ ${COLORS[$status]+_} ]; then
|
||||
color=${COLORS[$status]}
|
||||
else
|
||||
color="#ffffff"
|
||||
fi
|
||||
output+="|%{F${color}}${count}%{F-}"
|
||||
done
|
||||
|
||||
echo "${output:1}"
|
||||
BIN
.config/polybar/scripts/info-healthchecks.io/screenshots/1.png
Normal file
BIN
.config/polybar/scripts/info-healthchecks.io/screenshots/1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 576 B |
Reference in New Issue
Block a user