From c00b14c75468f7c91cb0e89de20d8433fba7c917 Mon Sep 17 00:00:00 2001 From: Philip Wittamore Date: Fri, 6 Jun 2025 23:42:59 +0200 Subject: update --- pw-battery | 60 +++++++++++++++++++++++++-------------------------- pw-cputemp | 26 ++++++++++++++++++++++ pw-date | 45 ++++++++++++++++++++++---------------- pw-fan | 10 +++++++++ pw-music | 30 ++++++++++++++++++++++++++ pw-systemstats | 38 -------------------------------- pw-update-fingerprint | 2 +- 7 files changed, 122 insertions(+), 89 deletions(-) create mode 100755 pw-cputemp create mode 100755 pw-fan create mode 100755 pw-music delete mode 100755 pw-systemstats diff --git a/pw-battery b/pw-battery index 3f3dea7..bce03cc 100755 --- a/pw-battery +++ b/pw-battery @@ -1,28 +1,11 @@ -#!/bin/sh +#!/usr/bin/env bash + # Display the current battery status. # requires joypixels font in dwm config.def.h -notify() { - dunstify \ - -i battery-good-symbolic \ - -t 10000 \ - -h string:x-canonical-private-synchronous:battery \ - "Battery" "$1" -} - - -case "$BLOCK_BUTTON" in - # ugly must do better - 1) - INF=$(inxi -B --extra 3 -c 0 -y 1) - REM=$(acpi | cut -d , -f 3) - DAT=$(echo "$INF$REM" | sed -e 's/^[ \t]*//') - notify "$DAT" - ;; - 3) - notify "$(acpi -b | awk -F ': |, ' '{printf "%s\n%s\n", $2, $4}')" - ;; -esac +# This is updated by signal 2, so 2 + 34 = +# kill -36 $(pidof dwmblocks) or +# pkill -RTMIN+2 dwmblocks # Loop through all attached batteries. for battery in /sys/class/power_supply/BAT?*; do @@ -43,18 +26,33 @@ for battery in /sys/class/power_supply/BAT?*; do fi case "$(cat "$battery/status" 2>&1)" in - Full) status="⚡ " ;; - Discharging) + + "Full") + status="⚡" + ;; + + "Discharging") if [ "$capacity" -le 20 ]; then status="$status" - color=1 fi - ;; - Charging) status="🔌$status" ;; - "Not charging") status="♻️" ;; - Unknown) status="? $status" ;; - *) exit 1 ;; + ;; + + "Charging") + status="🔌$status" + ;; + + "Not charging") + status="♻️" + ;; + + "Unknown") + status="? $status" + ;; + + *) + exit 1 + ;; esac - echo "┊ $status $capacity%" + echo -e "┊ $status $capacity%" done diff --git a/pw-cputemp b/pw-cputemp new file mode 100755 index 0000000..eda3871 --- /dev/null +++ b/pw-cputemp @@ -0,0 +1,26 @@ +#!/usr/bin/env bash +# requires joypixels font in dwm config.def.h + +CPU_TEMP=$(sensors | awk ' + /^Tdie|^Package id|^Core 0|^CPU|^temp1/ { + gsub(/[+°C]/, ""); + for (i=1; i<=NF; i++) { + if ($i ~ /^[0-9]+(\.[0-9]+)?$/) { + gsub(/\..*/, "", $i); + print $i; + exit; + } + } + }') + +# Debug CPU temperature detection, if not found, return N/A +if [ -z "$CPU_TEMP" ]; then + # Try simpler pattern as fallback + CPU_TEMP=$(sensors | grep -E '^(Core 0|Package id 0|CPU)' | awk '{print $3}' | tr -d '+°C' | head -n1) +fi + +[ -z "$CPU_TEMP" ] && CPU_TEMP="N/A" + +# Send to bar +echo -e " 🌡️ $CPU_TEMP°C ┊" + diff --git a/pw-date b/pw-date index 17105e5..05b2998 100755 --- a/pw-date +++ b/pw-date @@ -1,26 +1,17 @@ #!/usr/bin/env bash # unfortunately cal is a bit limited here, -# so I use orage, an xfce4 calendar app +# so I also use orage, an xfce4 calendar app +# This is updated by signal 1, so 1 + 34 = +# kill -35 $(pidof dwmblocks) or +# pkill -RTMIN+1 dwmblocks -# X220 screen is 1366x768 -width=300 -height=180 -X=$((1366-width)) -Y=24 # bar height + +echo -e "┊ $(date '+%a %d %b %T')" case $BLOCK_BUTTON in - 1) - pid=$(wmctrl -lp | awk '/Orage/{print $3}') - if (( pid > 0 )) ; then - kill -9 "$pid" - else - { orage > /dev/null 2>&1; } & - wmctrl -r "orage" -e "0,$X,$Y,$width,$height" - fi - ;; - - 3) + + 1) TODAY=$(date '+%-d') HEAD=$(cal | head -n1) BODY=$(cal | tail -n7 | sed -z "s|$TODAY|$TODAY|1") @@ -30,8 +21,24 @@ case $BLOCK_BUTTON in -h string:x-canonical-private-synchronous:calendar \ -u normal ;; + + 3) + # X220 screen is 1366x768 + width=300 + height=180 + X=$((1366-width)) + Y=24 # bar height - + # toggle Orage on/off + pid=$(wmctrl -lp | awk '/Orage/{print $3}') + if (( pid > 0 )) ; then + kill -9 "$pid" + else + { orage > /dev/null 2>&1; } & + wmctrl -r "orage" -e "0,$X,$Y,$width,$height" + fi + ;; + esac -echo "$(date '+%a %d %b %T')" +exit 0 diff --git a/pw-fan b/pw-fan new file mode 100755 index 0000000..4dea310 --- /dev/null +++ b/pw-fan @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +# requires joypixels font in dwm config.def.h + +# Try different fan sensors +FAN_SPEED=$(sensors | awk '/^fan|^cpu_fan/ {print $2}') +[ -z "$FAN_SPEED" ] && FAN_SPEED="N/A" + +# Send to bar +echo -e " 🌀 $FAN_SPEED ┊" + diff --git a/pw-music b/pw-music new file mode 100755 index 0000000..f0f9112 --- /dev/null +++ b/pw-music @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +STATUS=$(playerctl status) + +case $STATUS in + + "Playing") + TITLE=$(playerctl metadata title | sed s/_/\ /g) + META="${TITLE:-Title}" + curstatus=" 🎵 $META ┊" + ;; + + "Paused") + TITLE=$(playerctl metadata title | sed s/.m4a//g) + META="${TITLE:-Title}" + curstatus=" ⏸️ $META ┊" + ;; + + *) + curstatus=" Player Off ┊" + ;; +esac + +echo -e "$curstatus" + +case "$BLOCK_BUTTON" in + 1) + playerctl play-pause + ;; +esac diff --git a/pw-systemstats b/pw-systemstats deleted file mode 100755 index 76cec99..0000000 --- a/pw-systemstats +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env bash -# requires joypixels font in dwm config.def.h - -CPU_TEMP=$(sensors | awk ' - /^Tdie|^Package id|^Core 0|^CPU|^temp1/ { - gsub(/[+°C]/, ""); - for (i=1; i<=NF; i++) { - if ($i ~ /^[0-9]+(\.[0-9]+)?$/) { - gsub(/\..*/, "", $i); - print $i; - exit; - } - } - }') - -# Debug CPU temperature detection, if not found, return N/A -if [ -z "$CPU_TEMP" ]; then - # Try simpler pattern as fallback - CPU_TEMP=$(sensors | grep -E '^(Core 0|Package id 0|CPU)' | awk '{print $3}' | tr -d '+°C' | head -n1) -fi - -[ -z "$CPU_TEMP" ] && CPU_TEMP="N/A" - - -# Try different fan sensors -FAN_SPEED=$(sensors | awk '/^fan|^cpu_fan/ {print $2}') -[ -z "$FAN_SPEED" ] && FAN_SPEED="N/A" - - -# Send to bar -echo " 🌀 $FAN_SPEED ┊ 🌡️ $CPU_TEMP󰔄" - -# Clicking on bar -case $BLOCK_BUTTON in - 1) notify-send "$(sensors)";; - 2) notify-send "button 2 clicked";; - 3) notify-send "button 3 clicked";; -esac diff --git a/pw-update-fingerprint b/pw-update-fingerprint index e25a0b4..60239fb 100755 --- a/pw-update-fingerprint +++ b/pw-update-fingerprint @@ -13,4 +13,4 @@ KEY=$(msmtp --serverinfo --tls --tls-certcheck=off --host="$MAILSERVER" --port=" # replace tls_fingerprint line in .msmtprc sed -i "s/^tls_fingerprint.*/tls_fingerprint $KEY/g" .msmtprc -echo ".msmtprc has been updated with the latest $MAILSERVER fingerprint." +echo ".msmtprc has been updated with the latest mail.nagatha.fr fingerprint." -- cgit v1.2.3