From 5c1dc577453a8ea922b7c315f0f074ef51c8167c Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Thu, 10 Mar 2016 16:48:51 -0500 Subject: Add external battery and volume applet programs --- (limited to 'bin') diff --git a/bin/batmon b/bin/batmon new file mode 100755 index 0000000..fec22b7 --- /dev/null +++ b/bin/batmon @@ -0,0 +1,44 @@ +#!/bin/sh + +bat() +{ + eval "$(cat /sys/class/power_supply/BAT0/uevent | grep -E \ + '^POWER_SUPPLY_(STATUS|ENERGY_)')" + percentage=$(printf 'scale = 0; %d * 100 / %d;\n' \ + ${POWER_SUPPLY_ENERGY_NOW} ${POWER_SUPPLY_ENERGY_FULL} | bc) + case "${POWER_SUPPLY_STATUS}" in + 'Unknown') + status='?' + ;; + 'Charging') + status='⚡' + ;; + 'Discharging') + status='🔋' + ;; + 'Not charging') + status='!' + ;; + 'Full') + status='🔌' + ;; + esac + printf '%s%3d%%\n' "${status}" ${percentage} +} + +ac() +{ + status='🔌' + printf '%s\n' "${status}" +} + +main() +{ + if [ -e /sys/class/power_supply/BAT0/uevent ]; then + bat + else + ac + fi +} + +main "${@}" diff --git a/bin/volmon b/bin/volmon new file mode 100755 index 0000000..0b1b87e --- /dev/null +++ b/bin/volmon @@ -0,0 +1,10 @@ +#!/bin/sh + +main() +{ + vol="$(amixer get Master,0 | \ + sed -n 's/^.*Playback [0-9]* \[\([0-9]*\)%\].*$/\1/p')" + printf '🔉%3d%%\n' ${vol} +} + +main "${@}" -- cgit v0.9.1