• R/O
  • SSH

hnix: Commit

Hans' *nix things.


Commit MetaInfo

Revision4c4e79b007d8f967888389a564e4022d659a2801 (tree)
Time2014-05-07 01:56:11
Author <hans.t.tornqvist@aste...>

Log Message

First test for a simpler laptop ACPI thing.

Change Summary

Incremental Difference

diff -r 000000000000 -r 4c4e79b007d8 hacpi/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hacpi/Makefile Tue May 06 18:56:11 2014 +0200
@@ -0,0 +1,6 @@
1+PREFIX?=~/opt
2+
3+install:
4+ mkdir -p $(PREFIX)/bin
5+ cp -f hacpi.sh hacpibat.sh $(PREFIX)/bin
6+ chmod 755 $(PREFIX)/bin/{hacpi,hacpibat}.sh
diff -r 000000000000 -r 4c4e79b007d8 hacpi/hacpi.sh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hacpi/hacpi.sh Tue May 06 18:56:11 2014 +0200
@@ -0,0 +1,23 @@
1+#!/bin/sh
2+
3+# Listens to ACPI events.
4+
5+if [ $1 == "ac_adapter" ]; then
6+ if [ $4 -eq 0 ]; then
7+ # No power.
8+ xbacklight -set 80
9+ else
10+ # AC powah, let it roast!
11+ xbacklight -set 100
12+ fi
13+ exit 0
14+fi
15+if [ $1 == "button/lid" ]; then
16+ # Blank the screen.
17+ xset dpms force off
18+ exit 0
19+fi
20+if [ $1 == "button/power" ]; then
21+ # Do nothing. Maybe hibernate?
22+ exit 0
23+fi
diff -r 000000000000 -r 4c4e79b007d8 hacpi/hacpibat.sh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hacpi/hacpibat.sh Tue May 06 18:56:11 2014 +0200
@@ -0,0 +1,19 @@
1+#!/bin/sh
2+
3+# Cronned to check battery level.
4+
5+path=/sys/class/power_supply/BAT1
6+status=$path/status
7+
8+status=`cat $path/status`
9+if [ "Charging" \= $status ]; then
10+ # Charging, so we're ok.
11+ exit 0
12+fi
13+
14+alarm=`cat $path/alarm`
15+energy_now=`cat $path/energy_now`
16+if [ $alarm -gt $energy_now ]; then
17+ # Hibernate under alarm level.
18+ /opt/bin/acpi_hibernate
19+fi
Show on old repository browser