about summary refs log tree commit diff stats
path: root/home-manager/config/yambar/scripts
diff options
context:
space:
mode:
authorene <ene@sils.li>2023-03-04 15:00:11 +0100
committerene <ene@sils.li>2023-03-04 15:00:11 +0100
commit6e77d5a081004fb9fe0d47950bd031119c29e9c2 (patch)
treef78b0e14b4ce94330a734daa0987b2d1b4a9f911 /home-manager/config/yambar/scripts
parentFix(hm/alacritty): Config (diff)
downloadnixos-config-6e77d5a081004fb9fe0d47950bd031119c29e9c2.tar.gz
nixos-config-6e77d5a081004fb9fe0d47950bd031119c29e9c2.zip
Feat(hm/config/yambar): Update the scripts and better paths
Diffstat (limited to '')
-rw-r--r--home-manager/config/yambar/scripts/disk.sh26
-rw-r--r--home-manager/config/yambar/scripts/grades-average.sh15
-rw-r--r--home-manager/config/yambar/scripts/network.sh53
-rwxr-xr-xhome-manager/config/yambar/scripts/old/amixer-monitor (renamed from home-manager/config/yambar/scripts/amixer-monitor)0
-rwxr-xr-xhome-manager/config/yambar/scripts/old/cpu (renamed from home-manager/config/yambar/scripts/cpu)0
-rwxr-xr-xhome-manager/config/yambar/scripts/old/dfspace (renamed from home-manager/config/yambar/scripts/dfspace)0
-rwxr-xr-xhome-manager/config/yambar/scripts/old/grades-average (renamed from home-manager/config/yambar/scripts/grades-average)0
-rwxr-xr-xhome-manager/config/yambar/scripts/old/meminfo (renamed from home-manager/config/yambar/scripts/meminfo)0
-rwxr-xr-xhome-manager/config/yambar/scripts/old/nmclitest (renamed from home-manager/config/yambar/scripts/nmclitest)0
-rwxr-xr-xhome-manager/config/yambar/scripts/old/pingtest (renamed from home-manager/config/yambar/scripts/pingtest)0
-rwxr-xr-xhome-manager/config/yambar/scripts/old/yambar-tray (renamed from home-manager/config/yambar/scripts/yambar-tray)0
-rwxr-xr-xhome-manager/config/yambar/scripts/old/yambar-tray-width (renamed from home-manager/config/yambar/scripts/yambar-tray-width)0
-rw-r--r--home-manager/config/yambar/scripts/sound-volume.sh22
13 files changed, 116 insertions, 0 deletions
diff --git a/home-manager/config/yambar/scripts/disk.sh b/home-manager/config/yambar/scripts/disk.sh
new file mode 100644
index 00000000..568ac71e
--- /dev/null
+++ b/home-manager/config/yambar/scripts/disk.sh
@@ -0,0 +1,26 @@
+#! /usr/bin/env dash
+# shellcheck disable=SC2086
+# shellcheck source=/dev/null
+# . ~/.local/lib/shell/lib
+. %SHELL_LIBRARY_PATH
+
+
+# Main loop
+while true; do
+    # vars
+    used_space=$(btrfs filesystem usage / 2> /dev/null | awk '{if ( /Used:/ ) { print $2 } } ' | head -n1)
+    all_space=$(btrfs filesystem usage / 2> /dev/null | awk '{if ( /Device size:/ ) { print $3 } } ' | head -n1 | tr -d "GiB")
+
+
+  # Check space available (4) and percentage used (5)
+  spaceperc=$(echo "$(echo "$used_space" | tr -d "GiB" )"  "$all_space"  | awk '{div=$1/$2;div *= 100; printf"%2d%%\n",div }')
+
+  echo "diskspace|string|$used_space"
+  echo "diskperc|string|$spaceperc"
+  echo ""
+  sleep 1
+done
+
+
+
+# vim: ft=sh
diff --git a/home-manager/config/yambar/scripts/grades-average.sh b/home-manager/config/yambar/scripts/grades-average.sh
new file mode 100644
index 00000000..72e180bd
--- /dev/null
+++ b/home-manager/config/yambar/scripts/grades-average.sh
@@ -0,0 +1,15 @@
+#!/usr/bin/env dash
+# shellcheck disable=SC2086
+# shellcheck source=/dev/null
+. %SHELL_LIBRARY_PATH
+
+
+while true; do
+    grade=$(grades list average | awk '{print $2}');
+
+    echo "grade|string|$grade";
+    echo "";
+
+    sleep 1;
+done
+# vim: ft=sh
diff --git a/home-manager/config/yambar/scripts/network.sh b/home-manager/config/yambar/scripts/network.sh
new file mode 100644
index 00000000..9d797e15
--- /dev/null
+++ b/home-manager/config/yambar/scripts/network.sh
@@ -0,0 +1,53 @@
+#! /usr/bin/env dash
+# shellcheck disable=SC2086
+# shellcheck source=/dev/null
+#. ~/.local/lib/shell/lib
+. %SHELL_LIBRARY_PATH
+
+LIB_TEMP_DIR_FOR_SCRIPT=$(mktemp -d)
+
+retest=120
+retest_if_con_fails=10
+backend=nmcli
+
+case "$backend" in
+    "nmcli") # Test for connectivity with nmcli
+        while true; do
+            connection_status=$(nmcli networking connectivity)
+            if [ "$connection_status" = "full" ]; then
+                echo "internet|string|Connected"
+                echo ""
+                sleep $retest
+            else
+                echo "internet|string|Disconnected"
+                echo ""
+                sleep $retest_if_con_fails
+            fi
+        done
+        ;;
+    "ping") # Test for connectivity with ping
+        ip_address='8.8.8.8'
+        ping_number=3
+
+        while true; do
+
+            ping_result=$(mktmp)
+            ping $ip_address -c $ping_number -q | awk 'BEGIN {FS="/"} END {print $5}' > $ping_result
+
+            if [ "$(cat $ping_result | wc -l)" -eq 0 ]; then
+                echo "med|string|No connection"
+                echo ""
+                sleep $retest_if_con_fails
+            else
+                echo "med|string|$(cat $ping_result) ms"
+                echo ""
+                sleep $retest
+            fi
+        done
+        ;;
+esac
+
+
+
+if [ -d "$LIB_TEMP_DIR_FOR_SCRIPT" ];then rm -r "$LIB_TEMP_DIR_FOR_SCRIPT"; fi
+# vim: ft=sh
diff --git a/home-manager/config/yambar/scripts/amixer-monitor b/home-manager/config/yambar/scripts/old/amixer-monitor
index 9e75acfa..9e75acfa 100755
--- a/home-manager/config/yambar/scripts/amixer-monitor
+++ b/home-manager/config/yambar/scripts/old/amixer-monitor
diff --git a/home-manager/config/yambar/scripts/cpu b/home-manager/config/yambar/scripts/old/cpu
index bae820d0..bae820d0 100755
--- a/home-manager/config/yambar/scripts/cpu
+++ b/home-manager/config/yambar/scripts/old/cpu
diff --git a/home-manager/config/yambar/scripts/dfspace b/home-manager/config/yambar/scripts/old/dfspace
index 0b262481..0b262481 100755
--- a/home-manager/config/yambar/scripts/dfspace
+++ b/home-manager/config/yambar/scripts/old/dfspace
diff --git a/home-manager/config/yambar/scripts/grades-average b/home-manager/config/yambar/scripts/old/grades-average
index a04b958c..a04b958c 100755
--- a/home-manager/config/yambar/scripts/grades-average
+++ b/home-manager/config/yambar/scripts/old/grades-average
diff --git a/home-manager/config/yambar/scripts/meminfo b/home-manager/config/yambar/scripts/old/meminfo
index 0156e94c..0156e94c 100755
--- a/home-manager/config/yambar/scripts/meminfo
+++ b/home-manager/config/yambar/scripts/old/meminfo
diff --git a/home-manager/config/yambar/scripts/nmclitest b/home-manager/config/yambar/scripts/old/nmclitest
index 3e8bc73a..3e8bc73a 100755
--- a/home-manager/config/yambar/scripts/nmclitest
+++ b/home-manager/config/yambar/scripts/old/nmclitest
diff --git a/home-manager/config/yambar/scripts/pingtest b/home-manager/config/yambar/scripts/old/pingtest
index 2b5f9998..2b5f9998 100755
--- a/home-manager/config/yambar/scripts/pingtest
+++ b/home-manager/config/yambar/scripts/old/pingtest
diff --git a/home-manager/config/yambar/scripts/yambar-tray b/home-manager/config/yambar/scripts/old/yambar-tray
index 1704c6dd..1704c6dd 100755
--- a/home-manager/config/yambar/scripts/yambar-tray
+++ b/home-manager/config/yambar/scripts/old/yambar-tray
diff --git a/home-manager/config/yambar/scripts/yambar-tray-width b/home-manager/config/yambar/scripts/old/yambar-tray-width
index 00544e70..00544e70 100755
--- a/home-manager/config/yambar/scripts/yambar-tray-width
+++ b/home-manager/config/yambar/scripts/old/yambar-tray-width
diff --git a/home-manager/config/yambar/scripts/sound-volume.sh b/home-manager/config/yambar/scripts/sound-volume.sh
new file mode 100644
index 00000000..8fc0107f
--- /dev/null
+++ b/home-manager/config/yambar/scripts/sound-volume.sh
@@ -0,0 +1,22 @@
+#! /usr/bin/env dash
+# shellcheck disable=SC2086
+# shellcheck source=/dev/null
+# . ~/.local/lib/shell/lib
+. %SHELL_LIBRARY_PATH
+
+while true; do
+    volume=$(pactl get-sink-volume 0 | awk 'BEGIN { FS="/" } {gsub("%","",$2); gsub(" ","",$2)} {printf $2}')
+
+    if [ "$volume" -eq 0 ]; then
+        echo "muted|bool|true"
+    else
+        echo "volume|string|$volume"
+        echo "muted|bool|false"
+    fi
+    echo ""
+
+    sleep 1;
+done
+
+
+# vim: ft=sh