1/* 2 * Copyright 2013, Jérôme Duval, korli@users.berlios.de. 3 * Copyright 2005, Nathan Whitehorn. 4 * 5 * Distributed under the terms of the MIT License. 6 */ 7 8 9#include "lid_monitor.h" 10 11#include <Messenger.h> 12#include <Roster.h> 13 14#include <stdio.h> 15 16#include <RosterPrivate.h> 17 18 19LidMonitor::LidMonitor() 20{ 21 int fd = open("/dev/power/acpi_lid/0", O_RDONLY); 22 if (fd > 0) 23 fFDs.insert(fd); 24} 25 26 27LidMonitor::~LidMonitor() 28{ 29 for (std::set<int>::iterator it = fFDs.begin(); it != fFDs.end(); ++it) 30 close(*it); 31} 32 33 34void 35LidMonitor::HandleEvent(int fd) 36{ 37 uint8 status; 38 if (read(fd, &status, 1) != 1) 39 return; 40 41 if (status == 1) 42 printf("lid status 1\n"); 43} 44