Scratch #11, wasn't running as root, which of course the powerbtn.sh
would be :-)

Cut'n'paste tests now show
... as before ...
r...@wopr:~# getXconsole
r...@wopr:~# echo $XUSER
falken
r...@wopr:~# test "$XUSER" != "" && pidof dcopserver > /dev/null && test -x 
/usr/bin/dcop && /usr/bin/dcop --user $XUSER kded kded loadedModules | grep -q 
klaptopdaemon
r...@wopr:~# echo $?
1
r...@wopr:~#  test "$XUSER" != "" && test -x /usr/bin/qdbus && test -r 
/proc/$(pidof kded4)/environ && su - $XUSER -c "eval $(echo -n 'export '; cat 
/proc/$(pidof kded4)/environ |tr '\0' '\n'|grep DBUS_SESSION_BUS_ADDRESS); 
qdbus org.kde.kded" | grep -q powerdevil
-bash: test: too many arguments

Ahh ha ! That is the line that's meant to spot KDE4 and poke it... it
looks like a horrible undocument mess to me though.

r...@wopr:~# pidof kded4
14371 2153 1955
r...@wopr:~# ps -efww|grep kded4
falken    1955     1  0 May01 ?        00:01:23 kdeinit4: kded4 [kdeinit]       
               
falken    2153  1955  0 May01 ?        00:00:00 [kded4] <defunct>
root     14371     1  0 May03 ?        00:00:02 kdeinit4: kded4 [kdeinit]  
root     20826 20690  0 22:43 pts/1    00:00:00 grep kded4

I found the process I think it should be asking for, and it looks like it 
should work:
r...@wopr:~# cat /proc/1955/environ |tr '\0' '\n'|grep DB
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-wZqbwHsRWt,guid=a017520a52ed70c025d498814bdc07f1
r...@wopr:~# su - $XUSER -c "eval export 
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-wZqbwHsRWt,guid=a017520a52ed70c025d498814bdc07f1;
 qdbus org.kde.kded"|grep powerdevil
/modules/powerdevil
r...@wopr:~# 

As a suggestion, the final test should replace 'pidof kded4' with 'ps 
-efww|grep kded4|grep $XUSER|grep -v grep|grep -v defunct
' or similar.
I do not believe the defunct is the problem, rather there are many kded4's (one 
for me, one for root, one for every user logged in ?). I've filtered out 
defunct ones anyway, and also restricted it to the current X user name. This 
should more reliably locate the one KDE instance we are interested in.

This appears to work:
PIDOFKDE4=`ps -efww|grep kded4|grep $XUSER|grep -v grep|grep -v defunct|tr -s ' 
'|awk '{print $2}'`

if pidof x $PMS > /dev/null ||
         ( test "$XUSER" != "" && pidof dcopserver > /dev/null && test -x 
/usr/bin/dcop && /usr/bin/dcop --user $XUSER kded kded loadedModules | grep -q 
klaptopdaemon) ||
         ( test "$XUSER" != "" && test -x /usr/bin/qdbus && test -r 
/proc/$PIDOFKDE4/environ && su - $XUSER -c "eval $(echo -n 'export '; cat 
/proc/$PIDOFKDE4/environ |tr '\0' '\n'|grep DBUS_SESSION_BUS_ADDRESS); qdbus 
org.kde.kded" | grep -q powerdevil) ; then
 echo hello
fi

Attached is a a version of powerbtn.sh that works for me.
Someone with more Bash voodoo might want to take a look at this.

Using this version, with a power button press, hibernate and resume betwen the 
two ls's :
r...@wopr:~# ls -lah /tmp/powerbutton.fail 
-rw-r--r-- 1 root root 0 2010-05-03 22:01 /tmp/powerbutton.fail
r...@wopr:~# date
Tue May  4 23:10:10 BST 2010
r...@wopr:~# ls -lah /tmp/powerbutton.fail 
-rw-r--r-- 1 root root 0 2010-05-03 22:01 /tmp/powerbutton.fail
r...@wopr:~# date
Tue May  4 23:12:20 BST 2010

this indicates the script correctly bailed rather than falling through
to the shutdown.


** Attachment added: "powerbtn.sh"
   http://launchpadlibrarian.net/47827182/powerbtn.sh

-- 
kde power button configuration ignored
https://bugs.launchpad.net/bugs/553557
You received this bug notification because you are a member of Kubuntu
Bugs, which is subscribed to kdebase-workspace in ubuntu.

-- 
kubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/kubuntu-bugs

Reply via email to