mirror of
https://github.com/pigmonkey/spark.git
synced 2026-07-26 01:17:22 +00:00
parent
4faff9eff5
commit
7531a055b2
3 changed files with 20 additions and 1 deletions
15
roles/laptop/files/lowbatt.sh
Executable file
15
roles/laptop/files/lowbatt.sh
Executable file
|
|
@ -0,0 +1,15 @@
|
|||
#!/bin/sh
|
||||
|
||||
capacity='low'
|
||||
|
||||
# Try to get an actual percentage.
|
||||
if [ -f /sys/class/power_supply/BAT0/capacity ]; then
|
||||
capacity="at `cat /sys/class/power_supply/BAT0/capacity`%"
|
||||
fi
|
||||
|
||||
# Build the message body.
|
||||
message="Battery is $capacity. We need more power, Scotty!"
|
||||
|
||||
# Make some noise.
|
||||
notify-send --urgency=critical "Low Battery" "$message"
|
||||
wall "Battery is low. $message"
|
||||
|
|
@ -1 +1,2 @@
|
|||
SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{capacity}=="[5-10]", RUN+="/usr/local/bin/lowbatt.sh"
|
||||
SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{capacity}=="[0-5]", RUN+="/usr/bin/systemctl suspend"
|
||||
|
|
|
|||
|
|
@ -5,5 +5,8 @@
|
|||
- name: Copy logind configuration file
|
||||
copy: src=logind.conf dest=/etc/systemd/logind.conf
|
||||
|
||||
- name: Push udev rule to suspend on low battery
|
||||
- name: Push low battery warning script
|
||||
copy: src=lowbatt.sh dest=/usr/local/bin/lowbatt mode=0755
|
||||
|
||||
- name: Push low battery udev rules
|
||||
copy: src=udev.rules dest=/etc/udev/rules.d/99-lowbat.rules
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue