System Inactivity Notifier v1.6
Hi all,
I've attached the final version of SIN, a user inactivity monitor posted few days ago on this list. Since then a couple of things have been improved. For example, the acpi events have been substituted by _uevents_ (thanks Arjan for the hint!), _sysfs_ has been preferred to procfs and the event triggering logic has been optimized. Moreover, this version takes advantage from the PM callbacks, in order to correctly preserve the state among several suspend/resume cycles. The patch also contains what is needed to test conveniently the driver with udev-103. Thanks to all for the support.
Best,
Alessandro
Makefile +43 -0
@@ -0,0 +1,43 @@ +MODLPATH = kernel/drivers/char + +#DEBUG="-D SIN_DEBUG" + +MODL = sinmod +OBJS = sin.o sysfs.o table.o input_enumerator.o + +SRCS := $(patsubst %.o,%.c,$(OBJS)) +HDRS := $(patsubst %.o,%.h,$(OBJS)) +CMDS := $(patsubst %.o,.%.o.cmd,$(OBJS)) + +ifneq ($(KERNELRELEASE),) + EXTRA_CFLAGS := $(DEBUG) + obj-m := $(MODL).o + $(MODL)-objs := $(OBJS) +else + KDIR := /lib/modules/$(shell uname -r)/build + PWD := $(shell pwd) + +all: $(MODL).ko + +$(MODL).ko: $(SRCS) $(HDRS) + @$(MAKE) -C $(KDIR) M=$(PWD) modules + +im: $(MODL).ko + @sudo insmod $(MODL).ko + +rm: + @sudo rmmod $(MODL) + +rmf: + @sudo rmmod -f $(MODL) + +install: + @sudo $(MAKE) INSTALL_MOD_DIR=$(MODLPATH) -C $(KDIR) M=$(PWD) modules_install + +modules_install: + @$(MAKE) INSTALL_MOD_DIR=$(MODLPATH) -C $(KDIR) M=$(PWD) modules_install + +clean: + @$(MAKE) -C $(KDIR) M=$(PWD) clean + @rm -f Module.symvers +endif
debug.h +36 -0
@@ -0,0 +1,36 @@ +/* +* Copyright (C) 2007 Alessandro Di Marco +*/ + +/* +* This file is part of SIN. +* +* SIN is free software; you can redistribute it and/or modify it under the +* terms of the GNU General Public License as published by the Free Software +* Foundation; version 2 of the License. +* +* SIN is distributed in the hope that it will be useful, but WITHOUT ANY +* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +* details. +* +* You should have received a copy of the GNU General Public License along +* with SIN; if not, write to the Free Software Foundation, Inc., 51 Franklin +* St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef DEBUG_H +#define DEBUG_H + +#ifdef SIN_DEBUG +extern int debug; +#define set_debug (val) debug = (val) +#define printd(fmt...) if (unlikely(debug)) { printk("SIN: " fmt); } +#else +#define SORRY "SIN: debugging support was disabled at compile time, sorry!\n" + +#define set_debug (val) if (val) { printk(KERN_DEBUG SORRY); } +#define printd(fmt...) +#endif + +#endif /* DEBUG_H */
etc/sin/rules.sh +43 -0
43 lines not on this page · raw message
etc/sin/setup.sh +11 -0
@@ -0,0 +1,11 @@ +#!/bin/bash + +set $* + +STATE="`cat /proc/acpi/ac_adapter/ACAD/state | grep off-line`" + +if [ -n "${STATE}" ] ; then + cat /etc/sin/table.bat >/sys/class/misc/sin/table +else + cat /etc/sin/table.ac >/sys/class/misc/sin/table +fi
etc/sin/table.ac +8 -0
@@ -0,0 +1,8 @@ +0 +2 3 +0 1 +0 +resume +1200 dim +3500 blank +27000 sleep
etc/sin/table.bat +8 -0
@@ -0,0 +1,8 @@ +0 +2 3 +0 1 +0 +resume +500 dim +900 blank +3000 sleep
etc/udev/rules.d/99-sin.rules +2 -0
@@ -0,0 +1,2 @@ +KERNEL=="sin", SUBSYSTEM=="misc", ACTION=="add", RUN+="/etc/sin/setup.sh" +KERNEL=="sin", SUBSYSTEM=="misc", ACTION=="change", RUN+="/etc/sin/rules.sh"
gentable.sh +146 -0
146 lines not on this page · raw message
input_enumerator.c +198 -0
198 lines not on this page · raw message
input_enumerator.h +47 -0
47 lines not on this page · raw message
sin.c +390 -0
390 lines not on this page · raw message
sin.h +82 -0
82 lines not on this page · raw message
sysfs.c +122 -0
122 lines not on this page · raw message
sysfs.h +28 -0
@@ -0,0 +1,28 @@ +/* +* Copyright (C) 2007 Alessandro Di Marco +*/ + +/* +* This file is part of SIN. +* +* SIN is free software; you can redistribute it and/or modify it under the +* terms of the GNU General Public License as published by the Free Software +* Foundation; version 2 of the License. +* +* SIN is distributed in the hope that it will be useful, but WITHOUT ANY +* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +* details. +* +* You should have received a copy of the GNU General Public License along +* with SIN; if not, write to the Free Software Foundation, Inc., 51 Franklin +* St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef SYSFS_H +#define SYSFS_H + +extern int start_sysfs (struct device *dev); +extern void stop_sysfs (void ); + +#endif /* SYSFS_H */
table.c +353 -0
353 lines not on this page · raw message
table.h +79 -0
79 lines not on this page · raw message
uniq.h +59 -0
59 lines not on this page · raw message
--
Tradition is what you resort to when you don't have the time or the money to do it right. - Kurt Herbert Alder