Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 317421 - sys-power/acpid-2.0.4: powerbtn.sh doesn't check if KDE4 session is running, only KDE3/Gnome
Summary: sys-power/acpid-2.0.4: powerbtn.sh doesn't check if KDE4 session is running, ...
Status: RESOLVED DUPLICATE of bug 253764
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Samuli Suominen (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-27 07:59 UTC by Igor Poboiko
Modified: 2010-05-15 11:23 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Fedora power button script (acpid-2.0.4-powerbtn.sh,662 bytes, text/plain)
2010-04-28 13:53 UTC, Samuli Suominen (RETIRED)
Details
powerbtn.sh (powerbtn.sh,1.81 KB, text/plain)
2010-04-28 14:32 UTC, Pacho Ramos
Details
powerbtn.sh.diff (powerbtn.sh.diff,593 bytes, text/plain)
2010-04-28 15:22 UTC, Pacho Ramos
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Igor Poboiko 2010-04-27 07:59:51 UTC
When I'm clicking power button on my laptop (KDE4 session is running), acpi calls /etc/acpi/default.sh to handle it. This script calls /etc/acpi/powerbtn.sh, which tests if KDE3 or Gnome session is running, and calls /sbin/shutdown if not. 
KDE4 handles power button click using HAL and shows 'logout/shutdown' default dialog, but powerbtn.sh calls /sbin/shutdown, and my laptop shutdowns (without asking me what to do :) )

Possible solution is just add to this script lines like:
---
#if KDE4 session is running
if pidof kdeinit4 >/dev/null; then
  exit 0
fi
---
We can use kded4 (or something else) instead of kdeinit4.

Reproducible: Always

Steps to Reproduce:
1. Start a KDE4 session
2. Press power button
3. See result
Actual Results:  
Computer shutdowns immediately

Expected Results:  
Computer asks user what to do (logout/shutdown/restart/etc)

# emerge --info sys-power/acpid
Portage 2.2_rc67 (default/linux/x86/10.0/desktop, gcc-4.3.3, glibc-2.11.1-r0, 2.6.33-gentoodv1400 i686)
=================================================================
                        System Settings
=================================================================
System uname: Linux-2.6.33-gentoodv1400-i686-Intel-R-_Celeron-R-_CPU_540_@_1.86GHz-with-gentoo-2.0.1
Timestamp of tree: Mon, 26 Apr 2010 17:00:02 +0000
app-shells/bash:     4.1_p5
dev-java/java-config: 2.1.10
dev-lang/python:     2.6.5-r1, 3.1.2-r2
dev-util/cmake:      2.8.1-r1
sys-apps/baselayout: 2.0.1
sys-apps/openrc:     0.6.1-r1
sys-apps/sandbox:    2.2
sys-devel/autoconf:  2.13, 2.65
sys-devel/automake:  1.8.5-r3, 1.9.6-r3, 1.10.3, 1.11.1
sys-devel/binutils:  2.20.1
sys-devel/gcc:       4.3.3-r2, 4.4.3-r2
sys-devel/gcc-config: 1.4.1
sys-devel/libtool:   2.2.6b
virtual/os-headers:  2.6.33
ACCEPT_KEYWORDS="x86 ~x86"
ACCEPT_LICENSE="* -@EULA LOKI-EULA Q3AEULA sun-bcla-java-vm dlj-1.1 PUEL skype-eula"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-O2 -march=i686 -pipe -ggdb"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/X11/xkb /usr/share/config"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/splash /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-O2 -march=i686 -pipe -ggdb"
DISTDIR="/home/distfiles"
FEATURES="assume-digests distlocks fixpackages news parallel-fetch preserve-libs protect-owned sandbox sfperms splitdebug strict unmerge-logs unmerge-orphans userfetch"
GENTOO_MIRRORS="http://gentoo.iteam.net.ua/ http://mirror.leaseweb.com/gentoo/ ftp://de-mirror.org/distro/gentoo/"
LANG="ru_RU.UTF-8"
LC_ALL=""
LDFLAGS="-Wl,--as-needed"
LINGUAS="ru en"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage /var/lib/layman/kde /var/lib/layman/roslin /var/lib/layman/rion"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="X a52 aac acl acpi alsa bash-completion berkdb bluetooth branding bzip2 cairo cdda cdr chm cli consolekit cracklib crypt ctype cups curl cxx dbus dcc_video dell djvu dri dts dvd dvdr emboss encode exif fam fbcon fbcondecor ffmpeg filter firefox flac fortran gdbm geoip gif glib gpm gstreamer hal handbook iconv icq imagemagick ipv6 jabber jpeg jpeg2k kde kipi kontact lame laptop lcms libnotify mad mikmod mjpeg mng modules mp3 mp4 mpeg mudflap mysql ncurses networkmanager nls nptl nptlonly ntfs ogg opengl openmp openssl oscar pam pango pcre pdf perl phonon pm-utils png policykit ppds pppd python qt-webkit qt3support qt4 readline reflection resolvconf samba sdl semantic-desktop session skype smbclient spell spl sql sqlite ssl startup-notification subversion svg sysfs taglib tcpd theora threads tiff truetype unicode usb utf8 v4l v4l2 vcd vim-syntax vnc vorbis wav webkit wicd wifi win32codecs wma x264 x86 xcb xml xmp xorg xscreensaver xulrunner xv xvid 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 mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" ELIBC="glibc" INPUT_DEVICES="synaptics evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="ru en" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="nvidia" 
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

