can't use kwrite /kate

I use opensuse 11.3 x86_64 (language:chinese ).My english is very bad.I do ntot know how to means the problem.I just show it.Please help me.
(1)It works.
wei@linux-wzpd:~> kate
(2)wrong now
wei@linux-wzpd:~> sudo kate
kate: cannot connect to X server
wei@linux-wzpd:~> su
password:
linux-wzpd:/home/wei # kate
kate(7764): Session bus not found

KCrash: Application ‘kate’ crashing…
sock_file=/root/.kde4/socket-linux-wzpd.site/kdeinit4__0
Warning: connect() failed: : no such file or folder
KCrash cannot reach kdeinit, launching directly.
drkonqi(7765): Session bus not found

linux-wzpd:/home/wei # kwrite
kwrite(7766): Session bus not found

KCrash: Application ‘kwrite’ crashing…
sock_file=/root/.kde4/socket-linux-wzpd.site/kdeinit4__0
Warning: connect() failed: : no such file or folder
KCrash cannot reach kdeinit, launching directly.
drkonqi(7767): Session bus not found

You might try this to see if it might “fix” the problem. Open up a terminal session such as konsole. Then type the following command and see what this does:

dbus-lanuch kwrite

Then try it again with kate:


dbus-lanuch kste

Here is some information about the dbus-lanuch command:

dbus-launch(1) - Linux man page

Thank You,

While there may be somethiing wrong, but I also see a problem in what you are doing.

II assume that you do have a GUI session running as user wei and that you run a terminal session (konsole or xterm or likewise) inside that GUI session.
Now as you start a graphical application there it will open a (or more) window(s) on your desktop. But as you try to do that as another user (in this case root, but that is an unimportant detail) this window will not open when the owner of the session (wei) will not allow this. Imagine, all sorts of users on your system (or even from outside) that started opening all sorts of windows on your screen while you are working!

You can give that allowance this with the xhost command. Thus test if

wei@linux-wzpd:~> xhost +
access control disabled, clients can connect from any host
wei@linux-wzpd:~> su -
password:
linux-wzpd:~ # kate

does what you want.

The correct method is to run this command:

kdesu kwrite

but more normally if you have a file that you want either to create or to edit, called “somefile.txt” located in directory “somewhere” at the address /path_to/somewhere/somefile.txt, you would type this fuller expression:

kdesu kwrite /path_to/somewhere/somefile.txt

you can also do

su - 

or

su -l

and then

kwrite

or

kwrite /path/to/some/file