Author Topic: cmd-line logout/re-login  (Read 3702 times)

Offline pinoc

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2844
    • other projects...
cmd-line logout/re-login
« on: May 10, 2010, 01:37:31 PM »
need to find a command-line sequence to logout and then re-login a given user. I could logout with:
Code: [Select]
qdbus org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.logout 0 0 2but that leavers me at the login-screen from where one would have to manually login to the user account. What I need is a cmd which will  logout and re-login a given user without stopping at the login-screen. Any ideas?
-p.

Offline Rudge

  • Hero Member
  • *****
  • Posts: 9690
  • I'm Just A Dog.
Re: cmd-line logout/re-login
« Reply #1 on: May 10, 2010, 01:49:20 PM »
Are you just trying to reload the user's profile?


-If you wish to make an apple pie from scratch, you must first invent the universe-  Carl Sagan

Offline pinoc

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2844
    • other projects...
Re: cmd-line logout/re-login
« Reply #2 on: May 10, 2010, 02:06:52 PM »
Are you just trying to reload the user's profile?

essentially I need the user to logout and re-login but I want to do this from a cmd-line from inside a script. Maybe reloading the user's profile might be enough, how would I do that from a cmd-line? But I'm afraid I will have to restart X to apply the intended changes to the desktop layout and that means logout/login.
-p.

Offline Rudge

  • Hero Member
  • *****
  • Posts: 9690
  • I'm Just A Dog.
Re: cmd-line logout/re-login
« Reply #3 on: May 10, 2010, 02:23:45 PM »
Not sure about doing in a script but the command is ". /etc/profile" I think.  ;)


-If you wish to make an apple pie from scratch, you must first invent the universe-  Carl Sagan

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15847
  • LXDE! Coffee, Bacon and Cheesecake!
Re: cmd-line logout/re-login
« Reply #4 on: May 10, 2010, 02:39:52 PM »
If you know the commands used in logout, restartx and in autologin, maybe something like
logout-command
restartx
autologin-command
could be used as a basis for a script.

Probably not much help here. :-[

Online daniel

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3737
  • God knows, i'm not an Angel!
    • Tipps und Tricks
Re: cmd-line logout/re-login
« Reply #5 on: May 10, 2010, 02:57:53 PM »
Can work autologin after restartx?

Offline pinoc

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2844
    • other projects...
Re: cmd-line logout/re-login
« Reply #6 on: May 10, 2010, 03:03:31 PM »
Can work autologin after restartx?

I guess it could work but my primary question is: is there a command to bypass the login window and login a given user?

Offline Neal ManBear

  • Administrator
  • Super Villain
  • *****
  • Posts: 15847
  • LXDE! Coffee, Bacon and Cheesecake!
Re: cmd-line logout/re-login
« Reply #7 on: May 10, 2010, 03:09:56 PM »
Autologin does that. At the end of boot up, when X is started the selected user's DE is loaded. However, after a logout this does not happen. There may be something useful in the autologin script.

Offline Rudge

  • Hero Member
  • *****
  • Posts: 9690
  • I'm Just A Dog.
Re: cmd-line logout/re-login
« Reply #8 on: May 10, 2010, 03:11:10 PM »
pinoc, maybe you are asking the wrong question.

What exactly are you trying to accomplish? Perhaps there is someone that could shed some light on how to do it that may not require the user to log off.  

Just a thought.  :D


-If you wish to make an apple pie from scratch, you must first invent the universe-  Carl Sagan

Online daniel

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3737
  • God knows, i'm not an Angel!
    • Tipps und Tricks
Re: cmd-line logout/re-login
« Reply #9 on: May 10, 2010, 03:17:48 PM »

Offline YouCanToo

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 5331
  • Location: Lebanon, OR., USA
    • Spreading the word.......
Re: cmd-line logout/re-login
« Reply #10 on: May 10, 2010, 03:49:28 PM »
Are you just trying to reload the user's profile?

essentially I need the user to logout and re-login but I want to do this from a cmd-line from inside a script. Maybe reloading the user's profile might be enough, how would I do that from a cmd-line? But I'm afraid I will have to restart X to apply the intended changes to the desktop layout and that means logout/login.
-p.

Would "Switch User" not do what you want without the fuss?




Be sure to visit the NEW Knowledge Base


Linux is user-friendly- it's just picky who its friends are!

Offline pinoc

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2844
    • other projects...
Re: cmd-line logout/re-login
« Reply #11 on: May 10, 2010, 04:01:20 PM »
pinoc, maybe you are asking the wrong question.

What exactly are you trying to accomplish? Perhaps there is someone that could shed some light on how to do it that may not require the user to log off.  

Just a thought.  :D

Rudge, good point.  ;)
Ok then, this is about the KDE4 desktop widget layout. For example: you click the cashew, select "Unlock widgets", then for some of your favorite apps from the PCmenu -> ... you right-click and choose "Add to Desktop", and position these widgets where you want them on the desktop. When done, click the cashew, and select "Lock widgets".  The position and size of the taskbar, the specific position of your widgets (in pixel locations), and some other details are then written to the file ~/.kde4/share/config/plasma-desktop-appletsrc.
Now, if you manually change a widget position in that file then this new position will only be applied to the desktop after you logout and login again. Naturally you will now ask yourself why the heck I wanted to manually change the position of a widget after I spent all that time before to place them where I want them. And the answer is because I'm working on a special remaster and this remaster should show a specific desktop widget layout consistently for any screen-resolution. For this reason, I have setup 11 screen-resolution specific plasma-desktop-appletsrc files. In the live-session, the actual screen-resolution is detected and then the corresponding plasma-desktop-appletsrc-file is copied into the guest-account. To then apply the correct widget-layout for the given screen-resolution I must logout and then re-login the guest-account. Everything works well so far and for now I just logout and tell the user to login again. But it would be nicer to have this automatic, hence the relogin command.  Maybe Leiche's link will help.

