Jump to content

How do i start a kde-session from shell for ANOTHER user?


qeldroma
 Share

Recommended Posts

Aim is to start up a workstation without XDMCP-Management, menaing without KDM/GDM/XDM/MDKDM.

 

I don't need them, am the only user. How do i start up a KDE-session with a specified user from root (init)?

 

I tried to do it like this:

su TheUser --command=startx

 

This fails with the error, that i am probably not owning the console i am doing this.

 

How do i manipulate this? How do i substitute "X &; startkde" to an user?

Link to comment
Share on other sites

I guess you have to log in a linux shell as the user you want (Press CTRL-ALT-F2 for instance and log in). Now startx as follow:

startx -- :1

Now go in your new X session by pressing CTRL-ALT-F8. The original X session is at CTRL-ALT-F7 (the one that starts automatically at boot).

 

MOttS

Link to comment
Share on other sites

I think you may find valuable ideas in this thread: http://mandrakeusers.org/viewtopic.php?t=4673

Adapt it a bit, and you should have a working machine.

 

Just an idea, to put in /etc/profile (which, according to bash's man page, is "The systemwide initialization file, executed for login shells") on the server:

currentD=$(echo $DISPLAY | sed 's/^.*:([0-9]*).*$/1/')

if [ $(currentD:-0) -gt 9 ]; then

 ( $HOME/.xinitrc || /usr/X11R6/bin/icewm ) &

fi

It is not tested. It's just roughly the idea.

 

Yves.

Link to comment
Share on other sites

Thanks but i was too fast, solved it on my own :mrgreen:

 

Following my /etc/X11/prefdm:

 

#!/bin/sh



PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin

HOME=/root

export HOME



# We need to source this so that the login screens get translated

[ -f /etc/profile.d/10lang.sh ] && . /etc/profile.d/10lang.sh



# trap SIGTERM to be able to kill autologin

killed () {

   kill -15 $!

   exit

}



trap killed 15



X -ac & sleep 2

export DISPLAY=":0"

echo -n $! >/var/lock/subsys/dm

su - MyUser -c startkde && ps aux |kill `awk '/X / {print $2}'`

exit 0

 

I added automatically closing of X with kde-shutdown.[/code]

Link to comment
Share on other sites

...Just an idea, to put in /etc/profile (which, according to bash's man page, is "The systemwide initialization file, executed for login shells") on the server...

 

The right syntax should be:

if [ ${currentD:-0} -gt 9 ]; then

with '{' instead of "("

 

But that will be buggy if you login when you already are in X (ie: "su -"); I think I don't understand why If you actually have a DISPLAY would you want to start it again.

 

I suggest another control level, to check if you are already in X or not (you can do it also with $(tty) instead of $TERM):

 

case $TERM in

     *xterm|rxvt) :;; #Do nothing, we are already in X

     *) YOURCODE;; # We are at VT and we want to go into X.

esac

 

That will also be buggy if we log into a VT when there is already an X session used on VT7 (display :0)

 

So my advice will be not to put such code in /etc/profile, unless you develop it a little bit more to include checks for letting bash know which is your environment and wich X-VT are free to start them.

Link to comment
Share on other sites

The right syntax should be [...] with '{' instead of "("
Yes, you're right ! I typed too fast :oops:
But that will be buggy if you login when you already are in X (ie: "su -"); I think I don't understand why If you actually have a DISPLAY would you want to start it again.
Actually, I don't start X again; just the window manager, and optionnaly additionnal apps. It is a kind of follow-up to the thread I refered to. In this thread, we discuss a remote X display via only SSH (no XDMCP). The process is to start X (nothing else), then login via SSH with X11-forwarding, and then remotely start the window manager.

You can recognize this setup because SSH creates a proxy-display for the user on the server; this proxy-display is "localhost:10.0" or further.

 

But my previous post was crude at best, and I know it. It needs refining. But I know that qeldroma is a capable person :)

 

Yves.

Link to comment
Share on other sites

Oh, my script fails in a special way:

 

When i am starting it DIRECTLY, it works well.

After having booted, i can manually switch "init 5" and it does. But when i am Restarting the machine in "init 5", the dm-service fails, the screen flashes some times, i can see the X, but after the 4. -5. flash, i am back to console.

 

Waiting some seconds and starting "prefdm" manually works then again?!

Link to comment
Share on other sites

I suggest you to do a little of debugin to your script to see what does wrong; start your script using the -x or -xv flags and redirect the stderr to a file:

#! /bin/sh -x

exec 2> /home/username/debug-$(date +%s).txt

 

or if you want to be more polite:

#! /bin/sh

exec 2> /home/username/debug-$(date +%s).txt

set -x

 

 

Check "/home/username/debug-XXXXXX.txt" after each scenario to see what (or if something) makes the difference in your script

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...