diff options
| -rwxr-xr-x | ar/.local/bin/cron/checkup | 3 | ||||
| -rwxr-xr-x | ar/.local/bin/cron/newsup | 4 | ||||
| -rwxr-xr-x | ar/.local/bin/dmenurecord | 9 | ||||
| -rwxr-xr-x | ar/.local/bin/dmenuupgrade | 10 | ||||
| -rwxr-xr-x | ar/.local/bin/gitupdate | 2 | ||||
| -rwxr-xr-x | ar/.local/bin/qndl | 4 | ||||
| -rwxr-xr-x | ar/.local/bin/statusbar/sb-forecast | 2 | ||||
| -rwxr-xr-x | ar/.local/bin/statusbar/sb-internet | 67 | ||||
| -rwxr-xr-x | ar/.local/bin/statusbar/sb-mailbox | 2 | ||||
| -rwxr-xr-x | ar/.local/bin/statusbar/sb-mpdup | 2 | ||||
| -rwxr-xr-x | ar/.local/bin/statusbar/sb-packages | 2 | ||||
| -rwxr-xr-x | ar/.local/bin/statusbar/sb-playerctlup | 2 | ||||
| -rwxr-xr-x | ar/.local/bin/statusbar/sb-popupgrade | 2 | ||||
| -rwxr-xr-x | ar/.local/bin/statusbar/sb-queues | 2 | ||||
| -rwxr-xr-x | ar/.local/bin/statusbar/sb-system | 128 | ||||
| -rwxr-xr-x | ar/.local/bin/td-toggle | 2 | ||||
| -rwxr-xr-x | ar/.local/bin/tordone | 2 | ||||
| -rwxr-xr-x | ar/.local/bin/torwrap | 2 | ||||
| -rwxr-xr-x | ar/.local/bin/transadd | 2 |
19 files changed, 148 insertions, 101 deletions
diff --git a/ar/.local/bin/cron/checkup b/ar/.local/bin/cron/checkup index 2ea6772..86cba4a 100755 --- a/ar/.local/bin/cron/checkup +++ b/ar/.local/bin/cron/checkup @@ -1,13 +1,14 @@ #!/bin/sh # Syncs repositories and downloads updates, meant to be run as a cronjob. +# /usr/share/libalpm/hooks/statusbar.hook notify-send "š¦ Repository Sync" "Checking for package updates..." sudo pacman -Syyuw --noconfirm || notify-send "ā Error downloading updates. Check your internet connection, if pacman is already running, or run update manually to see errors." -pkill -RTMIN+14 "${STATUSBAR:-dwmblocks}" +pkill -RTMIN+11 "${STATUSBAR:-dwmblocks}" if pacman -Qu | grep -v "\[ignored\]"; then notify-send "š Repository Sync" "Updates available. Click statusbar icon (š¦) or run sb-popupgrade in terminal for update." diff --git a/ar/.local/bin/cron/newsup b/ar/.local/bin/cron/newsup index f8b40b7..c587e21 100755 --- a/ar/.local/bin/cron/newsup +++ b/ar/.local/bin/cron/newsup @@ -8,8 +8,8 @@ pgrep -f newsboat$ && /usr/bin/xdotool key --window "$(/usr/bin/xdotool search --name "^newsboat$")" R && exit echo š >/tmp/newsupdate -pkill -RTMIN+17 "${STATUSBAR:-dwmblocks}" +pkill -RTMIN+14 "${STATUSBAR:-dwmblocks}" /usr/bin/newsboat -x reload rm -f /tmp/newsupdate -pkill -RTMIN+17 "${STATUSBAR:-dwmblocks}" +pkill -RTMIN+14 "${STATUSBAR:-dwmblocks}" /usr/bin/notify-send "š° RSS feed update complete." diff --git a/ar/.local/bin/dmenurecord b/ar/.local/bin/dmenurecord index adb8ae1..20959f8 100755 --- a/ar/.local/bin/dmenurecord +++ b/ar/.local/bin/dmenurecord @@ -17,7 +17,7 @@ getdim() { xrandr | grep -oP '(?<=current ).*(?=,)' | tr -d ' '; } updateicon() { echo "$1" >/tmp/recordingicon - pkill -RTMIN+22 "${STATUSBAR:-dwmblocks}" + pkill -RTMIN+19 "${STATUSBAR:-dwmblocks}" } killrecording() { @@ -25,7 +25,7 @@ killrecording() { kill -15 "$recpid" rm -f /tmp/recordingpid updateicon "" - pkill -RTMIN+22 "${STATUSBAR:-dwmblocks}" + pkill -RTMIN+19 "${STATUSBAR:-dwmblocks}" } getmonitor() { @@ -115,7 +115,10 @@ video() { } videoselected() { - slop -f "%x %y %w %h" >/tmp/slop || { rm -f /tmp/slop; exit 1; } + slop -f "%x %y %w %h" >/tmp/slop || { + rm -f /tmp/slop + exit 1 + } read -r X Y W H </tmp/slop rm /tmp/slop diff --git a/ar/.local/bin/dmenuupgrade b/ar/.local/bin/dmenuupgrade index b23e80a..4185eb0 100755 --- a/ar/.local/bin/dmenuupgrade +++ b/ar/.local/bin/dmenuupgrade @@ -16,7 +16,7 @@ case "$selection" in if [ "$(printf "No\nYes" | dmenu -i -p 'Proceed with upgrade for all packages?')" = "Yes" ]; then notify-send "š¦ Upgrading all packages..." yay -Syu --noconfirm - pkill -RTMIN+14 "${STATUSBAR:-dwmblocks}" + pkill -RTMIN+11 "${STATUSBAR:-dwmblocks}" notify-send "ā
Upgrade of all packages completed." else notify-send "ā Upgrade cancelled." @@ -31,7 +31,7 @@ case "$selection" in if [ "$(printf "No\nYes" | dmenu -i -p 'Proceed with pacman upgrade?')" = "Yes" ]; then notify-send "š¦ Upgrading pacman packages..." printf "%s" "$pacman_updates" | awk '{print $1}' | xargs sudo pacman -S --noconfirm - pkill -RTMIN+14 "${STATUSBAR:-dwmblocks}" + pkill -RTMIN+11 "${STATUSBAR:-dwmblocks}" notify-send "ā
Pacman packages upgrade completed." else notify-send "ā Upgrade cancelled." @@ -46,7 +46,7 @@ case "$selection" in if [ "$(printf "No\nYes" | dmenu -i -p 'Proceed with upgrade for this package?')" = "Yes" ]; then notify-send "š¦ Upgrading package: $selection..." sudo pacman -S --noconfirm "$(printf "%s" "$selection" | awk '{print $1}')" - pkill -RTMIN+14 "${STATUSBAR:-dwmblocks}" + pkill -RTMIN+11 "${STATUSBAR:-dwmblocks}" notify-send "ā
Upgrade completed for package: $selection." else notify-send "ā Upgrade cancelled." @@ -73,7 +73,7 @@ case "$selection" in if [ "$(printf "No\nYes" | dmenu -i -p 'Proceed with AUR upgrade?')" = "Yes" ]; then notify-send "š¦ Upgrading AUR packages..." yay -Syu --aur --noconfirm - pkill -RTMIN+14 "${STATUSBAR:-dwmblocks}" + pkill -RTMIN+11 "${STATUSBAR:-dwmblocks}" notify-send "ā
AUR packages upgrade completed." else notify-send "ā Upgrade cancelled." @@ -88,7 +88,7 @@ case "$selection" in if [ "$(printf "No\nYes" | dmenu -i -p 'Proceed with upgrade for this package?')" = "Yes" ]; then notify-send "š¦ Upgrading AUR package: $selection..." yay -S --noconfirm "$(printf "%s" "$selection" | awk '{print $2}')" - pkill -RTMIN+14 "${STATUSBAR:-dwmblocks}" + pkill -RTMIN+11 "${STATUSBAR:-dwmblocks}" notify-send "ā
Upgrade completed for AUR package: $selection." else notify-send "ā Upgrade cancelled." diff --git a/ar/.local/bin/gitupdate b/ar/.local/bin/gitupdate index 3dabf34..4ea7874 100755 --- a/ar/.local/bin/gitupdate +++ b/ar/.local/bin/gitupdate @@ -85,4 +85,4 @@ printf "\n[repo] %s(%s): %s\n" "$(basename "$repo_root")" "$branch" "$message" # Return to the original directory cd - >/dev/null -command -v dwmblocks >/dev/null 2>&1 && pkill -RTMIN+16 "${STATUSBAR:-dwmblocks}" +command -v dwmblocks >/dev/null 2>&1 && pkill -RTMIN+13 "${STATUSBAR:-dwmblocks}" diff --git a/ar/.local/bin/qndl b/ar/.local/bin/qndl index 6a815ac..c7666ea 100755 --- a/ar/.local/bin/qndl +++ b/ar/.local/bin/qndl @@ -47,7 +47,7 @@ case $type in video_id=$(echo "$line" | awk '{print $2}') ytdl_cmd="$ytdl_cmd_base --output \"$ytdl_output_format\" \"https://www.youtube.com/watch?v=$video_id\"" idnum=$(tsp bash -c "$ytdl_cmd") - pkill -RTMIN+19 "${STATUSBAR:-dwmblocks}" + pkill -RTMIN+16 "${STATUSBAR:-dwmblocks}" done <"$archive_file" exit 0 ;; @@ -120,7 +120,7 @@ filename=$($simulation_cmd 2>/dev/null) [ -f /tmp/qplaylist ] && rm -rf /tmp/qplaylist notify-send "ā³ Downloading $download_type:" "$filename" idnum=$(tsp bash -c "$ytdl_cmd") -pkill -RTMIN+19 "${STATUSBAR:-dwmblocks}" +pkill -RTMIN+16 "${STATUSBAR:-dwmblocks}" # Notify upon completion tsp -D "$idnum" notify-send "ā
$download_type download complete:" "$url" || 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 <Enter> 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 <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" ] + [ ! -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" diff --git a/ar/.local/bin/td-toggle b/ar/.local/bin/td-toggle index c71d53f..0c89ac6 100755 --- a/ar/.local/bin/td-toggle +++ b/ar/.local/bin/td-toggle @@ -8,4 +8,4 @@ else ifinstalled transmission-cli || exit [ "$(printf "No\\nYes" | dmenu -i -p "Turn on transmission daemon?")" = "Yes" ] && transmission-daemon && notify-send "š transmission-daemon enabled." fi -sleep 3 && pkill -RTMIN+20 "${STATUSBAR:-dwmblocks}" +sleep 3 && pkill -RTMIN+17 "${STATUSBAR:-dwmblocks}" diff --git a/ar/.local/bin/tordone b/ar/.local/bin/tordone index 016568f..f220c32 100755 --- a/ar/.local/bin/tordone +++ b/ar/.local/bin/tordone @@ -5,6 +5,6 @@ if [ -n "$completed_torrents" ]; then for torrent_id in $completed_torrents; do transmission-remote -n "$USER" -t "$torrent_id" -r done - pkill -RTMIN+20 "${STATUSBAR:-dwmblocks}" && notify-send "ā
Transmission-daemon" "Torrent(s) $TR_TORRENT_NAME has completed downloading. Deleting torrent files." + pkill -RTMIN+17 "${STATUSBAR:-dwmblocks}" && notify-send "ā
Transmission-daemon" "Torrent(s) $TR_TORRENT_NAME has completed downloading. Deleting torrent files." [ -z "$(transmission-remote -n "$USER" -l | grep -v "Sum:")" ] && killall transmission-daemon && notify-send "ā Transmission-daemon disabled." fi diff --git a/ar/.local/bin/torwrap b/ar/.local/bin/torwrap index 624778a..f08b224 100755 --- a/ar/.local/bin/torwrap +++ b/ar/.local/bin/torwrap @@ -5,4 +5,4 @@ ifinstalled stig transmission-cli || exit 1 ! pidof transmission-daemon >/dev/null && transmission-daemon && notify-send "Starting torrent daemon..." "${TERMINAL:-st}" -n stig -e stig -pkill -RTMIN+20 "${STATUSBAR:-dwmblocks}" +pkill -RTMIN+17 "${STATUSBAR:-dwmblocks}" diff --git a/ar/.local/bin/transadd b/ar/.local/bin/transadd index 567b1bc..7163f47 100755 --- a/ar/.local/bin/transadd +++ b/ar/.local/bin/transadd @@ -4,7 +4,7 @@ # transmission-daemon sometimes fails to take remote requests in its first moments, hence the sleep. -pidof transmission-daemon >/dev/null || (transmission-daemon && notify-send "š” Starting transmission daemon..." && sleep 3 && pkill -RTMIN+20 "${STATUSBAR:-dwmblocks}") +pidof transmission-daemon >/dev/null || (transmission-daemon && notify-send "š” Starting transmission daemon..." && sleep 3 && pkill -RTMIN+17 "${STATUSBAR:-dwmblocks}") directory="$HOME/Torrents" |
