commit 484b9ab92ac61871aa2c6707e862c6c557716736 parent 07da1486e66f9847d47f82964000a92e0f7a3547 Author: Alex Balgavy <alex@balgavy.eu> Date: Tue, 4 May 2021 16:55:57 +0200 Scripts for dwmblocks Diffstat:
M | scripts/battery | | | 9 | ++------- |
A | scripts/dwmblock-battery | | | 12 | ++++++++++++ |
A | scripts/dwmblock-brightness | | | 16 | ++++++++++++++++ |
3 files changed, 30 insertions(+), 7 deletions(-)
diff --git a/scripts/battery b/scripts/battery @@ -2,13 +2,8 @@ os=$(uname -s | tr '[:upper:]' '[:lower:]') case "$os" in linux*) - if [ -f /sys/class/power_supply/BAT0/uevent ]; then - state="$(awk -F '=' '/POWER_SUPPLY_STATUS/ {print $2}' /sys/class/power_supply/BAT0/uevent)" - percent="$(awk -F '=' '/POWER_SUPPLY_CAPACITY=/ {print $2}' /sys/class/power_supply/BAT0/uevent)" - else - printf "No such file: /sys/class/power_supply/BAT0/uevent.\nNo other methods to find battery charge implemented.\n" >&2 - exit 1 - fi + state="$(cat /sys/class/power_supply/BAT0/status)" + percent="$(cat /sys/class/power_supply/BAT0/capacity)" ;; darwin*) battstatus="$(pmset -g batt)" diff --git a/scripts/dwmblock-battery b/scripts/dwmblock-battery @@ -0,0 +1,12 @@ +#!/bin/sh +case "$BUTTON" in + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac +printf "%s%%\n" "$(battery | tac | tr -d '\n' | sed ' + s/Charging/⚡/; + /Discharging[01]*[0-9]$/s/Discharging/‼ /; + s/Discharging/🔋 /; + s/Not charging/⛔/; + s/Full/✅/; + s/Unknown/‽‽/' \ + | tac | tr -d '\n')" diff --git a/scripts/dwmblock-brightness b/scripts/dwmblock-brightness @@ -0,0 +1,16 @@ +#!/bin/sh +case "$BUTTON" in + 1) "$TERMINAL" -e backlight-brightness ;; + 3) backlight-brightness -s 100 ;; + 4) + backlight-brightness '-10' + pkill -RTMIN+1 dwmblocks + ;; + 5) + backlight-brightness '+20' + pkill -RTMIN+1 dwmblocks + ;; + 6) "$TERMINAL" -e "$EDITOR" "$0" ;; +esac + +paste -d '/' /sys/class/backlight/*/brightness /sys/class/backlight/*/max_brightness