wok-current rev 1512

acpid: acpi_fakekey added
author Dominique Corbex <domcox@users.sourceforge.net>
date Mon Oct 06 19:15:21 2008 +0200 (2008-10-06)
parents 3d99ecce2d4b
children 7f21235a6721
files acpid/acpi_fakekey acpid/acpi_fakekey.c acpid/key-constants acpid/receipt acpid/stuff/acpi/ac.sh acpid/stuff/acpi/battery.sh acpid/stuff/acpi/events/ac acpid/stuff/acpi/events/battery acpid/stuff/acpi_fakekey.c acpid/stuff/init.d/acpid
line diff
     1.1 Binary file acpid/acpi_fakekey has changed
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/acpid/acpi_fakekey.c	Mon Oct 06 19:15:21 2008 +0200
     2.3 @@ -0,0 +1,64 @@
     2.4 +#include <unistd.h>
     2.5 +#include <fcntl.h>
     2.6 +#include <string.h>
     2.7 +#include <stdlib.h>
     2.8 +#include <stdio.h>
     2.9 +#include <linux/input.h>
    2.10 +
    2.11 +#define TestBit(bit, array) (array[(bit) / 8] & (1 << ((bit) % 8)))
    2.12 +
    2.13 +int find_keyboard() {
    2.14 +	int i, j;
    2.15 +        int fd;
    2.16 +        char filename[32];
    2.17 +        char key_bitmask[(KEY_MAX + 7) / 8];
    2.18 +
    2.19 +        for (i=0; i<32; i++) {
    2.20 +                snprintf(filename,sizeof(filename), "/dev/input/event%d", i);
    2.21 +
    2.22 +                fd = open(filename, O_RDWR);
    2.23 +                ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(key_bitmask)), key_bitmask);
    2.24 +
    2.25 +		for (j = 0; j < BTN_MISC; j++) {
    2.26 +			if (TestBit(j, key_bitmask))
    2.27 +				break;
    2.28 +		}
    2.29 +
    2.30 +                if (j < BTN_MISC) {
    2.31 +                        return fd;
    2.32 +                }
    2.33 +		close (fd);
    2.34 +        }
    2.35 +        return 0;
    2.36 +}
    2.37 +
    2.38 +int main(int argc, char** argv) {
    2.39 +	int fd;
    2.40 +	int key;
    2.41 +	struct input_event event;
    2.42 +
    2.43 +	if (argc == 2) {
    2.44 +		key = atoi(argv[1]);
    2.45 +	} else {
    2.46 +		return 1;
    2.47 +	}
    2.48 +
    2.49 +	fd = find_keyboard();
    2.50 +
    2.51 +	if (!fd) {
    2.52 +		return 2;
    2.53 +	}
    2.54 +
    2.55 +	event.type = EV_KEY;
    2.56 +	event.code = key;
    2.57 +	event.value = 1;
    2.58 +	write(fd, &event, sizeof event);
    2.59 +
    2.60 +	event.type = EV_KEY;
    2.61 +	event.code = key;
    2.62 +	event.value = 0;
    2.63 +	write(fd, &event, sizeof event);
    2.64 +	
    2.65 +	return 0;
    2.66 +}
    2.67 +
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/acpid/key-constants	Mon Oct 06 19:15:21 2008 +0200
     3.3 @@ -0,0 +1,246 @@
     3.4 +# Generated from $INPUT dated mar aoû 26 22:06:20 CEST 2008
     3.5 +KEY_RESERVED=0
     3.6 +KEY_ESC=1
     3.7 +KEY_1=2
     3.8 +KEY_2=3
     3.9 +KEY_3=4
    3.10 +KEY_4=5
    3.11 +KEY_5=6
    3.12 +KEY_6=7
    3.13 +KEY_7=8
    3.14 +KEY_8=9
    3.15 +KEY_9=10
    3.16 +KEY_0=11
    3.17 +KEY_MINUS=12
    3.18 +KEY_EQUAL=13
    3.19 +KEY_BACKSPACE=14
    3.20 +KEY_TAB=15
    3.21 +KEY_Q=16
    3.22 +KEY_W=17
    3.23 +KEY_E=18
    3.24 +KEY_R=19
    3.25 +KEY_T=20
    3.26 +KEY_Y=21
    3.27 +KEY_U=22
    3.28 +KEY_I=23
    3.29 +KEY_O=24
    3.30 +KEY_P=25
    3.31 +KEY_LEFTBRACE=26
    3.32 +KEY_RIGHTBRACE=27
    3.33 +KEY_ENTER=28
    3.34 +KEY_LEFTCTRL=29
    3.35 +KEY_A=30
    3.36 +KEY_S=31
    3.37 +KEY_D=32
    3.38 +KEY_F=33
    3.39 +KEY_G=34
    3.40 +KEY_H=35
    3.41 +KEY_J=36
    3.42 +KEY_K=37
    3.43 +KEY_L=38
    3.44 +KEY_SEMICOLON=39
    3.45 +KEY_APOSTROPHE=40
    3.46 +KEY_GRAVE=41
    3.47 +KEY_LEFTSHIFT=42
    3.48 +KEY_BACKSLASH=43
    3.49 +KEY_Z=44
    3.50 +KEY_X=45
    3.51 +KEY_C=46
    3.52 +KEY_V=47
    3.53 +KEY_B=48
    3.54 +KEY_N=49
    3.55 +KEY_M=50
    3.56 +KEY_COMMA=51
    3.57 +KEY_DOT=52
    3.58 +KEY_SLASH=53
    3.59 +KEY_RIGHTSHIFT=54
    3.60 +KEY_KPASTERISK=55
    3.61 +KEY_LEFTALT=56
    3.62 +KEY_SPACE=57
    3.63 +KEY_CAPSLOCK=58
    3.64 +KEY_F1=59
    3.65 +KEY_F2=60
    3.66 +KEY_F3=61
    3.67 +KEY_F4=62
    3.68 +KEY_F5=63
    3.69 +KEY_F6=64
    3.70 +KEY_F7=65
    3.71 +KEY_F8=66
    3.72 +KEY_F9=67
    3.73 +KEY_F10=68
    3.74 +KEY_NUMLOCK=69
    3.75 +KEY_SCROLLLOCK=70
    3.76 +KEY_KP7=71
    3.77 +KEY_KP8=72
    3.78 +KEY_KP9=73
    3.79 +KEY_KPMINUS=74
    3.80 +KEY_KP4=75
    3.81 +KEY_KP5=76
    3.82 +KEY_KP6=77
    3.83 +KEY_KPPLUS=78
    3.84 +KEY_KP1=79
    3.85 +KEY_KP2=80
    3.86 +KEY_KP3=81
    3.87 +KEY_KP0=82
    3.88 +KEY_KPDOT=83
    3.89 +KEY_ZENKAKUHANKAKU=85
    3.90 +KEY_102ND=86
    3.91 +KEY_F11=87
    3.92 +KEY_F12=88
    3.93 +KEY_RO=89
    3.94 +KEY_KATAKANA=90
    3.95 +KEY_HIRAGANA=91
    3.96 +KEY_HENKAN=92
    3.97 +KEY_KATAKANAHIRAGANA=93
    3.98 +KEY_MUHENKAN=94
    3.99 +KEY_KPJPCOMMA=95
   3.100 +KEY_KPENTER=96
   3.101 +KEY_RIGHTCTRL=97
   3.102 +KEY_KPSLASH=98
   3.103 +KEY_SYSRQ=99
   3.104 +KEY_RIGHTALT=100
   3.105 +KEY_LINEFEED=101
   3.106 +KEY_HOME=102
   3.107 +KEY_UP=103
   3.108 +KEY_PAGEUP=104
   3.109 +KEY_LEFT=105
   3.110 +KEY_RIGHT=106
   3.111 +KEY_END=107
   3.112 +KEY_DOWN=108
   3.113 +KEY_PAGEDOWN=109
   3.114 +KEY_INSERT=110
   3.115 +KEY_DELETE=111
   3.116 +KEY_MACRO=112
   3.117 +KEY_MUTE=113
   3.118 +KEY_VOLUMEDOWN=114
   3.119 +KEY_VOLUMEUP=115
   3.120 +KEY_POWER=116
   3.121 +KEY_KPEQUAL=117
   3.122 +KEY_KPPLUSMINUS=118
   3.123 +KEY_PAUSE=119
   3.124 +KEY_KPCOMMA=121
   3.125 +KEY_HANGEUL=122
   3.126 +KEY_HANJA=123
   3.127 +KEY_YEN=124
   3.128 +KEY_LEFTMETA=125
   3.129 +KEY_RIGHTMETA=126
   3.130 +KEY_COMPOSE=127
   3.131 +KEY_STOP=128
   3.132 +KEY_AGAIN=129
   3.133 +KEY_PROPS=130
   3.134 +KEY_UNDO=131
   3.135 +KEY_FRONT=132
   3.136 +KEY_COPY=133
   3.137 +KEY_OPEN=134
   3.138 +KEY_PASTE=135
   3.139 +KEY_FIND=136
   3.140 +KEY_CUT=137
   3.141 +KEY_HELP=138
   3.142 +KEY_MENU=139
   3.143 +KEY_CALC=140
   3.144 +KEY_SETUP=141
   3.145 +KEY_SLEEP=142
   3.146 +KEY_WAKEUP=143
   3.147 +KEY_FILE=144
   3.148 +KEY_SENDFILE=145
   3.149 +KEY_DELETEFILE=146
   3.150 +KEY_XFER=147
   3.151 +KEY_PROG1=148
   3.152 +KEY_PROG2=149
   3.153 +KEY_WWW=150
   3.154 +KEY_MSDOS=151
   3.155 +KEY_COFFEE=152
   3.156 +KEY_DIRECTION=153
   3.157 +KEY_CYCLEWINDOWS=154
   3.158 +KEY_MAIL=155
   3.159 +KEY_BOOKMARKS=156
   3.160 +KEY_COMPUTER=157
   3.161 +KEY_BACK=158
   3.162 +KEY_FORWARD=159
   3.163 +KEY_CLOSECD=160
   3.164 +KEY_EJECTCD=161
   3.165 +KEY_EJECTCLOSECD=162
   3.166 +KEY_NEXTSONG=163
   3.167 +KEY_PLAYPAUSE=164
   3.168 +KEY_PREVIOUSSONG=165
   3.169 +KEY_STOPCD=166
   3.170 +KEY_RECORD=167
   3.171 +KEY_REWIND=168
   3.172 +KEY_PHONE=169
   3.173 +KEY_ISO=170
   3.174 +KEY_CONFIG=171
   3.175 +KEY_HOMEPAGE=172
   3.176 +KEY_REFRESH=173
   3.177 +KEY_EXIT=174
   3.178 +KEY_MOVE=175
   3.179 +KEY_EDIT=176
   3.180 +KEY_SCROLLUP=177
   3.181 +KEY_SCROLLDOWN=178
   3.182 +KEY_KPLEFTPAREN=179
   3.183 +KEY_KPRIGHTPAREN=180
   3.184 +KEY_NEW=181
   3.185 +KEY_REDO=182
   3.186 +KEY_F13=183
   3.187 +KEY_F14=184
   3.188 +KEY_F15=185
   3.189 +KEY_F16=186
   3.190 +KEY_F17=187
   3.191 +KEY_F18=188
   3.192 +KEY_F19=189
   3.193 +KEY_F20=190
   3.194 +KEY_F21=191
   3.195 +KEY_F22=192
   3.196 +KEY_F23=193
   3.197 +KEY_F24=194
   3.198 +KEY_PLAYCD=200
   3.199 +KEY_PAUSECD=201
   3.200 +KEY_PROG3=202
   3.201 +KEY_PROG4=203
   3.202 +KEY_SUSPEND=205
   3.203 +KEY_CLOSE=206
   3.204 +KEY_PLAY=207
   3.205 +KEY_FASTFORWARD=208
   3.206 +KEY_BASSBOOST=209
   3.207 +KEY_PRINT=210
   3.208 +KEY_HP=211
   3.209 +KEY_CAMERA=212
   3.210 +KEY_SOUND=213
   3.211 +KEY_QUESTION=214
   3.212 +KEY_EMAIL=215
   3.213 +KEY_CHAT=216
   3.214 +KEY_SEARCH=217
   3.215 +KEY_CONNECT=218
   3.216 +KEY_FINANCE=219
   3.217 +KEY_SPORT=220
   3.218 +KEY_SHOP=221
   3.219 +KEY_ALTERASE=222
   3.220 +KEY_CANCEL=223
   3.221 +KEY_BRIGHTNESSDOWN=224
   3.222 +KEY_BRIGHTNESSUP=225
   3.223 +KEY_MEDIA=226
   3.224 +KEY_SWITCHVIDEOMODE=227
   3.225 +KEY_KBDILLUMTOGGLE=228
   3.226 +KEY_KBDILLUMDOWN=229
   3.227 +KEY_KBDILLUMUP=230
   3.228 +KEY_SEND=231
   3.229 +KEY_REPLY=232
   3.230 +KEY_FORWARDMAIL=233
   3.231 +KEY_SAVE=234
   3.232 +KEY_DOCUMENTS=235
   3.233 +KEY_BATTERY=236
   3.234 +KEY_BLUETOOTH=237
   3.235 +KEY_WLAN=238
   3.236 +KEY_UWB=239
   3.237 +KEY_UNKNOWN=240
   3.238 +KEY_VIDEO_NEXT=241
   3.239 +KEY_VIDEO_PREV=242
   3.240 +KEY_BRIGHTNESS_CYCLE=243
   3.241 +KEY_BRIGHTNESS_ZERO=244
   3.242 +KEY_DISPLAY_OFF=245
   3.243 +KEY_WIMAX=246
   3.244 +KEY_LOCK=$KEY_COFFEE
   3.245 +KEY_LIGHT=$KEY_F19
   3.246 +KEY_VIDEOOUT=$KEY_F20
   3.247 +KEY_ROTATESCREEN=$KEY_F21
   3.248 +KEY_VIDEOMODECYCLE=$KEY_F22
   3.249 +KEY_PRESENTATION=\KEY_F23
     4.1 --- a/acpid/receipt	Sun Oct 05 23:16:15 2008 +0000
     4.2 +++ b/acpid/receipt	Mon Oct 06 19:15:21 2008 +0200
     4.3 @@ -9,10 +9,27 @@
     4.4  TARBALL="$PACKAGE-$VERSION.tar.gz"
     4.5  WEB_SITE="http://acpid.sourceforge.net/"
     4.6  WGET_URL="$SF_MIRROR/$PACKAGE/$TARBALL"
     4.7 +KEY_FILE="key-constants"
     4.8  
     4.9  # Rules to configure and make the package.
    4.10  compile_rules()
    4.11  {
    4.12 +	# Build acpi_fakekey utility
    4.13 +	cp -a stuff/acpi_fakekey.c .
    4.14 +	gcc -g -Wall -o acpi_fakekey acpi_fakekey.c
    4.15 +	# Generate key constants file
    4.16 +	INPUT_H="/usr/include/linux/input.h"
    4.17 +	echo -n '# Generated from $INPUT dated ' > $KEY_FILE
    4.18 +	date -r $INPUT_H >> $KEY_FILE
    4.19 +   	echo "KEY_RESERVED=0" >> $KEY_FILE
    4.20 +	awk '/define KEY_/{if($3 <= 255 && $3 > 0) print $2"="$3}' $INPUT_H | sort -nt'=' -k2 >> $KEY_FILE
    4.21 +	echo "KEY_LOCK=\$KEY_COFFEE" >> $KEY_FILE
    4.22 +	echo "KEY_LIGHT=\$KEY_F19" >> $KEY_FILE
    4.23 +	echo "KEY_VIDEOOUT=\$KEY_F20" >> $KEY_FILE
    4.24 +	echo "KEY_ROTATESCREEN=\$KEY_F21" >> $KEY_FILE
    4.25 +	echo "KEY_VIDEOMODECYCLE=\$KEY_F22" >> $KEY_FILE
    4.26 +	echo "KEY_PRESENTATION=\KEY_F23" >> $KEY_FILE
    4.27 +	# Build acpid
    4.28  	cd $src
    4.29  	make clean && make
    4.30  	make INSTPREFIX=$PWD/_pkg install
    4.31 @@ -22,13 +39,19 @@
    4.32  genpkg_rules()
    4.33  {
    4.34  	mkdir -p $fs/usr
    4.35 +	# acpid
    4.36 +	cp -a $_pkg/usr/sbin $fs/usr
    4.37 +	# acpi_listen
    4.38  	cp -a $_pkg/usr/bin $fs/usr
    4.39 -	cp -a $_pkg/usr/sbin $fs/usr
    4.40 -	mkdir -p $fs/etc/init.d
    4.41 -	cp -a stuff/acpid $fs/etc/init.d
    4.42 -	mkdir -p $fs/etc/acpi/events
    4.43 -	cp -a stuff/power $fs/etc/acpi/events
    4.44 +	# acpid conf files
    4.45 +	mkdir -p $fs/etc
    4.46 +	cp -a stuff/init.d $fs/etc/
    4.47 +	cp -a stuff/acpi $fs/etc/
    4.48 +	mkdir -p $fs/var/log/
    4.49  	touch $fs/var/log/acpid.log && chmod 700 $fs/var/log/acpid.log
    4.50 +	# acpi_fakekey
    4.51 +	cp -a acpi_fakekey $fs/usr/bin
    4.52 +	cp -a $KEY_FILE $fs/etc/acpi/
    4.53  }
    4.54  
    4.55  # Pre and post remove commands for Tazpkg                                                                              
    4.56 @@ -41,7 +64,12 @@
    4.57  post_remove()
    4.58  {
    4.59  	if [ `ls /etc/acpi/events | wc -l` -eq 0 ]; then
    4.60 -		echo -n "Removing /etc/acpi..."
    4.61 +		echo -n "Removing /etc/acpi/events"
    4.62 +		rm -rf /etc/acpi/events
    4.63 +		status
    4.64 +	fi
    4.65 +	if [ `ls /etc/acpi | wc -l` -eq 0 ]; then
    4.66 +		echo -n "Removing /etc/acpi"
    4.67  		rm -rf /etc/acpi
    4.68  		status
    4.69  	fi
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/acpid/stuff/acpi/ac.sh	Mon Oct 06 19:15:21 2008 +0200
     5.3 @@ -0,0 +1,40 @@
     5.4 +#!/bin/sh
     5.5 +##
     5.6 +## ac.sh
     5.7 +## 
     5.8 +## Made by Dominique Corbex
     5.9 +## Login   <domcox@users.sourceforge.net>
    5.10 +## 
    5.11 +## Started on  Mon Oct  6 12:56:58 2008 Dominique Corbex
    5.12 +## Last update 
    5.13 +##
    5.14 +
    5.15 +# Disable laptop mode
    5.16 +# When laptop mode is enabled, the kernel will try to be smart
    5.17 +# about when to do IO, to give the disk and the SATA links as
    5.18 +# much time as possible in a low power state.
    5.19 +
    5.20 +if [ -e /proc/sys/vm/laptop_mode ] ; then
    5.21 +    echo "Disabling laptop mode"
    5.22 +    echo 0 > /proc/sys/vm/laptop_mode
    5.23 +fi
    5.24 +
    5.25 +# AC97 audio power saving mode
    5.26 +# The AC97 onboard audio chips support power saving, where the
    5.27 +# analog parts (codec) are powered down when no program is using
    5.28 +# the audio device.
    5.29 +
    5.30 +if [ -e /sys/module/snd_ac97_codec/parameters/power_save ] ; then
    5.31 +    echo "Enabling AC97 audio power saving mode"
    5.32 +    echo 0 > /sys/module/snd_ac97_codec/parameters/power_save
    5.33 +fi
    5.34 +
    5.35 +# The VM writeback time
    5.36 +# The VM subsystem caching allows the kernel to group consecutive
    5.37 +# writes into one big write, and to generally optimize the disk IO
    5.38 +# to be the most efficient. 
    5.39 +
    5.40 +if [ -e /proc/sys/vm/dirty_writeback_centisecs ] ; then
    5.41 +    echo "Writeback time reset back to 500ms"
    5.42 +    echo 500 > /proc/sys/vm/dirty_writeback_centisecs
    5.43 +fi
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/acpid/stuff/acpi/battery.sh	Mon Oct 06 19:15:21 2008 +0200
     6.3 @@ -0,0 +1,46 @@
     6.4 +#!/bin/sh
     6.5 +##
     6.6 +## battery.sh
     6.7 +## 
     6.8 +## Made by Dominique Corbex
     6.9 +## Login   <domcox@users.sourceforge.net
    6.10 +## 
    6.11 +## Started on  Mon Oct  6 12:09:59 2008 Dominique Corbex
    6.12 +## Last update 
    6.13 +##
    6.14 +## Tips & Tricks taken from http://www.lesswatts.org
    6.15 +
    6.16 +# Enable laptop mode
    6.17 +# When laptop mode is enabled, the kernel will try to be smart
    6.18 +# about when to do IO, to give the disk and the SATA links as
    6.19 +# much time as possible in a low power state. 
    6.20 +
    6.21 +if [ ! -e /proc/sys/vm/laptop_mode ] ; then
    6.22 +    echo "Kernel does not have support for laptop mode. Please apply the laptop mode" >&2
    6.23 +    echo "patch or install a newer kernel." >&2
    6.24 +else
    6.25 +    echo "Enabling laptop mode"
    6.26 +    echo 5 > /proc/sys/vm/laptop_mode
    6.27 +fi
    6.28 +
    6.29 +# AC97 audio power saving mode
    6.30 +# The AC97 onboard audio chips support power saving, where the
    6.31 +# analog parts (codec) are powered down when no program is using
    6.32 +# the audio device.
    6.33 +
    6.34 +if [ -e /sys/module/snd_ac97_codec/parameters/power_save ] ; then
    6.35 +    echo "Enabling AC97 audio power saving mode"
    6.36 +    echo 1 > /sys/module/snd_ac97_codec/parameters/power_save
    6.37 +    echo 1 > /dev/dsp
    6.38 +fi
    6.39 +
    6.40 +# The VM writeback time
    6.41 +# The VM subsystem caching allows the kernel to group consecutive
    6.42 +# writes into one big write, and to generally optimize the disk IO
    6.43 +# to be the most efficient.
    6.44 +
    6.45 +if [ -e /proc/sys/vm/dirty_writeback_centisecs ] ; then
    6.46 +    echo "Writeback time set to 1500ms"
    6.47 +    echo 1500 > /proc/sys/vm/dirty_writeback_centisecs
    6.48 +fi
    6.49 +
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/acpid/stuff/acpi/events/ac	Mon Oct 06 19:15:21 2008 +0200
     7.3 @@ -0,0 +1,5 @@
     7.4 +# /etc/acpi/event/ac
     7.5 +# called when the user connects ac power
     7.6 +
     7.7 +event=ac_adapter
     7.8 +action=/etc/acpi/ac.sh
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/acpid/stuff/acpi/events/battery	Mon Oct 06 19:15:21 2008 +0200
     8.3 @@ -0,0 +1,5 @@
     8.4 +# /etc/acpi/event/battery
     8.5 +# called when ac power goes away
     8.6 +
     8.7 +event=battery
     8.8 +action=/etc/acpi/battery.sh
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/acpid/stuff/acpi_fakekey.c	Mon Oct 06 19:15:21 2008 +0200
     9.3 @@ -0,0 +1,64 @@
     9.4 +#include <unistd.h>
     9.5 +#include <fcntl.h>
     9.6 +#include <string.h>
     9.7 +#include <stdlib.h>
     9.8 +#include <stdio.h>
     9.9 +#include <linux/input.h>
    9.10 +
    9.11 +#define TestBit(bit, array) (array[(bit) / 8] & (1 << ((bit) % 8)))
    9.12 +
    9.13 +int find_keyboard() {
    9.14 +	int i, j;
    9.15 +        int fd;
    9.16 +        char filename[32];
    9.17 +        char key_bitmask[(KEY_MAX + 7) / 8];
    9.18 +
    9.19 +        for (i=0; i<32; i++) {
    9.20 +                snprintf(filename,sizeof(filename), "/dev/input/event%d", i);
    9.21 +
    9.22 +                fd = open(filename, O_RDWR);
    9.23 +                ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(key_bitmask)), key_bitmask);
    9.24 +
    9.25 +		for (j = 0; j < BTN_MISC; j++) {
    9.26 +			if (TestBit(j, key_bitmask))
    9.27 +				break;
    9.28 +		}
    9.29 +
    9.30 +                if (j < BTN_MISC) {
    9.31 +                        return fd;
    9.32 +                }
    9.33 +		close (fd);
    9.34 +        }
    9.35 +        return 0;
    9.36 +}
    9.37 +
    9.38 +int main(int argc, char** argv) {
    9.39 +	int fd;
    9.40 +	int key;
    9.41 +	struct input_event event;
    9.42 +
    9.43 +	if (argc == 2) {
    9.44 +		key = atoi(argv[1]);
    9.45 +	} else {
    9.46 +		return 1;
    9.47 +	}
    9.48 +
    9.49 +	fd = find_keyboard();
    9.50 +
    9.51 +	if (!fd) {
    9.52 +		return 2;
    9.53 +	}
    9.54 +
    9.55 +	event.type = EV_KEY;
    9.56 +	event.code = key;
    9.57 +	event.value = 1;
    9.58 +	write(fd, &event, sizeof event);
    9.59 +
    9.60 +	event.type = EV_KEY;
    9.61 +	event.code = key;
    9.62 +	event.value = 0;
    9.63 +	write(fd, &event, sizeof event);
    9.64 +	
    9.65 +	return 0;
    9.66 +}
    9.67 +
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/acpid/stuff/init.d/acpid	Mon Oct 06 19:15:21 2008 +0200
    10.3 @@ -0,0 +1,55 @@
    10.4 +#!/bin/sh
    10.5 +# /etc/init.d/acpid: Start, stop and restart acpid deamon on SliTaz, at boot
    10.6 +# time or with the command line.
    10.7 +#
    10.8 +# To start daemon at boot time, just put the right name in the $RUN_DAEMONS
    10.9 +# variable of /etc/rcS.conf and configure options with /etc/daemons.conf.
   10.10 +#
   10.11 +. /etc/init.d/rc.functions
   10.12 +. /etc/daemons.conf
   10.13 +
   10.14 +NAME=acpid
   10.15 +DESC="ACPI event deamon"
   10.16 +DAEMON=/usr/sbin/acpid
   10.17 +OPTIONS=$ACPID_OPTIONS
   10.18 +PIDFILE=/var/run/acpid.pid
   10.19 +
   10.20 +case "$1" in
   10.21 +  start)
   10.22 +    if [ -f $PIDFILE ] ; then
   10.23 +      echo "$NAME already running."
   10.24 +      exit 1
   10.25 +    fi
   10.26 +    echo -n "Starting $DESC: $NAME... "
   10.27 +    $DAEMON $OPTIONS > /dev/null
   10.28 +    status
   10.29 +    ;;
   10.30 +  stop)
   10.31 +    if [ ! -f $PIDFILE ] ; then
   10.32 +      echo "$NAME is not running."
   10.33 +      exit 1
   10.34 +    fi
   10.35 +    echo -n "Stopping $DESC: $NAME... "
   10.36 +    kill `cat $PIDFILE`
   10.37 +    status
   10.38 +    ;;
   10.39 +  restart)
   10.40 +    if [ ! -f $PIDFILE ] ; then
   10.41 +      echo "$NAME is not running."
   10.42 +      exit 1
   10.43 +    fi
   10.44 +    echo -n "Restarting $DESC: $NAME... "
   10.45 +    kill `cat $PIDFILE`
   10.46 +    sleep 2
   10.47 +    $DAEMON $OPTIONS > /dev/null
   10.48 +    status
   10.49 +    ;;
   10.50 +  *)
   10.51 +    echo ""
   10.52 +    echo -e "\033[1mUsage:\033[0m /etc/init.d/`basename $0` [start|stop|restart]"
   10.53 +    echo ""
   10.54 +    exit 1
   10.55 +    ;;
   10.56 +esac
   10.57 +
   10.58 +exit 0