PS: the true screen-resolution can only be detected (using xrandr) after X has started. It does not necessarily correspond to the one written in xorg.conf, for example the xorg.conf of a virtual machine setup will say you have a 1024x768 but then auto-scale the display to fit your different screen-resolution. So I first have to have X running in order to get the real screen-resolution, then apply the correct plasma-desktop-appletsrc file, then logout/login, and then I get the correct screen-resolution specific widget desktop layout.

-p

Offline Joble

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 6804
  • USA - Mountain Time
Re: cmd-line logout/re-login
« Reply #12 on: May 10, 2010, 04:07:18 PM »
Can you do init3 and then init5 or does that end up at the login again?

----------------------
or kill x and startx

I'll try this when I get home.
« Last Edit: May 10, 2010, 04:11:38 PM by Joble »
Search First.
Forum Rules
Hero means I talk a lot, nothing more, nothing less!
Have an Awesome Day!
Healthy System

Offline Old-Polack

  • Administrator
  • Super Villain
  • *****
  • Posts: 11581
  • ----IOFLU----
Re: cmd-line logout/re-login
« Reply #13 on: May 10, 2010, 05:15:34 PM »
pinoc:

If you are doing this just to test what the new configuration will look like, and the changed code is in place, or written in the script, from an X terminal, (Konsole)

[polack@littleboy ~]$ startx -- :1

will start a new X session on screen 1. Ctrl+Alt+F7 will return you to the original desktop on screen 0. Ctrl+Alt+F8 will allow you to switch back to the desktop on screen 1.

You can log out of the second session, and be returned to the first, or kill it from the first with Ctrl+C in the originating terminal session. If you wish to log in as a different user, you can su to that user, enter his password, then enter the startx -- :1 command and he will be logged into the new X session.

How you put that information into a script, I haven't a clue. I've just used this so far to give my grand kids their own desktops to use for short periods while visiting, before I built them computers of their own. I could set up their desktop as they wanted it, without having to log out of one and into the other repeatedly.
« Last Edit: May 10, 2010, 05:17:09 PM by old-polack »
Old-Polack

Of what use be there for joy, if not for the sharing thereof?



Lest we forget...

Offline travisN000

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1758
Re: cmd-line logout/re-login
« Reply #14 on: May 19, 2010, 10:07:49 PM »
How about the following command (as user) to restart plasma-desktop:

Code: [Select]
killall plasma-desktop && plasma-desktop

..or maybe there is a better / cleaner way  ???

« Last Edit: May 20, 2010, 12:26:39 AM by travisn000 »