summaryrefslogtreecommitdiff
path: root/ar/.local/bin/statusbar
diff options
context:
space:
mode:
Diffstat (limited to 'ar/.local/bin/statusbar')
-rwxr-xr-xar/.local/bin/statusbar/sb-disk27
-rwxr-xr-xar/.local/bin/statusbar/sb-system7
-rwxr-xr-xar/.local/bin/statusbar/sb-ylog22
3 files changed, 20 insertions, 36 deletions
diff --git a/ar/.local/bin/statusbar/sb-disk b/ar/.local/bin/statusbar/sb-disk
deleted file mode 100755
index 9871872..0000000
--- a/ar/.local/bin/statusbar/sb-disk
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/sh
-
-# Status bar module for disk space
-# $1 should be drive mountpoint, otherwise assumed /.
-
-location=${1:-/}
-
-[ -d "$location" ] || exit
-
-case "$location" in
-"/home"*) icon="💾" ;;
-"/mnt"*) icon="🫜" ;;
-*) icon="💻" ;;
-esac
-
-usage=$(df -h "$location" | awk ' /[0-9]/ {print $3 "/" $2}')
-
-case $BLOCK_BUTTON in
-1) notify-send "💽 Disk space" "$(df -h --output=target,used,size)" ;;
-2) notify-send "💽 Disk usage" "$icon: $usage" ;;
-3) notify-send "💽 Disk module" "\- Shows used hard drive space
-- Left click to show all disk info
-- Middle click to show disk usage" ;;
-6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;;
-esac
-
-printf "%s%s\n" "$icon" "$(df -hP "$location" | awk ' /[0-9]/ {print $5}')"
diff --git a/ar/.local/bin/statusbar/sb-system b/ar/.local/bin/statusbar/sb-system
index b2e28af..48addca 100755
--- a/ar/.local/bin/statusbar/sb-system
+++ b/ar/.local/bin/statusbar/sb-system
@@ -21,6 +21,13 @@ DISK_LOCATION=${1:-/}
CACHE_DIR=/tmp/sb-system
mkdir -p "$CACHE_DIR"
+# Clear stale caches on first run (e.g. dwmblocks restart)
+LOCK="$CACHE_DIR/.started"
+if [ ! -f "$LOCK" ]; then
+ rm -f "$CACHE_DIR"/cpu "$CACHE_DIR"/cpubars "$CACHE_DIR"/cpubars_prev "$CACHE_DIR"/memory "$CACHE_DIR"/disk*
+ touch "$LOCK"
+fi
+
# ── Helper: check if cache is stale ────────────────────────
# usage: is_stale <cache_file> <interval_seconds>
is_stale() {
diff --git a/ar/.local/bin/statusbar/sb-ylog b/ar/.local/bin/statusbar/sb-ylog
index 637af89..7f53c8e 100755
--- a/ar/.local/bin/statusbar/sb-ylog
+++ b/ar/.local/bin/statusbar/sb-ylog
@@ -6,7 +6,7 @@
# Middle click: force refresh
# Right click: help
-CACHE_DIR="/tmp/ylog_sb"
+CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/ylog_sb"
PREV="$CACHE_DIR/prev"
CURR="$CACHE_DIR/curr"
NEW="$CACHE_DIR/new"
@@ -14,6 +14,8 @@ LOCK="$CACHE_DIR/lock"
mkdir -p "$CACHE_DIR"
+export SSH_AUTH_SOCK="/run/user/$(id -u)/gnupg/S.gpg-agent.ssh"
+
fetch_logs() {
us_today=$(TZ=America/New_York LC_TIME=C date +%d/%b)
us_yesterday=$(TZ=America/New_York LC_TIME=C date -d 'yesterday' +%d/%b)
@@ -27,19 +29,19 @@ update() {
if [ -f "$LOCK" ]; then
kill -0 "$(cat "$LOCK")" 2>/dev/null && return
fi
- echo $$ > "$LOCK"
+ echo $$ >"$LOCK"
- fetch_logs > "$CURR" 2>/dev/null
- total=$(wc -l < "$CURR")
+ fetch_logs >"$CURR" 2>/dev/null
+ total=$(wc -l <"$CURR")
if [ -f "$PREV" ]; then
# Find lines in curr that are not in prev
- comm -23 "$CURR" "$PREV" > "$NEW"
+ comm -23 "$CURR" "$PREV" >"$NEW"
else
cp "$CURR" "$NEW"
fi
- new_count=$(wc -l < "$NEW")
+ new_count=$(wc -l <"$NEW")
[ -t 1 ] && echo "[ylog] fetched $total lines, $new_count new" >&2
rm -f "$LOCK"
@@ -47,7 +49,7 @@ update() {
mark_seen() {
[ -f "$CURR" ] && cp "$CURR" "$PREV"
- : > "$NEW"
+ : >"$NEW"
}
case $BLOCK_BUTTON in
@@ -80,6 +82,8 @@ esac
# Display
if [ -s "$NEW" ]; then
- count=$(wc -l < "$NEW")
- echo "🌐$count"
+ count=$(wc -l <"$NEW")
+ printf "🌐%s\n" "$count"
fi
+
+exit 0