From 01e4a66a09486307728d016576bee88df7b698c1 Mon Sep 17 00:00:00 2001 From: TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> Date: Tue, 24 Mar 2026 11:34:32 +0900 Subject: updates --- ar/.local/bin/statusbar/sb-forecast | 2 +- ar/.local/bin/statusbar/sb-internet | 67 +++++++++++++---- ar/.local/bin/statusbar/sb-mailbox | 2 +- ar/.local/bin/statusbar/sb-mpdup | 2 +- ar/.local/bin/statusbar/sb-packages | 2 +- ar/.local/bin/statusbar/sb-playerctlup | 2 +- ar/.local/bin/statusbar/sb-popupgrade | 2 +- ar/.local/bin/statusbar/sb-queues | 2 +- ar/.local/bin/statusbar/sb-system | 128 +++++++++++++++++---------------- 9 files changed, 126 insertions(+), 83 deletions(-) (limited to 'ar/.local/bin/statusbar') diff --git a/ar/.local/bin/statusbar/sb-forecast b/ar/.local/bin/statusbar/sb-forecast index 2e42368..061b095 100755 --- a/ar/.local/bin/statusbar/sb-forecast +++ b/ar/.local/bin/statusbar/sb-forecast @@ -417,5 +417,5 @@ After $secs seconds, new clicks will also automatically update the doppler RADAR 8) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;; esac -checkforecast "$weatherreportjson" "10800" || { getweatherreportjson && getweatherreport && pkill -RTMIN+13 "${STATUSBAR:-dwmblocks}" && sleep 3; } +checkforecast "$weatherreportjson" "10800" || { getweatherreportjson && getweatherreport && pkill -RTMIN+10 "${STATUSBAR:-dwmblocks}" && sleep 3; } showweather diff --git a/ar/.local/bin/statusbar/sb-internet b/ar/.local/bin/statusbar/sb-internet index eeab61a..b659d60 100755 --- a/ar/.local/bin/statusbar/sb-internet +++ b/ar/.local/bin/statusbar/sb-internet @@ -3,6 +3,13 @@ # Show wifi šŸ›œ and percent strength or šŸ“” if none. # Show 🌐 if connected to ethernet or āŽ if none. # Show šŸ›° if a vpn connection is active +# Show šŸ‡°šŸ‡· country flag via geoip lookup + +# Toggle each section: 1 to show, 0 to hide +SHOW_WIFI=1 +SHOW_ETH=1 +SHOW_VPN=1 +SHOW_IPLOC=1 eth_con="$(nmcli -t -f NAME,TYPE,DEVICE connection show | awk -F: '$2=="ethernet" && $3!="" { print $1; exit }')" @@ -53,30 +60,60 @@ case $BLOCK_BUTTON in āŽ: no ethernet 🌐: ethernet working šŸ›°: vpn is active +šŸ³: ip geolocation (country flag) " ;; 6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;; esac -# Wifi -if grep -q 'up' /sys/class/net/w*/operstate 2>/dev/null; then - if grep -q '^\s*w' /proc/net/wireless; then - wifiicon="$(awk '/^\s*w/ { print "šŸ›œ" int($3 * 100 / 70) "%" }' /proc/net/wireless)" +icons="" + +# IP Geolocation +if [ "$SHOW_IPLOC" = 1 ]; then + ip="$(curl -4sfm 3 ifconfig.me 2>/dev/null)" + if [ -n "$ip" ]; then + addr="$(geoiplookup "$ip" 2>/dev/null)" else - wifiicon="šŸ“”" + ip="$(curl -6sfm 3 ifconfig.me 2>/dev/null)" + [ -n "$ip" ] && addr="$(geoiplookup6 "$ip" 2>/dev/null)" + fi + case "$addr" in *"not found"*) addr="" ;; esac + if [ -n "$addr" ]; then + cc="$(echo "$addr" | sed 's/.*: \([A-Z][A-Z]\),.*/\1/')" + if [ -n "$cc" ]; then + c1=$(printf '%d' "'$(echo "$cc" | cut -c1)") + c2=$(printf '%d' "'$(echo "$cc" | cut -c2)") + oct1=$(printf '%03o' "$((c1 + 101))") + oct2=$(printf '%03o' "$((c2 + 101))") + flag=$(printf "\\360\\237\\207\\${oct1}\\360\\237\\207\\${oct2}") + [ -n "$flag" ] && icons="${icons}$flag " + fi fi -elif grep -q 'down' /sys/class/net/w*/operstate 2>/dev/null; then - wifiicon="āŒ" fi -# Ethernet -grep -q 'up' /sys/class/net/e*/operstate && ethericon="🌐" || ethericon="āŽ" +# Wifi +if [ "$SHOW_WIFI" = 1 ]; then + if grep -q 'up' /sys/class/net/w*/operstate 2>/dev/null; then + if grep -q '^\s*w' /proc/net/wireless; then + wifiicon="$(awk '/^\s*w/ { print "šŸ›œ" int($3 * 100 / 70) "%" }' /proc/net/wireless)" + else + wifiicon="šŸ“”" + fi + elif grep -q 'down' /sys/class/net/w*/operstate 2>/dev/null; then + wifiicon="āŒ" + fi + [ -n "$wifiicon" ] && icons="${icons}$wifiicon " +fi -# TUN -[ -n "$(cat /sys/class/net/tun*/operstate 2>/dev/null)" ] && tunicon="šŸ›°" +# Ethernet +if [ "$SHOW_ETH" = 1 ]; then + grep -q 'up' /sys/class/net/e*/operstate && ethericon="🌐" || ethericon="āŽ" + [ -n "$ethericon" ] && icons="${icons}$ethericon " +fi -icons="" -[ -n "$wifiicon" ] && icons="${icons}$wifiicon " -[ -n "$ethericon" ] && icons="${icons}$ethericon " -[ -n "$tunicon" ] && icons="${icons}$tunicon " +# TUN/VPN +if [ "$SHOW_VPN" = 1 ]; then + [ -n "$(cat /sys/class/net/tun*/operstate 2>/dev/null)" ] && tunicon="šŸ›°" + [ -n "$tunicon" ] && icons="${icons}$tunicon " +fi printf "%s\n" "${icons% }" diff --git a/ar/.local/bin/statusbar/sb-mailbox b/ar/.local/bin/statusbar/sb-mailbox index 6926b6e..cfd1f2b 100755 --- a/ar/.local/bin/statusbar/sb-mailbox +++ b/ar/.local/bin/statusbar/sb-mailbox @@ -6,7 +6,7 @@ case $BLOCK_BUTTON in 1) setsid -w -f "$TERMINAL" -e neomutt - pkill -RTMIN+18 "${STATUSBAR:-dwmblocks}" + pkill -RTMIN+15 "${STATUSBAR:-dwmblocks}" ;; 2) setsid -f mw -Y >/dev/null ;; 3) notify-send "šŸ“¬ Mail module" "\- Shows unread mail diff --git a/ar/.local/bin/statusbar/sb-mpdup b/ar/.local/bin/statusbar/sb-mpdup index dd49322..9931d76 100755 --- a/ar/.local/bin/statusbar/sb-mpdup +++ b/ar/.local/bin/statusbar/sb-mpdup @@ -8,5 +8,5 @@ export MPD_HOST while :; do mpc idle >/dev/null || continue - kill -55 "$(pidof "${STATUSBAR:-dwmblocks}")" 2>/dev/null + kill -52 "$(pidof "${STATUSBAR:-dwmblocks}")" 2>/dev/null done diff --git a/ar/.local/bin/statusbar/sb-packages b/ar/.local/bin/statusbar/sb-packages index 467bfb3..3c8fae9 100755 --- a/ar/.local/bin/statusbar/sb-packages +++ b/ar/.local/bin/statusbar/sb-packages @@ -15,7 +15,7 @@ # [Action] # Description = Updating statusbar... # When = PostTransaction -# Exec = /usr/bin/pkill -RTMIN+14 dwmblocks # Or i3blocks if using i3. +# Exec = /usr/bin/pkill -RTMIN+11 dwmblocks # Or i3blocks if using i3. case $BLOCK_BUTTON in 1) setsid -f "$TERMINAL" -e sb-popupgrade && remaps ;; diff --git a/ar/.local/bin/statusbar/sb-playerctlup b/ar/.local/bin/statusbar/sb-playerctlup index dd29ee2..123a3a4 100755 --- a/ar/.local/bin/statusbar/sb-playerctlup +++ b/ar/.local/bin/statusbar/sb-playerctlup @@ -3,5 +3,5 @@ # Updates the music statusbar module when a playerctl-compatible player changes state playerctl -aF status 2>/dev/null | while read -r _; do - kill -55 "$(pidof "${STATUSBAR:-dwmblocks}")" 2>/dev/null + kill -52 "$(pidof "${STATUSBAR:-dwmblocks}")" 2>/dev/null done diff --git a/ar/.local/bin/statusbar/sb-popupgrade b/ar/.local/bin/statusbar/sb-popupgrade index 221c7db..3f5a0ed 100755 --- a/ar/.local/bin/statusbar/sb-popupgrade +++ b/ar/.local/bin/statusbar/sb-popupgrade @@ -3,7 +3,7 @@ printf "Beginning upgrade\\n" yay -Syu -pkill -RTMIN+14 "${STATUSBAR:-dwmblocks}" +pkill -RTMIN+11 "${STATUSBAR:-dwmblocks}" printf "\\nUpgrade complete.\\nPress to exit window.\\n\\n" read -r _ diff --git a/ar/.local/bin/statusbar/sb-queues b/ar/.local/bin/statusbar/sb-queues index ac7cb55..9bbb8ab 100755 --- a/ar/.local/bin/statusbar/sb-queues +++ b/ar/.local/bin/statusbar/sb-queues @@ -18,7 +18,7 @@ EOF if [ -z "$url" ]; then notify-send "šŸ’¤ No active yt-dlp downloads" fi - pkill -RTMIN+19 "${STATUSBAR:-dwmblocks}" + pkill -RTMIN+16 "${STATUSBAR:-dwmblocks}" } # This block displays the number of running and queued background tasks. Requires tsp. diff --git a/ar/.local/bin/statusbar/sb-system b/ar/.local/bin/statusbar/sb-system index d580376..b2e28af 100755 --- a/ar/.local/bin/statusbar/sb-system +++ b/ar/.local/bin/statusbar/sb-system @@ -3,7 +3,7 @@ # Combined system status bar module # Toggle each section on/off (1=on, 0=off) SHOW_CPU=1 -SHOW_CPUBARS=1 +SHOW_CPUBARS=0 SHOW_MEMORY=1 SHOW_DISK=1 @@ -24,19 +24,19 @@ mkdir -p "$CACHE_DIR" # ── Helper: check if cache is stale ──────────────────────── # usage: is_stale is_stale() { - [ ! -f "$1" ] && return 0 - last=$(stat -c %Y "$1" 2>/dev/null || echo 0) - now=$(date +%s) - [ $((now - last)) -ge "$2" ] + [ ! -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)" - ;; + [ "$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 @@ -47,75 +47,81 @@ 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 + 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) + 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 + 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 + 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 + 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 +# ── Clean up disabled module caches ─────────────────────────── +[ "$SHOW_CPU" = 0 ] && rm -f "$CACHE_DIR/cpu" +[ "$SHOW_CPUBARS" = 0 ] && rm -f "$CACHE_DIR/cpubars" "$CACHE_DIR/cpubars_prev" +[ "$SHOW_MEMORY" = 0 ] && rm -f "$CACHE_DIR/memory" +disk_key=$(printf "%s" "$DISK_LOCATION" | tr '/' '_') +[ "$SHOW_DISK" = 0 ] && rm -f "$CACHE_DIR/disk${disk_key}" + # ── 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" - } + f="$CACHE_DIR/$mod" + [ -f "$f" ] && val=$(cat "$f") && [ -n "$val" ] && { + [ -n "$out" ] && out="$out " + out="$out$val" + } done printf "%s\n" "$out" -- cgit v1.2.3