From f0b527f61e251a879a179ff4fef16baaa486c047 Mon Sep 17 00:00:00 2001 From: Philip Wittamore Date: Tue, 3 Jun 2025 19:56:25 +0200 Subject: update --- pw-battery | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ pw-date | 34 ++++++++++++++++++++++++++++++++++ pw-systemstats | 37 +++++++++++++++++++++++++++++++++++++ sb-battery | 52 ---------------------------------------------------- sb-date | 23 ----------------------- sb-systemstats | 45 --------------------------------------------- sb-theme | 28 ---------------------------- 7 files changed, 121 insertions(+), 148 deletions(-) create mode 100755 pw-battery create mode 100755 pw-date create mode 100755 pw-systemstats delete mode 100755 sb-battery delete mode 100755 sb-date delete mode 100755 sb-systemstats delete mode 100755 sb-theme diff --git a/pw-battery b/pw-battery new file mode 100755 index 0000000..e486769 --- /dev/null +++ b/pw-battery @@ -0,0 +1,50 @@ +#!/bin/sh +# Display the current battery status. + +notify() { + dunstify \ + -i battery-good-symbolic \ + -t 4000 \ + -h string:x-canonical-private-synchronous:battery \ + "Battery" "$1" +} + +case "$BLOCK_BUTTON" in + 1) notify "$(acpi -b | awk -F ': |, ' '{printf "%s\n%s\n", $2, $4}')" ;; + 3) ghostty -e "$EDITOR" "$0" ;; +esac + +# Loop through all attached batteries. +for battery in /sys/class/power_supply/BAT?*; do + # If non-first battery, print a space separator. + [ -n "${capacity+x}" ] && printf " " + + capacity="$(cat "$battery/capacity" 2>&1)" + if [ "$capacity" -gt 90 ]; then + status="󰁹 " + elif [ "$capacity" -gt 60 ]; then + status="󰁿 " + elif [ "$capacity" -gt 40 ]; then + status="󰁽 " + elif [ "$capacity" -gt 10 ]; then + status="󰁺 " + else + status="󰂎 " + fi + + case "$(cat "$battery/status" 2>&1)" in + Full) status="󱐋 " ;; + Discharging) + if [ "$capacity" -le 20 ]; then + status="$status" + color=1 + fi + ;; + Charging) status="󰚥$status" ;; + "Not charging") status=" " ;; + Unknown) status="? $status" ;; + *) exit 1 ;; + esac + + echo "| $status$capacity% |" +done diff --git a/pw-date b/pw-date new file mode 100755 index 0000000..10593c4 --- /dev/null +++ b/pw-date @@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +# X220 screen is 1366x768 +width=300 +height=180 +X=$((1366-width)) +Y=24 # bar height + +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) + TODAY=$(date '+%-d') + HEAD=$(cal | head -n1) + BODY=$(cal | tail -n7 | sed -z "s|$TODAY|$TODAY|1") + + dunstify "$HEAD" "$BODY" \ + -i office-calendar-symbolic \ + -h string:x-canonical-private-synchronous:calendar \ + -u normal + ;; + + +esac + +echo "$(date '+%a %d %b %T')" diff --git a/pw-systemstats b/pw-systemstats new file mode 100755 index 0000000..67ee45c --- /dev/null +++ b/pw-systemstats @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +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°C" + +# 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/sb-battery b/sb-battery deleted file mode 100755 index abfb53c..0000000 --- a/sb-battery +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh -# Display the current battery status. - -notify() { - dunstify \ - -i battery-good-symbolic \ - -t 4000 \ - -h string:x-canonical-private-synchronous:battery \ - "Battery" "$1" -} - -case "$BLOCK_BUTTON" in - 1) notify "$(acpi -b | awk -F ': |, ' '{printf "%s\n%s\n", $2, $4}')" ;; - 3) ghostty -e "$EDITOR" "$0" ;; -esac - -. sb-theme - -# Loop through all attached batteries. -for battery in /sys/class/power_supply/BAT?*; do - # If non-first battery, print a space separator. - [ -n "${capacity+x}" ] && printf " " - - capacity="$(cat "$battery/capacity" 2>&1)" - if [ "$capacity" -gt 90 ]; then - status="󰁹 " - elif [ "$capacity" -gt 60 ]; then - status="󰁿 " - elif [ "$capacity" -gt 40 ]; then - status="󰁽 " - elif [ "$capacity" -gt 10 ]; then - status="󰁺 " - else - status="󰂎 " - fi - - case "$(cat "$battery/status" 2>&1)" in - Full) status="󱐋 " ;; - Discharging) - if [ "$capacity" -le 20 ]; then - status="$status" - color=1 - fi - ;; - Charging) status="󰚥$status" ;; - "Not charging") status=" " ;; - Unknown) status="? $status" ;; - *) exit 1 ;; - esac - - display "$status$capacity%" "$color" -done diff --git a/sb-date b/sb-date deleted file mode 100755 index db08327..0000000 --- a/sb-date +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh -# Display the current time in HH:MM:SS. - -notify() { - notify-send --icon=office-calendar-symbolic \ - --hint=string:x-canonical-private-synchronous:"$1" "$@" -} - -case $BLOCK_BUTTON in - 3) - notify "This Month" "$(cal --color=always | - sed "s|..7m||;s|..0m||")" - appointments="$(calcurse -d1 \ - --format-apt "• %S - %E\n %m\n" \ - --format-event "• %m\n")" - [ -n "$appointments" ] && notify "Appointments" "$appointments" - ;; - 2) setsid --fork terminal -e calcurse ;; - 1) dunstify "This Month" "$(cal --color=always)";; -esac - -. sb-theme -display " $(date '+%a %d %b %T')" diff --git a/sb-systemstats b/sb-systemstats deleted file mode 100755 index 0f69661..0000000 --- a/sb-systemstats +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env bash - -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" - - -# Show warning icon if CPU temp is high -case $CPU_TEMP in - "N/A") COLOR="#d8dee9" && CPU_ICON="󰍛 ?" ;; - [7-9][6-9]|[8-9][0-9]|100) COLOR="#bf616a" && CPU_ICON="" ;; # Greater than 75 - [6][6-9]|7[0-5]) COLOR="#ebcb8b" && CPU_ICON="󰍛" ;; # Between 66 and 75 - *) COLOR="#a3be8c" && CPU_ICON="󰍛" ;; # 65 or below -esac - -# Send to bar -echo " 󰈐 $FAN_SPEED   $CPU_TEMP°C" - -# 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/sb-theme b/sb-theme deleted file mode 100755 index f04c205..0000000 --- a/sb-theme +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh -# Utility functions for theming statusbar scripts. - -display() { - if [ -n "$2" ]; then - color="$2" - else - case "$(basename "$0")" in - sb-mail) color=13 ;; - sb-music) color=14 ;; - sb-disk) color=10 ;; - sb-memory) color=15 ;; - sb-loadavg) color=11 ;; - sb-mic) color=9 ;; - sb-record) color=9 ;; - sb-volume) color=15 ;; - sb-battery) color=14 ;; - sb-date) color=12 ;; - sb-network) color=9 ;; - *) color=15 ;; - esac - fi - - case "$STATUSBAR" in - dwmblocks) echo "^C$color^$1" ;; - *) echo "$1" ;; - esac -} -- cgit v1.2.3