Skip to content

Instantly share code, notes, and snippets.

@Apsu
Created August 23, 2012 05:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Apsu/3433066 to your computer and use it in GitHub Desktop.
Save Apsu/3433066 to your computer and use it in GitHub Desktop.
power_supply udev rule
ACTION=="change", SUBSYSTEM=="power_supply", ENV{POWER_SUPPLY_ONLINE}=="[01]", RUN+="power %E{POWER_SUPPLY_ONLINE}"
#!/bin/bash
if (($1)); then # 0 = battery
powerup
else # 1 = plug
powerdown
fi
@Apsu
Copy link
Author

Apsu commented Aug 23, 2012

The 10-power.rules file goes in /etc/udev/rules.d
The power file goes in /lib/udev/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment