commit 05152fd0a5a85ee0f898be88e46d7d1bc9e88ee0 parent a9be078bcc2f1e6f677ddad587cfce2a731a3afe Author: clamiax <smoppy@gmail.com> Date: Tue, 8 Oct 2013 22:46:11 +0200 Initial commit. Diffstat:
A | acpi | | | 24 | ++++++++++++++++++++++++ |
A | dwmstatus | | | 57 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
2 files changed, 81 insertions(+), 0 deletions(-)
diff --git a/acpi b/acpi @@ -0,0 +1,24 @@ +#!/bin/bash + +SUSPEND_TO=mem +BATTCRITIC=2 + +suspend() { + echo -n $SUSPEND_TO > /sys/power/state +} + +getbattery() { + enow=$(cat /sys/class/power_supply/BAT0/energy_now) + efull=$(cat /sys/class/power_supply/BAT0/energy_full) + vnow=$(cat /sys/class/power_supply/BAT0/voltage_now) + + r=$(echo "($enow * 100 / $vnow) * 100 / ($efull * 100 / $vnow)" |bc) + echo $r +} + +main() { + t=$(getbattery) + [ $t -lt $BATTCRITIC ] && suspend +} + +main "$@" diff --git a/dwmstatus b/dwmstatus @@ -0,0 +1,57 @@ +#!/bin/bash + +getbattery() { + enow=$(cat /sys/class/power_supply/BAT0/energy_now) + efull=$(cat /sys/class/power_supply/BAT0/energy_full) + vnow=$(cat /sys/class/power_supply/BAT0/voltage_now) + + r=$(echo "($enow * 100 / $vnow) * 100 / ($efull * 100 / $vnow)" |bc) + echo "${r}%" +} + +getiwlink() { + s=$(/sbin/iwconfig $1 |head -1 |tr -s " " '.' |cut -d'.' -f3) + if [ "$s" != "off" ]; then + r="$(/sbin/iwconfig $1 |grep Quality | sed 's/:\|=/./g' |tr -d [:alpha:],[:space:] |cut -d'.' -f2 |cut -d'/' -f1)%" + else + r="off" + fi + + echo $r +} + +getdate() { + date +'%d/%m/%Y %H:%M' +} + +getfreq() { + freqs=$(cat /sys/devices/system/cpu/*/cpufreq/scaling_cur_freq) + freq="" + for f in $freqs + do + f="0.$(echo "$f / 10000" |bc)" + [ -z "$freq" ] && freq=$f || freq="${freq} $f" + done + + echo $freq +} + +gettemp() { + t=$(cat /sys/class/hwmon/hwmon*/device/temp1_input) + t=$(echo $t / 1000 |bc) + r=$(printf "%d" $t) + echo "${r}C" +} + +main() { + battery=$(getbattery) + iwlink=$(getiwlink wlan0) + date=$(getdate) + freq=$(getfreq) + temp=$(gettemp) + + status="F:[$freq] B:$battery T:$temp W:$iwlink $date" + echo "$status" +} + +main "$@"