Share Code: Laptop Lid State
Adam Tauno Williams
awilliam at whitemice.org
Thu Dec 5 13:42:12 CET 2013
On Tue, 2013-07-30 at 17:00 +0100, Chris Angelico wrote:
> On Tue, Jul 30, 2013 at 3:06 PM, Devyn Collier Johnson
> <devyncjohnson at gmail.com> wrote:
> > Aloha everyone!
> > I attached a script that I thought I could share with everyone for your
> > help. This Python3 script only works on Unix systems. It prints the current
> > state of the lid. This can be used to make a script that performs some
> > action when the lid is closed or open. The script is licensed under LGPLv3
> > and I will soon upload it to my Launchpad account. Enjoy!
> There's... no Python code in that. Why not simply
> open("/proc/acpi/button/lid/LID/state") and read from it, instead of
> using cat and awk?
The correct way to implement this is to use the power management
services available on the System D-Bus.
Integrating with D-Bus from Python is easy!
More information about the Python-list