# [SOLVED]power button isn't working

## znal

Sorry about my poor English

My problem: I can't shutdown my PC using power button on keyboard.

I have acpid emerged, added to a default runlevel and it is working. Power Management, ACPI and Button support turned on in kernel config. In Windows power button is working properly so there is no hardware or BIOS problems.

There is no output from cat /proc/acpi/event when I press the power button.

Part of /usr/src/linux/.config

```
CONFIG_PM=y

CONFIG_ACPI=y

CONFIG_ACPI_BUTTON=y

```

Here is, a bit of info:

```
koral ~ # emerge --info

Portage 2.1.2.11 (default-linux/x86/2007.0, gcc-4.1.2, glibc-2.5-r4, 2.6.21-gentoo-r4 i686)

=================================================================

System uname: 2.6.21-gentoo-r4 i686 AMD Athlon(tm) XP 2600+

Gentoo Base System release 1.12.9

Timestamp of tree: Sun, 12 Aug 2007 19:00:01 +0000

ccache version 2.4 [enabled]

dev-java/java-config: 1.3.7, 2.0.33-r1

dev-lang/python:     2.4.4-r4

dev-python/pycrypto: 2.0.1-r6

dev-util/ccache:     2.4-r7

sys-apps/sandbox:    1.2.17

sys-devel/autoconf:  2.13, 2.61

sys-devel/automake:  1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10

sys-devel/binutils:  2.17

sys-devel/gcc-config: 1.3.16

sys-devel/libtool:   1.5.23b

virtual/os-headers:  2.6.21

ACCEPT_KEYWORDS="x86"

AUTOCLEAN="yes"

CBUILD="i686-pc-linux-gnu"

CFLAGS="-march=athlon-xp -mtune=athlon-xp -O2 -fomit-frame-pointer -s -pipe -DNDEBUG -DG_DISABLE_ASSERT"

CHOST="i686-pc-linux-gnu"

CONFIG_PROTECT="/etc /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/share/X11/xkb /usr/share/config"

CONFIG_PROTECT_MASK="/etc/env.d /etc/env.d/java/ /etc/gconf /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/splash /etc/terminfo"

CXXFLAGS="-march=athlon-xp -mtune=athlon-xp -O2 -s -DNDEBUG -DG_DISABLE_ASSERT"

DISTDIR="/usr/portage/distfiles"

FEATURES="ccache distlocks metadata-transfer parallel-fetch sandbox sfperms strict"

GENTOO_MIRRORS="http://gentoo.prz.rzeszow.pl http://gentoo.zie.pg.gda.pl http://gentoo.po.opole.pl ftp://gentoo.po.opole.pl "

LANG="pl_PL"

LC_ALL="pl_PL"

LDFLAGS="-s -z combreloc"

LINGUAS="pl"

PKGDIR="/usr/portage/packages"

PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --filter=H_**/files/digest-*"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

PORTDIR_OVERLAY="/usr/portage/local/layman/arcon-portage /usr/portage/local/layman/xeffects /usr/portage/local/other"

SYNC="rsync://rsync.gentoo.org/gentoo-portage"

USE="/ 3dnow 3dnowext X aac acl acpi alsa amarok apache2 arts bcmath berkdb bitmap-fonts bluetooth bzip2 cdr cli cracklib crypt ctype cups curl curlwrappers cvs dbus djvu dri dvd dvdr encode exif expat ffmpeg firefox fortran ftp gd gdbm geoip gif gmp gpm gtk2 hal hash iconv ieee1394 imap ip3100 isdnlog java javascript jpeg kde lame live lm_sensors mhash midi mime mmx mp3 mpeg mplayer mudflap mysql ncurses nls nptl nptlonly nsplugin ogg opengl openmp pam pcre pdf perl php png pppd python qt4 quicktime rar readline real reflection scanner sdl servicetools session slang sms soap spell spl sse ssl subversion symlink tcpd tiff tlen tokenizer toolbar truetype truetype-fonts type1-fonts unicode usb v4l v4l2 visualization vorbis win32codecs x264 x86 xcb xcomposite xinetd xml xmlreader xmlrpc xmlwriter xorg xpm xsl xv xvid zip zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1 emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mulaw multi null plug rate route share shm softvol" ELIBC="glibc" INPUT_DEVICES="keyboard mouse" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="pl" USERLAND="GNU" VIDEO_CARDS="fglrx radeon"

Unset:  CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, MAKEOPTS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

```

