You are not logged in.

#1 2014-08-05 22:27:51

cplusplus
Member
Registered: 2014-08-02
Posts: 43

[Solved] Log Out of One Session and Immediately Into Another.

This is a fairly specific question, but any help or points in the right direction would be appreciated.

I have a login with an XBMC session, that when you login it launches xbmc-standalone. I'd like to make it so that when you logout of that session, it immediately logs in to a different session. (Gnome). And vice-versa.

Does anyone have any idea how I might go about accomplishing this?

Solution:
Scroll to bottom of page.

Last edited by cplusplus (2014-08-06 04:20:26)

Offline

#2 2014-08-05 22:35:47

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [Solved] Log Out of One Session and Immediately Into Another.

How do you login and start X?


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2014-08-05 22:36:31

cplusplus
Member
Registered: 2014-08-02
Posts: 43

Re: [Solved] Log Out of One Session and Immediately Into Another.

Currently, I'm using GDM, but am willing to switch.

Edit:
GDM automatically logs in to my xbmc user and session.

Last edited by cplusplus (2014-08-05 22:46:56)

Offline

#4 2014-08-05 22:57:09

cplusplus
Member
Registered: 2014-08-02
Posts: 43

Re: [Solved] Log Out of One Session and Immediately Into Another.

I believe the term I'm looking for is kiosk mode? Correct me if I'm wrong.

Offline

#5 2014-08-05 23:21:22

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [Solved] Log Out of One Session and Immediately Into Another.

No, kiosk mode is running a single (generally locked down) application in a session.

I don't use GDM, but I would think that what you want is to start X manually and have a hack in your profile that alternates between Gnome and XMBC, each with their own xinitrc file.
It should be easy enough to test:

if [[ -z "$DISPLAY" ] && [[ $(tty) = /dev/tty1 ]]; then
    exec startx -- vt1
    exec startx /path/to/xmbc_xinitrc --vt1
fi

This could cause some sort of horrible race condition, or it may not work at all...


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#6 2014-08-05 23:25:10

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,648
Website

Re: [Solved] Log Out of One Session and Immediately Into Another.

JWR, would that even work?  The first exec would execute on every log-in, the second would never be reached.  This would also require a fresh login to the tty between each one.

Is a new Xserver session needed?  Or could the following in xinitrc work:

while true; do
   some-xbmc-command
   some-gnome-command
done

I don't know what the specific commands would be as I use neither gnome nor xbmc, but I did something like this for a while with dwm and openbox.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#7 2014-08-05 23:30:09

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [Solved] Log Out of One Session and Immediately Into Another.

I don't know: I was just guessing that when the first X server terminated, the second command would get run (in the same TTY).


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#8 2014-08-05 23:34:26

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,648
Website

Re: [Solved] Log Out of One Session and Immediately Into Another.

The `exec` would have to go then.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#9 2014-08-05 23:41:49

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [Solved] Log Out of One Session and Immediately Into Another.

Trilby wrote:

The `exec` would have to go then.

Ah, yes, it would tongue


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#10 2014-08-05 23:44:19

cplusplus
Member
Registered: 2014-08-02
Posts: 43

Re: [Solved] Log Out of One Session and Immediately Into Another.

Trilby wrote:

I don't know what the specific commands would be as I use neither gnome nor xbmc, but I did something like this for a while with dwm and openbox.

Is there a way for me to test the commands in a safe environment without messing with my init file just yet?

Offline

#11 2014-08-05 23:49:25

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [Solved] Log Out of One Session and Immediately Into Another.

Don't bother: I just tested it and it doesn't work tongue

I'm not sure how you can autoload a new, different session immediately upon exiting the old one. Trilby knows a lot more about this stuff, though, so disregard my suggestions and he may be able to offer something helpful.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#12 2014-08-05 23:50:46

cplusplus
Member
Registered: 2014-08-02
Posts: 43

Re: [Solved] Log Out of One Session and Immediately Into Another.

jasonwryan wrote:

Don't bother: I just tested it and it doesn't work tongue

I'm not sure how you can autoload a new, different session immediately upon exiting the old one. Trilby knows a lot more about this stuff, though, so disregard my suggestions and he may be able to offer something helpful.

Actually, I tested the while loop in a bash script with just /usr/bin/xbmc-standalone and it seems to immediately open xbmc when i quit out of it, i just need to test it with gnome-session now.

Edit:
I'll have to look in to how the gnome-session is actually called. Immediately got this error while testing:

Could not acquire name on session bus

Last edited by cplusplus (2014-08-05 23:55:00)

Offline

#13 2014-08-06 00:12:08

cplusplus
Member
Registered: 2014-08-02
Posts: 43

Re: [Solved] Log Out of One Session and Immediately Into Another.

So, This is what I've come up with, but I can't test it without changing my init file, because apparently only console users my run startx. Not just that, but I'm not actually sure which file to put it in to....

#!/bin/bash
while true; do
/usr/bin/xbmc-standalone
/usr/bin/startx
done

Any suggestions or obvious flaws in logic?

Edit:
I'm dumb. Obviously putting this into the init file will cause a recursively infinite loop, only starting xbmc, because startx is called again. Should I just be calling gnome-session instead?

Last edited by cplusplus (2014-08-06 00:15:17)

Offline

#14 2014-08-06 00:23:23

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,648
Website

Re: [Solved] Log Out of One Session and Immediately Into Another.

Just put that while loop in xinitrc - that was my whole point, don't start and stop the xserver repeatedly, just change clients.

I'm not sure why JWR's test didn't work, but I was using the following for a while and it worked fine:

while true; do
   dwm
   openbox
done

For a while I even had a file in my home directory called ~/.wm which contained just one line to launch a wm.  I could revise that file from within an X session, exit the session, and the newly selected one would start without having to restart X.  Or I could put "exit" in that file to exit out of X without having to "killall" a while loop:

# in xinitrc:
while true; do source ~/.wm done

The concept for this is actually from the DWM page of the wiki where there is something like the following to be able to rebuild dwm and seemlessly restart it:

while true; do dwm; done

"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#15 2014-08-06 02:23:06

cplusplus
Member
Registered: 2014-08-02
Posts: 43

Re: [Solved] Log Out of One Session and Immediately Into Another.

So, I have it mostly working, but could use a little help figuring out this last little bit...

This is what I have:

xrandr --output HDMI3 --set audio force-dvi --mode 1920x1080
x11vnc -forever -bg &
while true; do
  xbmc-standalone
  gnome-session
done

It works for the first time around, however when i get to gnome-session again, gnome fails to load correctly.

Edit:
I've found a solution that I'm not a huge fan of, but it works.

I changed the line 'gnome-session' to 'exec gnome-session'. It works, but it logs me out of my vnc, presumably because it restarts the xinit entirely? I'm not 100% sure what is happening to be honest. I'd love to be enlightened though.

Last edited by cplusplus (2014-08-06 02:54:17)

Offline

#16 2014-08-06 02:52:29

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,648
Website

Re: [Solved] Log Out of One Session and Immediately Into Another.

I suspect it is due to gnome-session being more than a window manager (like openbox-session is more than openbox).  Some services or background processes are started and not killed when the session exits, so it cannot restart properly.  These may be associated with dbus, or various other bits.  I can think of two approaches:

1) identify these processes and kill them each time through the loop*.  They could be identified by inspecting ps/top output or looking into gnome-session documentation.

2) figure out how to launch just the WM component of gnome session (this used to be mutter, but I think that's changed - not sure).  While this approach may seem cleaner it might have a downside: if different bits of the gnome-session puzzle rely on keeping tabs on other components' PIDs this will fail and option 1 will be the only approach.

* total OT note: this is much like the time-travel show I'm currently watching where one of the main characters traveled back a week ... then had to kill the other version of herself so they didn't conflict.  Gruesome, but apt comparison.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#17 2014-08-06 04:19:26

cplusplus
Member
Registered: 2014-08-02
Posts: 43

Re: [Solved] Log Out of One Session and Immediately Into Another.

The final solution:

while true; do
  xbmc-standalone
  gnome-session
  pkill gnome-shell
done

Thanks to Trilby and jasonwyran

Offline

Board footer

Powered by FluxBB