This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Run kdialog and logout script from console script

Tags: None
(comma "," separated)
jlinkels
Registered Member
Posts
31
Karma
0
OS
Hi all,

I am trying to write a bash script which runs in the background, and at a certain condition:
1. pop up a dialog to warn the user that he will be logged out in 1 minute (preferably with progress bar)
2. logout this user from KDE (logging out all users from KDE would be acceptable as well.

As for the first command I tried this:
Open console with CTRL-ALT-F1, su to root
Issue this command:
kdialog --msgbox "Hello World"
Then I get this error message:
kdialog: cannot connect to X server
I tried to add this:
export DISPLAY=localhost:0:0
export DISPLAY=localhost:0:1 (because KDE is running on CTRL-ALT-F8)
export DISPLAY=myhost.mydomain.com:0:0 (this is an internal name, name resolution works)
export DISPLAY=myhost.mydomain.com:0:1 (this is an internal name, name resolution works)
How do I make kdialog to connect to the correct X server?

Then, for logout, I tried:
Open console with CTRL-ALT-F1, su to root
Issue this command:
qbdus org.kde.ksmserver /KSMServer logout 0 0 0
but that yields the error message:
Could not connect to D-Bus server: org.freedesktop.DBus.Error.Spawn.ExecFailed: dbus-launch failed to autolaunch D-Bus session: Autolaunch error: X11 initialization failed.

Alternatively I could run /etc/init.d/kdm stop, which does work, but that is pretty rude.
I am testing this in a console, assuming that as long as it does not work in a console, it won't work in a background script either. The background script is to be run as root.

I want to do this to kick my son off the computer at certain periods of the day. He has his own computer so I don't care too much if other users are disabled as well.

I am running KDE 4.4.5 on Debian Squeeze
Kernel 2.6.32-5-amd64

Any help?

jlinkels
jlinkels
Registered Member
Posts
31
Karma
0
OS
Solved.

First I have to issue an xhost +localhost from an XTerm. Then, from the Console I have to issue the commands directed to X as myself, not as root.

jlinkels
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
For D-Bus, you may also find it necessary to source the scripts located under ~/.dbus/session-bus/ to ensure you connect to the appropriate D-Bus session.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
jlinkels
Registered Member
Posts
31
Karma
0
OS
I'll look into that, thanks.

jlinkels


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Evergrowing, Google [Bot], ourcraft