From f3c10b52d5b360d0b37b80aebb3929cac15799dd Mon Sep 17 00:00:00 2001 From: Joachim Nielandt Date: Wed, 15 Jul 2020 15:30:25 +0200 Subject: [PATCH] Added obelisk status module --- dot_dotfiles/polybar/config.tmpl | 8 +++++++- scripts/.keep | 0 scripts/executable_obelisk.status.sh | 21 +++++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 scripts/.keep create mode 100644 scripts/executable_obelisk.status.sh diff --git a/dot_dotfiles/polybar/config.tmpl b/dot_dotfiles/polybar/config.tmpl index 89e8250..c0e1566 100644 --- a/dot_dotfiles/polybar/config.tmpl +++ b/dot_dotfiles/polybar/config.tmpl @@ -100,7 +100,7 @@ monitor = ${env:MONITOR:eDP-1} ;border-right-size = 16 ;unused modules - mpd xbacklight backlight-acpi alsa modules-left = i3 -modules-center = temperature battery xkeyboard memory cpu filesystem updates-arch reboot-check xbacklight top-process +modules-center = temperature battery xkeyboard memory cpu filesystem updates-arch reboot-check xbacklight top-process obelisk-status modules-right = net wifi0 vpn powermenu ; TRAY MANAGEMENT @@ -150,6 +150,12 @@ format-prefix-foreground = ${colors.bright_green} exec = ~/.config/polybar/polybar-scripts/polybar-scripts/info-hackspeed/info-hackspeed.sh tail = true +[module/obelisk-status] +type = custom/script +exec = ~/scripts/obelisk.status.sh +tail = false +interval = 10 + [module/top-process] type = custom/script format-prefix = " " diff --git a/scripts/.keep b/scripts/.keep new file mode 100644 index 0000000..e69de29 diff --git a/scripts/executable_obelisk.status.sh b/scripts/executable_obelisk.status.sh new file mode 100644 index 0000000..b31fb7f --- /dev/null +++ b/scripts/executable_obelisk.status.sh @@ -0,0 +1,21 @@ +#!/bin/bash +STATUSURL=https://obelisk.ilabt.imec.be/api/v2/status +STATUS=$(curl -s $STATUSURL | jq -r '.status') + +# colors +HEALTHY="#b8bb26" +DEGRADED="#fe8019" +FAILED="#fb4934" +UNKNOWN="#928374" + +# echo the status in polybar format +# the {F}x{F-} syntax allows you to color stuff +if [ $STATUS = "healthy" ]; then + echo "%{F$HEALTHY} %{F-} obelisk" +elif [ $STATUS = "degraded" ]; then + echo "%{F$DEGRADED} %{F-} obelisk" +elif [ $STATUS = "failed" ]; then + echo "%{F$FAILED} %{F-} obelisk" +else + echo "%{F$UNKNOWN} %{F-} obelisk" +fi