Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
howto display kde logout dialog on power-button-push?!?[SOL]
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
c_t
n00b
n00b


Joined: 29 Oct 2003
Posts: 36
Location: Berlin, Germany

PostPosted: Mon Jul 12, 2004 1:06 pm    Post subject: howto display kde logout dialog on power-button-push?!?[SOL] Reply with quote

I want my laptop to display the kde logout dialog when I push the power button.

I know, that I can get that logout-dialog with the console-command:
Code:
$ /usr/kde/3.2/bin/dcop kdesktop default logout


I also can configure the acpid to perform any command, when it receives the acpi-event from the power button. My /etc/acpi/event/default looks like this:
Code:
...
# action keeps the command to be executed after an event occurs
# In case of the power event above, your entry may look this way:
#event=button power.*
#action=/sbin/init 0

# Optionally you can specify the placeholder %e. It will pass
# through the whole kernel event message to the program you've
# specified.

event=.*
action=/etc/acpi/default.sh %e


It simpley passes the whole argument to /etc/acpi/default.sh in which I can finally define the commands:
Code:
#!/bin/sh
# Default acpi script that takes an entry for all actions

set $*

group=${1/\/*/}
action=${1/*\//}

case "$group" in
        button)
                case "$action" in
                        power)  /sbin/init 0
                                ;;
                        lid)    logger "lid switch"
                                #echo -n "standby" > /sys/power/state
                                ;;
                        sleep)  logger "sleep state"
                                #echo -n "mem" > /sys/power/state
                                ;;
                        *)      logger "ACPI action $action is not defined"
                                ;;
                esac
                ;;

        *)
                logger "ACPI group $group / action $action is not defined"
                ;;
esac


The problem now is, that this script is obviously run by root. So if I replace /sbin/init 0 with /usr/kde/3.2/bin/dcop kdesktop default logout this doesn't work.

Is there another way, to get the logout dialog? How can I get this working with the shell script, which is executed by the daemon?

greets, christoph


Last edited by c_t on Sun Feb 06, 2005 9:57 am; edited 1 time in total
Back to top
View user's profile Send private message
adaptr
Watchman
Watchman


Joined: 06 Oct 2002
Posts: 6730
Location: Rotterdam, Netherlands

PostPosted: Mon Jul 12, 2004 1:35 pm    Post subject: Reply with quote

Suid the script.
_________________
>>> emerge (3 of 7) mcse/70-293 to /
Essential tools: gentoolkit eix profuse screen
Back to top
View user's profile Send private message
neuron
Advocate
Advocate


Joined: 28 May 2002
Posts: 2371

PostPosted: Mon Jul 12, 2004 2:16 pm    Post subject: Reply with quote

relevant part of my default.sh (horrible implementation imho)

if anyone has any cleaner way of detecting if the user clicked logout or not it's apriciated ;)

Code:

   button)
      case "$action" in
         power)   
            if pidof X &>/dev/null; then
               if su neuron -c "DISPLAY=:0.0 /usr/kde/3.2/bin/dcop kdesktop" &>/dev/null; then
                  su neuron -c "DISPLAY=:0.0 /usr/kde/3.2/bin/dcop kdesktop KDesktopIface logout"
                  for a in 1 2 3 4 5 6 7 8 9 10
                  do
                     sleep 2
                     if pidof gdmgreeter &>/dev/null; then
                        sleep 5
                        #/etc/init.d/xdm stop
                        chvt 1
                        sync
                        halt
                        exit
                     fi
                  done
                  exit
               fi
            fi
            halt
            ;;
         lid)
            if pidof X &>/dev/null; then
               su neuron -c "DISPLAY=:0.0 /usr/kde/3.2/bin/dcop kdesktop KScreensaverIface lock"
            fi
            ;;
         *)   logger "ACPI action $action is not defined"
            ;;
      esac
      ;;
Back to top
View user's profile Send private message
c_t
n00b
n00b


Joined: 29 Oct 2003
Posts: 36
Location: Berlin, Germany

PostPosted: Mon Jul 12, 2004 4:19 pm    Post subject: Reply with quote

thanks a lot! your solution, neuron, works really fine for me...

i just don't really get it why you do the loop, to check, whether the user clicked log-out....
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum