1
0
Fork 0

minor updates

This commit is contained in:
Arthur Khachaturov 2024-09-19 04:25:07 +03:00
parent e3790a4f3f
commit 628baf3eea
No known key found for this signature in database
GPG key ID: CAC2B7EB6DF45D55
32 changed files with 655 additions and 123 deletions

View file

@ -4,22 +4,37 @@ shopt -s extglob
declare -a batteries
status_by_charge() {
capacity="$1"
if [ "$capacity" -ge 95 ]; then
echo ' '
elif [ "$capacity" -ge 65 ]; then
echo ' '
elif [ "$capacity" -ge 50 ]; then
echo ' '
elif [ "$capacity" -gt 20 ]; then
echo ' '
fi
}
for battery_path in /sys/class/power_supply/!(AC*); do
status="$(cat "${battery_path}/status")"
status="$(cat "${battery_path}/status")"
capacity="$(cat "${battery_path}/capacity")"
sep=$([ "$1" == "-s" ] && echo " ")
case "${status}" in
"Full") status_string="⚡" ;;
"Discharging") status_string="🔋" ;;
"Charging") status_string="🔌" ;;
"Not charging") status_string="🛑" ;;
"Unknown") status_string="♻️" ;;
*) status_string="??" ;;
"Full") status_symbol=" " ;;
"Discharging") status_symbol="$(status_by_charge "${capacity}")" ;;
"Charging") status_symbol="󱐥 " ;;
"Not charging") status_symbol="󱐤 " ;;
"Unknown") status_symbol="󰒲 " ;;
*) status_symbol="?? " ;;
esac
capacity="$(cat "${battery_path}/capacity")"
[ "$status" = "Discharging" ] && [ "$capacity" -le 25 ] && status_string="❗"
batteries+=("${status_string} ${capacity}%")
[ "$capacity" -eq 100 ] && status_symbol=" "
[ "$status" = "Discharging" ] && [ "$capacity" -le 20 ] && { status_symbol="❗"; [ -n "$sep" ] && sep="" || sep=" "; }
batteries+=("${status_symbol}${sep}${capacity}%")
done
echo "${batteries[@]}"

5
.local/bin/statusbar/sb-status Executable file
View file

@ -0,0 +1,5 @@
#!/bin/bash
FILEPATH="${XDG_RUNTIME_DIR}/my.itmo.pipe"
[ -f "${FILEPATH}" ] && cat "${FILEPATH}"

View file

@ -3,5 +3,5 @@
IFNAME="$(ip link show | grep 'wg_' | cut -d ' ' -f 2 | sed 's/://' | sed 's/wg_//' | tr '[:lower:]' '[:upper:]' | sed 's/_D/ (dpi)/')"
if [ -n "${IFNAME}" ]; then
echo "🛡️ ${IFNAME}"
echo "󰦝 ${IFNAME}"
fi