```
koral ~ # emerge -pv acpid acpitool

These are the packages that would be merged, in order:

Calculating dependencies... done!

[ebuild   R   ] sys-power/acpid-1.0.4-r5  USE="-doc -logrotate" 0 kB

[ebuild   R   ] sys-power/acpitool-0.4.7-r1  0 kB

Total: 2 packages (2 reinstalls), Size of downloads: 0 kB
```

```
koral ~ # dmesg |grep ACPI

 BIOS-e820: 000000001fff0000 - 000000001fff3000 (ACPI NVS)

 BIOS-e820: 000000001fff3000 - 0000000020000000 (ACPI data)

ACPI: RSDP 000F75E0, 0014 (r0 Nvidia)

ACPI: RSDT 1FFF3000, 0028 (r1 Nvidia AWRDACPI 42302E31 AWRD        0)

ACPI: FACP 1FFF3040, 0074 (r1 Nvidia AWRDACPI 42302E31 AWRD        0)

ACPI: DSDT 1FFF30C0, 4561 (r1 NVIDIA AWRDACPI     1000 MSFT  100000E)

ACPI: FACS 1FFF0000, 0040

Nvidia board detected. Ignoring ACPI timer override.

Nvidia board detected. Ignoring ACPI timer override.

ACPI: PM-Timer IO Port: 0x4008

ACPI: Core revision 20070126

ACPI: setting ELCR to 0200 (from 8e38)

ACPI: bus type pci registered

ACPI: Interpreter enabled

ACPI: Using PIC for interrupt routing

ACPI: PCI Root Bridge [PCI0] (0000:00)

ACPI: PCI Interrupt Routing Table [\_SB_.PCI0._PRT]

ACPI: PCI Interrupt Routing Table [\_SB_.PCI0.HUB0._PRT]

ACPI: PCI Interrupt Routing Table [\_SB_.PCI0.AGPB._PRT]

ACPI: PCI Interrupt Link [LNK1] (IRQs *3 4 5 6 7 9 10 11 12 14 15)

ACPI: PCI Interrupt Link [LNK2] (IRQs 3 4 *5 6 7 9 10 11 12 14 15)

ACPI: PCI Interrupt Link [LNK3] (IRQs 3 4 5 6 7 9 10 *11 12 14 15)

ACPI: PCI Interrupt Link [LNK4] (IRQs 3 4 *5 6 7 9 10 11 12 14 15)

ACPI: PCI Interrupt Link [LNK5] (IRQs 3 4 5 6 7 9 10 11 12 14 15) *0, disabled.

ACPI: PCI Interrupt Link [LUBA] (IRQs 3 4 5 6 7 9 10 11 12 14 *15)

ACPI: PCI Interrupt Link [LUBB] (IRQs 3 4 5 6 7 *9 10 11 12 14 15)

ACPI: PCI Interrupt Link [LMAC] (IRQs 3 4 5 6 7 9 10 *11 12 14 15)

ACPI: PCI Interrupt Link [LAPU] (IRQs 3 4 5 6 7 9 10 11 12 14 15) *0, disabled.

ACPI: PCI Interrupt Link [LACI] (IRQs 3 4 5 6 7 9 10 11 12 14 15) *0, disabled.

ACPI: PCI Interrupt Link [LMCI] (IRQs 3 4 5 6 7 9 10 11 12 14 15) *0, disabled.

ACPI: PCI Interrupt Link [LSMB] (IRQs 3 4 5 6 7 9 10 *11 12 14 15)

ACPI: PCI Interrupt Link [LUB2] (IRQs 3 *4 5 6 7 9 10 11 12 14 15)

ACPI: PCI Interrupt Link [LFIR] (IRQs 3 4 5 6 7 9 10 11 12 14 15) *0, disabled.

ACPI: PCI Interrupt Link [L3CM] (IRQs 3 4 5 6 7 9 10 11 12 14 15) *0, disabled.

ACPI: PCI Interrupt Link [LIDE] (IRQs 3 4 5 6 7 9 10 11 12 14 15) *0, disabled.

ACPI: PCI Interrupt Link [APC1] (IRQs *16)

ACPI: PCI Interrupt Link [APC2] (IRQs *17)

ACPI: PCI Interrupt Link [APC3] (IRQs *18)

ACPI: PCI Interrupt Link [APC4] (IRQs *19)

ACPI: PCI Interrupt Link [APC5] (IRQs *16), disabled.

ACPI: PCI Interrupt Link [APCF] (IRQs 20 21 22) *0

ACPI: PCI Interrupt Link [APCG] (IRQs 20 21 22) *0

ACPI: PCI Interrupt Link [APCH] (IRQs 20 21 22) *0

ACPI: PCI Interrupt Link [APCI] (IRQs 20 21 22) *0, disabled.

ACPI: PCI Interrupt Link [APCJ] (IRQs 20 21 22) *0, disabled.

ACPI: PCI Interrupt Link [APCK] (IRQs 20 21 22) *0, disabled.

ACPI: PCI Interrupt Link [APCS] (IRQs *23)

ACPI: PCI Interrupt Link [APCL] (IRQs 20 21 22) *0

ACPI: PCI Interrupt Link [APCM] (IRQs 20 21 22) *0, disabled.

ACPI: PCI Interrupt Link [AP3C] (IRQs 20 21 22) *0, disabled.

ACPI: PCI Interrupt Link [APCZ] (IRQs 20 21 22) *0, disabled.

pnp: PnP ACPI init

pnp: PnP ACPI: found 13 devices

PCI: Using ACPI for IRQ routing

ACPI: PCI Interrupt Link [LNK4] enabled at IRQ 5

ACPI: PCI Interrupt 0000:03:00.0[A] -> Link [LNK4] -> GSI 5 (level, low) -> IRQ 5

ACPI: Power Button (FF) [PWRF]

ACPI: Power Button (CM) [PWRB]

ACPI: PCI Interrupt Link [LNK3] enabled at IRQ 11

ACPI: PCI Interrupt 0000:01:0b.0[A] -> Link [LNK3] -> GSI 11 (level, low) -> IRQ 11

ACPI: PCI Interrupt Link [LUB2] enabled at IRQ 4

ACPI: PCI Interrupt 0000:00:02.2[C] -> Link [LUB2] -> GSI 4 (level, low) -> IRQ 4

ACPI: PCI Interrupt Link [LUBA] enabled at IRQ 15

ACPI: PCI Interrupt 0000:00:02.0[A] -> Link [LUBA] -> GSI 15 (level, low) -> IRQ 15

ACPI: PCI Interrupt Link [LMAC] enabled at IRQ 11

ACPI: PCI Interrupt 0000:00:04.0[A] -> Link [LMAC] -> GSI 11 (level, low) -> IRQ 11

ACPI: PCI Interrupt Link [LUBB] enabled at IRQ 9

ACPI: PCI Interrupt 0000:00:02.1[B] -> Link [LUBB] -> GSI 9 (level, low) -> IRQ 9

ACPI: PCI Interrupt Link [LNK2] enabled at IRQ 5

ACPI: PCI Interrupt 0000:01:04.0[A] -> Link [LNK2] -> GSI 5 (level, low) -> IRQ 5

ACPI: PCI Interrupt Link [LNK1] enabled at IRQ 3

ACPI: PCI Interrupt 0000:01:0a.0[A] -> Link [LNK1] -> GSI 3 (level, low) -> IRQ 3

ACPI: PCI Interrupt 0000:01:08.0[A] -> Link [LNK3] -> GSI 11 (level, low) -> IRQ 11
```

