From 82dcd59377f460bf28558af1b35d8c9091aae912 Mon Sep 17 00:00:00 2001 From: speedie Date: Tue, 1 Nov 2022 19:14:44 +0100 Subject: [PATCH] update stellar --- scripts/speedwm-stellar | 124 ++++++++++++++++++++++++++++------------ 1 file changed, 88 insertions(+), 36 deletions(-) diff --git a/scripts/speedwm-stellar b/scripts/speedwm-stellar index a65ae07..2a2ff03 100755 --- a/scripts/speedwm-stellar +++ b/scripts/speedwm-stellar @@ -211,7 +211,7 @@ esac # RAM usage ITEM1() { - module_ram --print & + module_ram --print if [ -e "/tmp/module_ram" ]; then cat /tmp/module_ram @@ -220,7 +220,7 @@ ITEM1() { # Time ITEM2() { - module_time --print & + module_time --print if [ -e "/tmp/module_time" ]; then cat /tmp/module_time @@ -229,7 +229,7 @@ ITEM2() { # Date ITEM3() { - module_date --print & + module_date --print if [ -e "/tmp/module_date" ]; then cat /tmp/module_date @@ -238,7 +238,7 @@ ITEM3() { # Volume ITEM4() { - module_vol --print & + module_vol --print if [ -e "/tmp/module_vol" ]; then cat /tmp/module_vol @@ -247,7 +247,7 @@ ITEM4() { # Weather ITEM5() { - module_weather --print & + module_weather --print if [ -e "/tmp/module_weather" ]; then cat /tmp/module_weather @@ -256,7 +256,7 @@ ITEM5() { # Network traffic ITEM6() { - module_net --print & + module_net --print if [ -e "/tmp/module_net" ]; then cat /tmp/module_net @@ -265,7 +265,7 @@ ITEM6() { # Dfmpeg status ITEM7() { - module_dfmpeg --print & + module_dfmpeg --print if [ -e "/tmp/module_dfmpeg" ]; then cat /tmp/module_dfmpeg @@ -274,7 +274,7 @@ ITEM7() { # CPU temp ITEM8() { - module_temp --print & + module_temp --print if [ -e "/tmp/module_temp" ]; then cat /tmp/module_temp @@ -283,7 +283,7 @@ ITEM8() { # mocp/cmus status ITEM9() { - module_music --print & + module_music --print if [ -e "/tmp/module_music" ]; then cat /tmp/module_music @@ -292,7 +292,7 @@ ITEM9() { # Newsboat unreads ITEM10() { - module_news --print & + module_news --print if [ -e "/tmp/module_news" ]; then cat /tmp/module_news @@ -301,7 +301,7 @@ ITEM10() { # Battery percentage/charging status ITEM11() { - module_bat --print & + module_bat --print if [ -e "/tmp/module_bat" ]; then cat /tmp/module_bat @@ -312,36 +312,88 @@ ITEM11() { ptext() { # Output of commands # We're doing this so we can manipulate them easily for various reasons. - itemcmd1="$(echo "$(ITEM1)" | sed ':a;N;$!ba;s/\n//g')" - itemcmd2="$(echo "$(ITEM2)" | sed ':a;N;$!ba;s/\n//g')" - itemcmd3="$(echo "$(ITEM3)" | sed ':a;N;$!ba;s/\n//g')" - itemcmd4="$(echo "$(ITEM4)" | sed ':a;N;$!ba;s/\n//g')" - itemcmd5="$(echo "$(ITEM5)" | sed ':a;N;$!ba;s/\n//g')" - itemcmd6="$(echo "$(ITEM6)" | sed ':a;N;$!ba;s/\n//g')" - itemcmd7="$(echo "$(ITEM7)" | sed ':a;N;$!ba;s/\n//g')" - itemcmd8="$(echo "$(ITEM8)" | sed ':a;N;$!ba;s/\n//g')" - itemcmd9="$(echo "$(ITEM9)" | sed ':a;N;$!ba;s/\n//g')" - itemcmd10="$(echo "$(ITEM10)" | sed ':a;N;$!ba;s/\n//g')" - itemcmd11="$(echo "$(ITEM11)" | sed ':a;N;$!ba;s/\n//g')" + if [ "$ENABLE_ITEM1" = "true" ]; then + if [ "$(cat /tmp/module_ram)" != "" ]; then + itemcmd1="$(echo "$(ITEM1)" | sed ':a;N;$!ba;s/\n//g')" + itemcmd1="$FSETCOLORCMD7$BSETCOLORCMD7 $itemcmd1" + fi + fi - # Add colors to them - itemcmd1="$FSETCOLORCMD7$BSETCOLORCMD7$itemcmd1" - itemcmd2="$FSETCOLORCMD11$BSETCOLORCMD11$itemcmd2" - itemcmd3="$FSETCOLORCMD10$BSETCOLORCMD10$itemcmd3" - itemcmd4="$FSETCOLORCMD8$BSETCOLORCMD8$itemcmd4" - itemcmd5="$FSETCOLORCMD3$BSETCOLORCMD3$itemcmd5" - itemcmd6="$FSETCOLORCMD6$BSETCOLORCMD6$itemcmd6" - itemcmd7="$FSETCOLORCMD5$BSETCOLORCMD5$itemcmd7" - itemcmd8="$FSETCOLORCMD4$BSETCOLORCMD4$itemcmd8" - itemcmd9="$FSETCOLORCMD2$BSETCOLORCMD2$itemcmd9" - itemcmd10="$FSETCOLORCMD9$BSETCOLORCMD9$itemcmd10" - itemcmd11="$FSETCOLORCMD8$BSETCOLORCMD8$itemcmd11" + if [ "$ENABLE_ITEM2" = "true" ]; then + if [ "$(cat /tmp/module_time)" != "" ]; then + itemcmd2="$(echo "$(ITEM2)" | sed ':a;N;$!ba;s/\n//g')" + itemcmd2="$FSETCOLORCMD11$BSETCOLORCMD11 $itemcmd2" + fi + fi + + if [ "$ENABLE_ITEM3" = "true" ]; then + if [ "$(cat /tmp/module_date)" != "" ]; then + itemcmd3="$(echo "$(ITEM3)" | sed ':a;N;$!ba;s/\n//g')" + itemcmd3="$FSETCOLORCMD10$BSETCOLORCMD10 $itemcmd3" + fi + fi + + if [ "$ENABLE_ITEM4" = "true" ]; then + if [ "$(cat /tmp/module_vol)" != "" ]; then + itemcmd4="$(echo "$(ITEM4)" | sed ':a;N;$!ba;s/\n//g')" + itemcmd4="$FSETCOLORCMD8$BSETCOLORCMD8 $itemcmd4" + fi + fi + + if [ "$ENABLE_ITEM5" = "true" ]; then + if [ "$(cat /tmp/module_weather)" != "" ]; then + itemcmd5="$(echo "$(ITEM5)" | sed ':a;N;$!ba;s/\n//g')" + itemcmd5="$FSETCOLORCMD3$BSETCOLORCMD3 $itemcmd5" + fi + fi + + if [ "$ENABLE_ITEM6" = "true" ]; then + if [ "$(cat /tmp/module_net)" != "" ]; then + itemcmd6="$(echo "$(ITEM6)" | sed ':a;N;$!ba;s/\n//g')" + itemcmd6="$FSETCOLORCMD6$BSETCOLORCMD6 $itemcmd6" + fi + fi + + if [ "$ENABLE_ITEM7" = "true" ]; then + if [ "$(cat /tmp/module_dfmpeg)" != "" ]; then + itemcmd7="$(echo "$(ITEM7)" | sed ':a;N;$!ba;s/\n//g')" + itemcmd7="$FSETCOLORCMD5$BSETCOLORCMD5 $itemcmd7" + fi + fi + + if [ "$ENABLE_ITEM8" = "true" ]; then + if [ "$(cat /tmp/module_temp)" != "" ]; then + itemcmd8="$(echo "$(ITEM8)" | sed ':a;N;$!ba;s/\n//g')" + itemcmd8="$FSETCOLORCMD4$BSETCOLORCMD4 $itemcmd8" + fi + fi + + if [ "$ENABLE_ITEM9" = "true" ]; then + if [ "$(cat /tmp/module_music)" != "" ]; then + itemcmd9="$(echo "$(ITEM9)" | sed ':a;N;$!ba;s/\n//g')" + itemcmd9="$FSETCOLORCMD2$BSETCOLORCMD2 $itemcmd9" + fi + fi + + if [ "$ENABLE_ITEM10" = "true" ]; then + if [ "$(cat /tmp/module_news)" != "" ]; then + itemcmd10="$(echo "$(ITEM10)" | sed ':a;N;$!ba;s/\n//g')" + itemcmd10="$FSETCOLORCMD9$BSETCOLORCMD9 $itemcmd10" + fi + fi + + if [ "$ENABLE_ITEM11" = "true" ]; then + if [ "$(cat /tmp/module_bat)" != "" ]; then + itemcmd11="$(echo "$(ITEM11)" | sed ':a;N;$!ba;s/\n//g')" + itemcmd11="$FSETCOLORCMD8$BSETCOLORCMD8 $itemcmd11" + fi + fi # Clickability if [ "$CLICKABLE" = "true" ]; then - ITEMS_TEXT="$(echo "$ITEM_ORDER" | sed "s|@10|\x10$itemcmd10|; s|@11|\x11$itemcmd11|; s|@1|\x01$itemcmd1|; s|@2|\x02$itemcmd2|; s|@3|\x03$itemcmd3|; s|@4|\x04$itemcmd4|; s|@5|\x05$itemcmd5|; s|@6|\x06$itemcmd6|; s|@7|\x07$itemcmd7|; s|@8|\x08$itemcmd8|; s|@9|\x09$itemcmd9|; s|%|%%|g")" + ITEMS_TEXT="$(echo "$ITEM_ORDER" | sed "s/^[[:space:]]*//g; s|@10|\x10$itemcmd10|; s|@11|\x11$itemcmd11|; s|@1|\x01$itemcmd1|; s|@2|\x02$itemcmd2|; s|@3|\x03$itemcmd3|; s|@4|\x04$itemcmd4|; s|@5|\x05$itemcmd5|; s|@6|\x06$itemcmd6|; s|@7|\x07$itemcmd7|; s|@8|\x08$itemcmd8|; s|@9|\x09$itemcmd9|; s|%|%%|g")" else - ITEMS_TEXT="$(echo "$ITEM_ORDER" | sed "s|@10|$itemcmd10|; s|@11|$itemcmd11|; s|@1|$itemcmd1|; s|@2|$itemcmd2|; s|@3|$itemcmd3|; s|@4|$itemcmd4|; s|@5|$itemcmd5|; s|@6|$itemcmd6|; s|@7|$itemcmd7|; s|@8|$itemcmd8|; s|@9|$itemcmd9|; s|%|%%|g")" + ITEMS_TEXT="$(echo "$ITEM_ORDER" | sed "s/^[[:space:]]*//g; s|@10|$itemcmd10|; s|@11|$itemcmd11|; s|@1|$itemcmd1|; s|@2|$itemcmd2|; s|@3|$itemcmd3|; s|@4|$itemcmd4|; s|@5|$itemcmd5|; s|@6|$itemcmd6|; s|@7|$itemcmd7|; s|@8|$itemcmd8|; s|@9|$itemcmd9|; s|%|%%|g")" fi # Auto-get character limit based on screen resolution