diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2026-03-24 11:08:18 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2026-03-24 11:08:18 +0900 |
| commit | 7ad735138ce0160e68c3cb0e8be013e778400cf8 (patch) | |
| tree | 616ca99625b21185c7be3d4f0cab4a11764283f5 /ar/.local/bin/statusbar | |
| parent | 5dd58abffb4ca07cc76face5175891328a9b55f4 (diff) | |
modified claude/settings.json, deleted statusbar/sb-cpu, deleted statusbar/sb-cpubars, deleted statusbar/sb-memory, created statusbar/sb-system
Diffstat (limited to 'ar/.local/bin/statusbar')
| -rwxr-xr-x | ar/.local/bin/statusbar/sb-cpu | 12 | ||||
| -rwxr-xr-x | ar/.local/bin/statusbar/sb-cpubars | 43 | ||||
| -rwxr-xr-x | ar/.local/bin/statusbar/sb-memory | 25 | ||||
| -rwxr-xr-x | ar/.local/bin/statusbar/sb-system | 121 |
4 files changed, 121 insertions, 80 deletions
diff --git a/ar/.local/bin/statusbar/sb-cpu b/ar/.local/bin/statusbar/sb-cpu deleted file mode 100755 index 753542f..0000000 --- a/ar/.local/bin/statusbar/sb-cpu +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -case $BLOCK_BUTTON in -1) notify-send "š„ CPU hogs" "$(ps axch -o cmd,%cpu | awk '{cmd[$1]+=$2} END {for (i in cmd) print i, cmd[i]}' | sort -nrk2 | head)\\n(100% per core)" ;; -2) setsid -f "$TERMINAL" -e htop ;; -3) notify-send "š§ CPU module " "\- Shows CPU temperature -- Left click to show intensive processes -- Middle click to open htop" ;; -6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;; -esac - -sensors | awk '/Tctl:/ {gsub(/[+°C]/,"",$2); printf "š§%s°", $2}' diff --git a/ar/.local/bin/statusbar/sb-cpubars b/ar/.local/bin/statusbar/sb-cpubars deleted file mode 100755 index 4b03fa6..0000000 --- a/ar/.local/bin/statusbar/sb-cpubars +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh - -# Module showing CPU load as a changing bars. -# Just like in polybar. -# Each bar represents amount of load on one core since -# last run. - -# Cache in tmpfs to improve speed and reduce SSD load -cache=/tmp/cpubarscache - -case $BLOCK_BUTTON in -2) setsid -f "$TERMINAL" -e htop ;; -3) notify-send "šŖØ CPU load module" "Each bar represents one CPU core" ;; -6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;; -esac - -# id total idle -stats=$(awk '/cpu[0-9]+/ {printf "%d %d %d\n", substr($1,4), ($2 + $3 + $4 + $5), $5 }' /proc/stat) -[ ! -f $cache ] && echo "$stats" >"$cache" -old=$(cat "$cache") -echo "$stats" | while read -r row; do - id=${row%% *} - rest=${row#* } - total=${rest%% *} - idle=${rest##* } - - case "$(echo "$old" | awk '{if ($1 == id) - printf "%d\n", (1 - (idle - $3) / (total - $2))*100 /12.5}' \ - id="$id" total="$total" idle="$idle")" in - - "0") printf "ā" ;; - "1") printf "ā" ;; - "2") printf "ā" ;; - "3") printf "ā" ;; - "4") printf "ā
" ;; - "5") printf "ā" ;; - "6") printf "ā" ;; - "7") printf "ā" ;; - "8") printf "ā" ;; - esac -done -printf "\\n" -echo "$stats" >"$cache" diff --git a/ar/.local/bin/statusbar/sb-memory b/ar/.local/bin/statusbar/sb-memory deleted file mode 100755 index 3b71f3c..0000000 --- a/ar/.local/bin/statusbar/sb-memory +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh - -case $BLOCK_BUTTON in -1) notify-send "š Memory hogs" "$(ps axch -o cmd,%mem | awk '{cmd[$1]+=$2} END {for (i in cmd) print i, cmd[i]}' | sort -nrk2 | head)" ;; -2) setsid -f "$TERMINAL" -e htop ;; -3) notify-send "š Memory module" "\- Shows Memory temperature and used/total -- Left click to show memory hogs -- Middle click to open htop -š”ļø: Memory temperature" ;; -6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;; -esac - -width=$(xrandr | grep "\*" | awk '{print $1}' | sed 's/x[0-9]*//g' | head -n1) -nvme_temp=$(sensors 2>/dev/null | - awk '/Composite:/ {gsub(/[+°C]/,"",$2); print $2; exit}') - -if [ -n "$width" ] && [ "$width" -eq "$width" ] 2>/dev/null; then - if [ "$width" -lt 1920 ]; then - free --mebi | sed -n '2{p;q}' | - awk -v t="$nvme_temp" '{printf "š”%s° š%d%%\n", t, ($3/$2)*100+0.5}' - else - free --mebi | sed -n '2{p;q}' | - awk -v t="$nvme_temp" '{printf "š”%s° š%dGB/%dGB", t, $3/1000+0.5, $2/1000+0.5}' - fi -fi diff --git a/ar/.local/bin/statusbar/sb-system b/ar/.local/bin/statusbar/sb-system new file mode 100755 index 0000000..d580376 --- /dev/null +++ b/ar/.local/bin/statusbar/sb-system @@ -0,0 +1,121 @@ +#!/bin/sh + +# Combined system status bar module +# Toggle each section on/off (1=on, 0=off) +SHOW_CPU=1 +SHOW_CPUBARS=1 +SHOW_MEMORY=1 +SHOW_DISK=1 + +# Refresh interval per module (seconds) +# The script itself should be called at the shortest interval (e.g. 5s) +INTERVAL_CPU=5 +INTERVAL_CPUBARS=15 +INTERVAL_MEMORY=60 +INTERVAL_DISK=10800 + +# Disk mountpoint (only used if SHOW_DISK=1) +DISK_LOCATION=${1:-/} + +# Cache directory +CACHE_DIR=/tmp/sb-system +mkdir -p "$CACHE_DIR" + +# āā Helper: check if cache is stale āāāāāāāāāāāāāāāāāāāāāāāā +# usage: is_stale <cache_file> <interval_seconds> +is_stale() { + [ ! -f "$1" ] && return 0 + last=$(stat -c %Y "$1" 2>/dev/null || echo 0) + now=$(date +%s) + [ $((now - last)) -ge "$2" ] +} + +# āā Click handlers āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā +case $BLOCK_BUTTON in +1) + [ "$SHOW_CPU" = 1 ] && notify-send "š„ CPU hogs" "$(ps axch -o cmd,%cpu | awk '{cmd[$1]+=$2} END {for (i in cmd) print i, cmd[i]}' | sort -nrk2 | head)\\n(100% per core)" + [ "$SHOW_MEMORY" = 1 ] && notify-send "š Memory hogs" "$(ps axch -o cmd,%mem | awk '{cmd[$1]+=$2} END {for (i in cmd) print i, cmd[i]}' | sort -nrk2 | head)" + [ "$SHOW_DISK" = 1 ] && notify-send "š½ Disk space" "$(df -h --output=target,used,size)" + ;; +2) setsid -f "$TERMINAL" -e htop ;; +3) notify-send "š„ System module" "CPU temp, CPU bars, Memory, Disk usage +Left click: show hogs & disk info +Middle click: open htop +Right click: this help" ;; +6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +# āā Module: CPU temperature āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā +if [ "$SHOW_CPU" = 1 ]; then + cf="$CACHE_DIR/cpu" + if is_stale "$cf" "$INTERVAL_CPU"; then + sensors | awk '/Tctl:/ {gsub(/[+°C]/,"",$2); printf "š§%s°", $2}' > "$cf" + fi +fi + +# āā Module: CPU bars āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā +if [ "$SHOW_CPUBARS" = 1 ]; then + cf="$CACHE_DIR/cpubars" + if is_stale "$cf" "$INTERVAL_CPUBARS"; then + prev_cache="$CACHE_DIR/cpubars_prev" + stats=$(awk '/cpu[0-9]+/ {printf "%d %d %d\n", substr($1,4), ($2 + $3 + $4 + $5), $5 }' /proc/stat) + [ ! -f "$prev_cache" ] && echo "$stats" > "$prev_cache" + old=$(cat "$prev_cache") + echo "$stats" | while read -r row; do + id=${row%% *} + rest=${row#* } + total=${rest%% *} + idle=${rest##* } + case "$(echo "$old" | awk '{if ($1 == id) + printf "%d\n", (1 - (idle - $3) / (total - $2))*100 /12.5}' \ + id="$id" total="$total" idle="$idle")" in + "0") printf "ā" ;; "1") printf "ā" ;; "2") printf "ā" ;; "3") printf "ā" ;; + "4") printf "ā
" ;; "5") printf "ā" ;; "6") printf "ā" ;; "7"|"8") printf "ā" ;; + esac + done > "$cf" + echo "$stats" > "$prev_cache" + fi +fi + +# āā Module: Memory + NVMe temp āāāāāāāāāāāāāāāāāāāāāāāāāāāāāā +if [ "$SHOW_MEMORY" = 1 ]; then + cf="$CACHE_DIR/memory" + if is_stale "$cf" "$INTERVAL_MEMORY"; then + width=$(xrandr | grep "\*" | awk '{print $1}' | sed 's/x[0-9]*//g' | head -n1) + nvme_temp=$(sensors 2>/dev/null | + awk '/Composite:/ {gsub(/[+°C]/,"",$2); print $2; exit}') + if [ -n "$width" ] && [ "$width" -eq "$width" ] 2>/dev/null; then + if [ "$width" -lt 1920 ]; then + free --mebi | sed -n '2{p;q}' | + awk -v t="$nvme_temp" '{printf "š”%s° š%d%%", t, ($3/$2)*100+0.5}' > "$cf" + else + free --mebi | sed -n '2{p;q}' | + awk -v t="$nvme_temp" '{printf "š”%s° š%dGB/%dGB", t, $3/1000+0.5, $2/1000+0.5}' > "$cf" + fi + fi + fi +fi + +# āā Module: Disk usage āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā +if [ "$SHOW_DISK" = 1 ] && [ -d "$DISK_LOCATION" ]; then + disk_key=$(printf "%s" "$DISK_LOCATION" | tr '/' '_') + cf="$CACHE_DIR/disk${disk_key}" + if is_stale "$cf" "$INTERVAL_DISK"; then + case "$DISK_LOCATION" in + "/home"*) icon="š¾" ;; "/mnt"*) icon="š«" ;; *) icon="š»" ;; + esac + printf "%s%s" "$icon" "$(df -hP "$DISK_LOCATION" | awk '/[0-9]/ {print $5}')" > "$cf" + fi +fi + +# āā Assemble output āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā +out="" +disk_key=$(printf "%s" "$DISK_LOCATION" | tr '/' '_') +for mod in cpu cpubars memory "disk${disk_key}"; do + f="$CACHE_DIR/$mod" + [ -f "$f" ] && val=$(cat "$f") && [ -n "$val" ] && { + [ -n "$out" ] && out="$out " + out="$out$val" + } +done +printf "%s\n" "$out" |