=================================================================
                        Package Settings
=================================================================

sys-power/acpid-2.0.4 was built with the following:
USE=""
Comment 1 Samuli Suominen (RETIRED) gentoo-dev 2010-04-28 07:34:29 UTC
Fedora has KDE4 support in acpid scripts:

http://cvs.fedoraproject.org/viewvc/rpms/acpid/devel/acpid.power.sh?view=log

Perhaps we should use their copy instead, the one that comes with acpid now is from Debian...

Try it?
Comment 2 Samuli Suominen (RETIRED) gentoo-dev 2010-04-28 13:53:05 UTC
Created attachment 229503 [details]
Fedora power button script

In ebuild,

-	doexe samples/powerbtn/powerbtn.sh || die
+       # acpi.power.sh from http://cvs.fedoraproject.org/viewvc/rpms/acpid/devel/
+	newexe "${FILESDIR}"/${PN}-2.0.4-powerbtn.sh powerbtn.sh || die
Comment 3 Igor Poboiko 2010-04-28 14:28:12 UTC
This script doesn't work for me because process 'kded4' in "ps axo" looks like;
=========
$ ps axo uid,cmd  | grep kded4
 1000 kdeinit4: kded4 [kdeinit]   
=========
but this script tries to find 'kded4' string in second  (... $2 ~ /kded4/ ...) parameter (in my case it is 'kdeinit4:')
We can change it:
=========
--- a/acpid.power.sh    2010-04-28 12:10:01.000000000 +0300
+++ b/acpid.power.sh    2010-04-28 17:25:43.000000000 +0300
@@ -22,7 +22,7 @@
 awk '
     $1 == '$uid_session' &&
        ($2 ~ /gnome-power-manager/ || $2 ~ /kpowersave/ ||
-        $2 ~ /kded4/ || $3 ~ /guidance-power-manager/) \
+        $3 ~ /kded4/ || $3 ~ /guidance-power-manager/) \
                { found = 1; exit }
     END { exit !found }
 ' ||
=========
This script works for me after applying this change
Comment 4 Pacho Ramos gentoo-dev 2010-04-28 14:32:29 UTC
Created attachment 229519 [details]
powerbtn.sh

I would wait a bit for Ted Felix to fix this directly in upstream, because seems that he upstreamed an older script from Debian. I attach current debian script supplied with 2.0.3-1 as it supports kde4
Comment 5 Samuli Suominen (RETIRED) gentoo-dev 2010-04-28 15:03:49 UTC
(In reply to comment #4)
> Created an attachment (id=229519) [details]
> powerbtn.sh
> 
> I would wait a bit for Ted Felix to fix this directly in upstream, because
> seems that he upstreamed an older script from Debian. I attach current debian
> script supplied with 2.0.3-1 as it supports kde4
> 

These Debian scripts are too heavy, they seem to rely on the acpi-support package. That's bug 99446.
Comment 6 Pacho Ramos gentoo-dev 2010-04-28 15:22:42 UTC
Created attachment 229529 [details]
powerbtn.sh.diff

Wouldn't something like this do the trick?

I am sure I saw some similar fix elsewhere (ubuntu, debian... ), but I can't remember it now :-(
Comment 7 Samuli Suominen (RETIRED) gentoo-dev 2010-04-28 15:23:00 UTC
try 2.0.4-r1
Comment 8 Igor Poboiko 2010-04-29 08:39:13 UTC
sys-power/acpid-2.0.4-r1 with new powerbtn.sh works fine for me.
Comment 9 Samuli Suominen (RETIRED) gentoo-dev 2010-05-03 18:34:32 UTC
I'm taking this bug. We really need to make a lean (clean) and most importantly readable, i'm not planning on maintaining acpid after this (last bug, btw :) is closed. We could check `ps` or something from /proc (?) for process names, without consolekit, and have them in a nice list (separate file?). Because we need to check at least:

kded4 (for kde4)
guidance-power-manager (for kde4)
gnome-power-manager (for gnome)
xfce4-power-manager (for xfce4)

Right now, at least KDE and older xfce4-power-manager works fine without consolekit (plain dbus+hal), so checking that is a bit early... but could be optional
Comment 10 Pacho Ramos gentoo-dev 2010-05-03 19:00:07 UTC
(In reply to comment #6)
> Created an attachment (id=229529) [details]
> powerbtn.sh.diff
> 
> Wouldn't something like this do the trick?
> 
> I am sure I saw some similar fix elsewhere (ubuntu, debian... ), but I can't
> remember it now :-(
> 

Have you tried this one? It shouldn't require consolekit if I don't misremember
Comment 11 Marat Radchenko 2010-05-15 08:57:43 UTC
acpid-2.0.4-r2 (stable), kde all stable, still observing this bug (pressing power button triggers BOTH kde dialog and machine shutdown).
Comment 12 Samuli Suominen (RETIRED) gentoo-dev 2010-05-15 11:15:16 UTC
Yeah, none of the scripts were good enough so it's reverted to the way it originally was. 

You just have to setup it (the power button script) using the installed samples yourself.

Duping this to bug 253764 and reopening for someone else to take look at it... (since it's reverted to the original state)

*** This bug has been marked as a duplicate of bug 253764 ***
Comment 13 Ted Felix 2010-05-15 11:23:49 UTC
I'm going to be including the latest powerbtn.sh script from Debian in the next release of acpid which will be today.  It should handle KDE4 properly.