power_daemon: added lid_monitor.
Thanks Rene!
This commit is contained in:
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2013, Jérôme Duval, [email protected].
|
||||||
|
* Copyright 2005, Nathan Whitehorn.
|
||||||
|
*
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "lid_monitor.h"
|
||||||
|
|
||||||
|
#include <Messenger.h>
|
||||||
|
#include <Roster.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <RosterPrivate.h>
|
||||||
|
|
||||||
|
|
||||||
|
LidMonitor::LidMonitor()
|
||||||
|
{
|
||||||
|
fFD = open("/dev/power/acpi_lid/0", O_RDONLY);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LidMonitor::~LidMonitor()
|
||||||
|
{
|
||||||
|
if (fFD > 0)
|
||||||
|
close(fFD);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
LidMonitor::HandleEvent()
|
||||||
|
{
|
||||||
|
if (fFD <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
uint8 status;
|
||||||
|
read(fFD, &status, 1);
|
||||||
|
|
||||||
|
if (status == 1) {
|
||||||
|
printf("lid status 1\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2005-2013, Haiku, Inc.
|
||||||
|
* Distributed under the terms of the MIT license.
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Nathan Whitehorn
|
||||||
|
*/
|
||||||
|
#ifndef _LID_MONITOR_H
|
||||||
|
#define _LID_MONITOR_H
|
||||||
|
|
||||||
|
|
||||||
|
class LidMonitor {
|
||||||
|
public:
|
||||||
|
LidMonitor();
|
||||||
|
~LidMonitor();
|
||||||
|
|
||||||
|
void HandleEvent();
|
||||||
|
|
||||||
|
int FD() const { return fFD; }
|
||||||
|
private:
|
||||||
|
int fFD;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _LID_MONITOR_H
|
||||||
Reference in New Issue
Block a user