Last edited by znal on Wed Aug 15, 2007 8:05 pm; edited 1 time in total

----------

## nova13

see http://gentoo-wiki.com/HOWTO_Shutdown_headless_server_when_power-button_pressed

----------

## znal

I have done all things from these page, but there is no effect  :Sad: 

When I press the power button nothing happen in system, no activity is logged in /var/log/acpid nor /var/log/messages.

```
To cleanly shut down a server when the power button is pressed, you will need:

   1. hardware that supports the ACPI power management features

   2. a kernel compiled with ACPI support

   3. the power button registered as an ACPI event

   4. acpid listening for ACPI events

   5. a handler for the power button event 
```

I have all listed above.

```
koral ~ # dmesg | grep '^ACPI: Power Button'

ACPI: Power Button (FF) [PWRF]

ACPI: Power Button (CM) [PWRB]
```

I have files: /etc/acpi/events/power and /etc/acpi/onButtonPress-Power.sh

Where is the problem?

----------

## nova13

Please post your /etc/acpi/events/power file.

----------

## znal

```
koral ~ # cat /etc/acpi/events/power

event=button/power.*

action=/etc/acpi/onButtonPress-Power.sh
```

```

koral ~ # cat /etc/acpi/onButtonPress-Power.sh

#!/bin/sh

# /etc/acpi/onButtonPress-Power.sh

# Shutdown when the power button is pressed

logger "Power button pressed -- shutting system down"

/sbin/shutdown -h now
```

EDIT:

I've tried xbindkeys and fortunately it works  :Smile: 

If anybody is interested this is solution:

- emerge xbindkeys

- create ~/.xbindeysrc file

- put this text into it:

```
"sudo /sbin/shutdown -h now &"

m:0x0 + c:222
```

----------

