From 71949de0f7dadd027f5bb95958ed1c417045e5d7 Mon Sep 17 00:00:00 2001 From: frosty Date: Thu, 4 Jul 2024 17:01:41 -0400 Subject: [PATCH] remove a few scripts, and move all monitors to a single script --- .config/xmobar/xmobarrc | 10 ++-- .local/bin/batmon | 16 ----- .local/bin/cpumon | 29 ---------- .local/bin/diskusage | 7 --- .local/bin/ipmon | 7 --- .local/bin/loadmon | 9 --- .local/bin/memmon | 21 ------- .local/bin/monitors | 116 +++++++++++++++++++++++++++++++++++++ .local/bin/netmon | 21 ------- .local/bin/pipe_nowplaying | 8 --- .local/bin/pipe_volume | 2 +- .local/bin/ssidmon | 17 ------ .local/bin/tempmon | 15 ----- .local/bin/uppretty | 3 - .local/bin/volmon | 9 --- 15 files changed, 122 insertions(+), 168 deletions(-) delete mode 100755 .local/bin/batmon delete mode 100755 .local/bin/cpumon delete mode 100755 .local/bin/diskusage delete mode 100755 .local/bin/ipmon delete mode 100755 .local/bin/loadmon delete mode 100755 .local/bin/memmon create mode 100755 .local/bin/monitors delete mode 100755 .local/bin/netmon delete mode 100755 .local/bin/pipe_nowplaying delete mode 100755 .local/bin/ssidmon delete mode 100755 .local/bin/tempmon delete mode 100755 .local/bin/uppretty delete mode 100755 .local/bin/volmon diff --git a/.config/xmobar/xmobarrc b/.config/xmobar/xmobarrc index f6f992a..3f8209b 100644 --- a/.config/xmobar/xmobarrc +++ b/.config/xmobar/xmobarrc @@ -7,12 +7,12 @@ Config , template = " %XMonadLog% }{ %network% : VOL %volume% : %battery% : CPU %cpu% : RAM %memory% : %load% : %date% " , commands = [ Run XMonadLog - , Run Com "netmon" [] "network" 6000 + , Run Com "monitors" ["network"] "network" 6000 , Run PipeReader "/tmp/pipe-volume" "volume" - , Run Com "batmon" [] "battery" 36000 - , Run Com "cpumon" [] "cpu" 50 - , Run Com "memmon" [] "memory" 50 - , Run Com "loadmon" [] "load" 6000 + , Run Com "monitors" ["battery"] "battery" 36000 + , Run Com "monitors" ["cpu"] "cpu" 50 + , Run Com "monitors" ["memory"] "memory" 50 + , Run Com "monitors" ["load"] "load" 6000 , Run Date "%d/%m/%Y %H:%M:%S" "date" 10 ] } diff --git a/.local/bin/batmon b/.local/bin/batmon deleted file mode 100755 index 980be5f..0000000 --- a/.local/bin/batmon +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -FULL_THRESHOLD=80 -FULL_COLOR="#31f53e" - -read -r capacity %s%% (%s)\n' "$FULL_COLOR" "$capacity" "$status" -else - printf '%s%% (%s)\n' "$capacity" "$status" -fi diff --git a/.local/bin/cpumon b/.local/bin/cpumon deleted file mode 100755 index a06097e..0000000 --- a/.local/bin/cpumon +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -while read -r _ user _ system idle _; do - initial_user_sys=$((user + system)) - initial_total=$((user + system + idle)) - break -done %s%% (%s)\n' "$BATTERY_FULL_COLOR" "$capacity" "$status" + else + printf '%s%% (%s)\n' "$capacity" "$status" + fi +} + +monitor_cpu() { + while read -r _ user _ system idle _; do + initial_user_sys=$((user + system)) + initial_total=$((user + system + idle)) + break + done %s @ %s\n' "$address" "$ssid" +} + +monitor_volume() { + volume=$(wpctl get-volume @DEFAULT_AUDIO_SINK@) + volume=${volume% \[MUTED\]} + volume=${volume#Volume: } + volume=${volume%.*}${volume#*.} + volume=${volume#0} + + printf '%s%%\n' "$volume" +} + +if command -v monitor_"$1" >/dev/null 2>&1; then + monitor_"$1" +fi diff --git a/.local/bin/netmon b/.local/bin/netmon deleted file mode 100755 index c069604..0000000 --- a/.local/bin/netmon +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -ADAPTER="wlan0" - -address=$(ip route get 1) -address=${address#* via * dev * src } -address=${address% uid *} - -ssid= -while read -r line; do - case $line in - *Connected\ network*) - ssid=${line##*Connected network} - ssid="${ssid#"${ssid%%[![:space:]]*}"}" - ;; - esac -done <%s @ %s\n' "$address" "$ssid" diff --git a/.local/bin/pipe_nowplaying b/.local/bin/pipe_nowplaying deleted file mode 100755 index 1e1d1c4..0000000 --- a/.local/bin/pipe_nowplaying +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -TEXT_COLOR="#fe8019" - -PIPE_FILE="/tmp/pipe-nowplaying" -[ -p "$PIPE_FILE" ] || mkfifo "$PIPE_FILE" - -echo "$(mpc | head -n1)" >"$PIPE_FILE" diff --git a/.local/bin/pipe_volume b/.local/bin/pipe_volume index 8bf7c64..4aca780 100755 --- a/.local/bin/pipe_volume +++ b/.local/bin/pipe_volume @@ -3,4 +3,4 @@ PIPE_FILE="/tmp/pipe-volume" [ -p "$PIPE_FILE" ] || mkfifo "$PIPE_FILE" -volmon >"$PIPE_FILE" +monitors volume >"$PIPE_FILE" diff --git a/.local/bin/ssidmon b/.local/bin/ssidmon deleted file mode 100755 index ef52a1d..0000000 --- a/.local/bin/ssidmon +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -ADAPTER="wlan0" - -ssid= -while read -r line; do - case $line in - *Connected\ network*) - ssid=${line##*Connected network} - ssid="${ssid#"${ssid%%[![:space:]]*}"}" - ;; - esac -done <