You are not logged in.

#1 2015-11-02 14:36:31

mbtamuli
Member
From: Pune, India
Registered: 2015-10-01
Posts: 11
Website

Start multiple WM/DE(on different tty)

I want to start both i3 and cinnamon.

This is my .xinitrc

#! /bin/bash

# Keeping i3 as default
session=${1:-i3}

case $session in
    cinnamon          ) exec cinnamon-session;;
    i3|i3wm           ) exec i3;;
    # No known session, try to run it as command
    *) exec $1;;
esac

Now,
I can log in on tty1 and start i3 with:

xinit i3 -- :0 vt1

and log in again with the same user on tty2 and start cinnamon with:

xinit cinnamon -- :1 vt2

Can I achieve the same with a modified .xinitrc without passing the flags everytime manually?

Also I tried to read this "Back to Basics With X and systemd", but did not understand this.

#!/bin/bash

TTY=${TTY:-$(tty)}
TTY=${TTY#/dev/}

if [[ $TTY != tty* ]]; then
  printf '==> ERROR: invalid TTY\n' >&2
  exit 1
fi

printf -v vt 'vt%02d' "${TTY#tty}"

xinit -- "$vt" "$@"

So here xinit is run. So if I want to run i3, should I do this -

xinit i3 -- "$vt" "$@"

This is not working.

Offline

#2 2015-11-02 15:20:47

Awebb
Member
Registered: 2010-05-06
Posts: 6,275

Re: Start multiple WM/DE(on different tty)

What stops you from adding the $TTY logic to your .xinitrc and wrap it in some "case $TTY in" construct and start the whole thing with startx?y

Offline

#3 2015-11-03 12:49:08

mbtamuli
Member
From: Pune, India
Registered: 2015-10-01
Posts: 11
Website

Re: Start multiple WM/DE(on different tty)

This is my working .xinitrc

#! /bin/bash

# Keeping i3 as default
session=${1:-i3}

case $session in
    cinnamon          ) exec cinnamon-session;;
    i3|i3wm           ) exec i3;;
    # No known session, try to run it as command
    *) exec $1;;
esac

So now, when I do

xinit i3 -- :0 vt1

It runs.

When I put only this in the script, and just startx, it does open i3, just a black screen

#!/bin/bash

TTY=${TTY:-$(tty)}
TTY=${TTY#/dev/}

if [[ $TTY != tty* ]]; then
  printf '==> ERROR: invalid TTY\n' >&2
  exit 1
fi

printf -v vt 'vt%02d' "${TTY#tty}"
xinit i3 -- "$vt" "$@"

Does the .xinitrc require exec to be in the script? I guess the second .xinitrc does not work as it run

xinit i3 -- "$vt" "$@"

instead of

exec i3

If it does not run without the case statements and when I just try with i3, there is no use trying "case $TTY in" construct.

Offline

#4 2015-11-03 13:44:57

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

Re: Start multiple WM/DE(on different tty)

You do not need exec in an xinitrc, it's just handy to remove the extra process.  But you definitely can't launch X from within X, and worse yet trying to do so recursively is crazy.

Did you read AWebb's advice?  I was going to suggest the exact same thing he did after I read your first post.

Also, while it's not really harmful, there is no need of the extra process to get the tty number from /usr/bin/tty then trim it, just use $XDG_VTNR


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

Offline

#5 2015-11-04 11:45:27

wirr
Member
Registered: 2009-10-25
Posts: 70

Re: Start multiple WM/DE(on different tty)

It looks like you cannot set $DISPLAY in your .xinitrc. How would you pass $TTY to the X server?

Untested:

#!/bin/bash
startx $1 -- :$((XDG_VTNR-1)) vt${XDG_VTNR}

(I think you just put $@ at the wrong place.)

Also where are my input devices (I did startx i3 -- :1 on vt2)? I had to reset sad

Offline

#6 2015-11-05 05:48:25

mbtamuli
Member
From: Pune, India
Registered: 2015-10-01
Posts: 11
Website

Re: Start multiple WM/DE(on different tty)

wirr wrote:

It looks like you cannot set $DISPLAY in your .xinitrc. How would you pass $TTY to the X server?

Untested:

#!/bin/bash
startx $1 -- :$((XDG_VTNR-1)) vt${XDG_VTNR}

(I think you just put $@ at the wrong place.)

Also where are my input devices (I did startx i3 -- :1 on vt2)? I had to reset sad

Yes. I think this is true "cannot set $DISPLAY in your .xinitrc"
If you see my working .xinitrc what I currently do to get things running,

When I only want to start one WM/DE -
On tty1,      xinit i3 -- :0 vt1     OR     xinit cinnamon -- :0 vt1

When I want to start two WM/DE -
On tty1,      xinit i3 -- :0 vt1
AND   
On tty2,      xinit cinnamon -- :1 vt2

Offline

#7 2015-11-05 08:33:17

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: Start multiple WM/DE(on different tty)

mbtamuli wrote:

If you see my working .xinitrc what I currently do to get things running,

When I only want to start one WM/DE -
On tty1,      xinit i3 -- :0 vt1     OR     xinit cinnamon -- :0 vt1

When I want to start two WM/DE -
On tty1,      xinit i3 -- :0 vt1
AND   
On tty2,      xinit cinnamon -- :1 vt2

This thread is a little messy/confusing. Let's see if I understand the situation: this is what you do currently and it works, but you wanted to do this "without passing the flags everytime manually". If you use startx instead of xinit, you can simply do `startx i3` and `startx cinnamon` on those ttys. Would that work for you?

Offline

Board footer

Powered by FluxBB