From d5081812ae5c92a83dd48cf6625a2f7e05f881a7 Mon Sep 17 00:00:00 2001 From: Fluffy-Bean Date: Mon, 11 Jul 2022 20:53:54 +0100 Subject: [PATCH] Server Status thingy --- polybar/config.ini | 8 ++++---- polybar/left_roundy.ini | 6 ++++++ polybar/right_roundy.ini | 6 ++++++ polybar/scripts/server_status.sh | 32 ++++++++++++++++++++++++++++++++ polybar/space.ini | 5 +++++ polybar/user_modules.ini | 13 +++++++++++++ 6 files changed, 66 insertions(+), 4 deletions(-) create mode 100755 polybar/scripts/server_status.sh diff --git a/polybar/config.ini b/polybar/config.ini index cff3ef0..9806bce 100644 --- a/polybar/config.ini +++ b/polybar/config.ini @@ -51,17 +51,17 @@ foreground = ${colors.foreground} font-0 = Rubik:size=11:weight=Medium;2 font-1 = Iosevka Nerd Font:size=18;4 font-2 = Material:size=13;3 -font-3 = Material:size=13;2 +font-3 = Material:size=13;1 ;;_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_- ;; BAR SETUP ;;_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_- -modules-left = dateL date dateR space timeL time timeR +modules-left = dateL date dateR space timeL time timeR space1 serverL servers serverR modules-center = spotifyL spotify spotifyR -modules-right = sysiconL dnd updates network bluetooth sysiconR space1 volumeL volume volumeR space2 powerL power powerR +modules-right = sysiconL dnd updates network bluetooth sysiconR space2 volumeL volume volumeR space3 powerL power powerR -;; Theres also dnd and mic modules that I don't really use +;; Theres also dnd and mic modules that I don't use so much ;;_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_- diff --git a/polybar/left_roundy.ini b/polybar/left_roundy.ini index 9b03dd9..f796e8a 100644 --- a/polybar/left_roundy.ini +++ b/polybar/left_roundy.ini @@ -13,6 +13,12 @@ content-background = ${colors.sepback} content-foreground = ${colors.modback} content = "%{T2}%{T-}" +[module/serverL] +type = custom/text +content-background = ${colors.sepback} +content-foreground = ${colors.modback} +content = "%{T2}%{T-}" + [module/spotifyL] type = custom/text content-background = ${colors.background} diff --git a/polybar/right_roundy.ini b/polybar/right_roundy.ini index 0126e53..15f598f 100644 --- a/polybar/right_roundy.ini +++ b/polybar/right_roundy.ini @@ -9,6 +9,12 @@ content = "%{T2}%{T-}" [module/timeR] type = custom/text +content-background = ${colors.sepback} +content-foreground = ${colors.modback} +content = "%{T2}%{T-}" + +[module/serverR] +type = custom/text content-background = ${colors.background} content-foreground = ${colors.modback} content = "%{T2}%{T-}" diff --git a/polybar/scripts/server_status.sh b/polybar/scripts/server_status.sh new file mode 100755 index 0000000..7b94047 --- /dev/null +++ b/polybar/scripts/server_status.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +#Script made by Fluffy, use/modify to your needs! +#Twitter: fluffybeanUwU +#Website: gay.fluffybean.gay +#GitHub: Fluffy-Bean + +server_list=$(cat ~/.config/polybar/scripts/server_list.txt) +server_status=() + +for server in $server_list +do + ip=$(ping -W 1 -c 1 -4 $server) + if [ $(echo $ip | grep "1 received" | wc -c) -eq 0 ] + then + server_status+=("%{F#666}%{F-}") + else + if [ $(echo $ip | grep "0% packet loss" | wc -c) -eq 0 ] + then + server_status+=("%{F#B66467}%{F-}") + else + server_status+=("") + fi + fi +done + +if [ $(echo $server_status | wc -c) -eq 0 ] +then + echo "Error: No servers/IPs in server_list.txt" +else + echo "${server_status[*]}" +fi diff --git a/polybar/space.ini b/polybar/space.ini index 8968922..9c25dc0 100644 --- a/polybar/space.ini +++ b/polybar/space.ini @@ -15,3 +15,8 @@ content = " " type = custom/text content-background = ${colors.sepback} content = " " + +[module/space3] +type = custom/text +content-background = ${colors.sepback} +content = " " diff --git a/polybar/user_modules.ini b/polybar/user_modules.ini index 6fe2d4f..4a815e2 100644 --- a/polybar/user_modules.ini +++ b/polybar/user_modules.ini @@ -26,6 +26,19 @@ label = "%time%" format-background = ${colors.modback} +;;_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_- +;; Servers +;;_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_- +[module/servers] +type = custom/script +interval = 5 + +format-background = ${colors.modback} +;format-padding = 1 + +exec = ~/.config/polybar/scripts/server_status.sh + + ;;_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_- ;; SPOTIFY ;;_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-