You are not logged in.

#1 2024-01-20 21:45:01

LittleSandra
Member
Registered: 2021-01-25
Posts: 86

[SOLVED] Possible to start i3wm from tty1 ?

Dear all smile

I am running Wayland+Sway and just bought Hollow Knight from gog.com, which locks up constantly under Wayland. So I need a way to switch to X when I want to play it.

I don't have any login managers such as GDM/LDM or similar installed, so Sway gets started when I login on tty1 as it reads .profile

#!/bin/bash
# https://wiki.archlinux.org/title/Xinit#Autostart_X_at_login
if [ -z "${DISPLAY}" ] && [ "${XDG_VTNR}" -eq 1 ]; then
  exec sway > ~/.sway.log 2>&1
fi

If I exit Sway, so I am back in tty1 and type "startx", then I was hoping i3wm would start, as I have that installed and configured. I just get the empty X instead.

Does anyone know how I can start i3wm from tty1?

Hugs,
Sandra smile

Last edited by LittleSandra (2024-01-20 23:10:39)

Offline

#2 2024-01-20 21:51:24

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,642

Re: [SOLVED] Possible to start i3wm from tty1 ?

Have you configured your ~/.xinitrc file?  Can you please post it here?

Here is mine:

#!/bin/sh
#
# ~/.xinitrc
#
# Executed by startx (run your window manager from here)

if [ -d /etc/X11/xinit/xinitrc.d ]; then
  for f in /etc/X11/xinit/xinitrc.d/*; do
    [ -x "$f" ] && . "$f"
  done
  unset f
fi
[[ -f ~/.Xresources ]] && xrdb -merge -I$HOME ~/.Xresources

autocutsel -fork &
autocutsel -selection PRIMARY -fork &


case $WM in
    i3)
	   exec i3 >~/i3log-$(date +'%F-%k-%M-%S') 2>&1
	   ;;
    plasma)
	   export DESKTOP_SESSION=plasma
	   exec startplasma-x11
	   ;;
    plasma-wayland)
	   export DESKTOP_SESSION=wayland
        exec startplasma-wayland
        ;;
    *)
	   export DESKTOP_SESSION=plasma
	   exec startplasma-x11
	   ;;
esac

It could be a little stale as I never use it anymore; I just use Sway.

With that .xinitrc, one would start i3 with:  WM=i3 startx

Last edited by ewaller (2024-01-20 22:00:44)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

#3 2024-01-20 21:57:50

Head_on_a_Stick
Member
From: The Wirral
Registered: 2014-02-20
Posts: 9,003
Website

Re: [SOLVED] Possible to start i3wm from tty1 ?

I use different TTYs for different desktops:

# ~/.profile

case "$(tty)" in
   /dev/tty1) exec sway > ~/.local/share/sway/sway.log 2>&1 ;;
   /dev/tty2) exec startx ;;
   /dev/tty3) exec tty-clock -cs
esac

Note that ~/.profile doesn't need a shebang line.

I'm surprised ~/.profile works for the OP though because bash won't read it if ~/.bash_profile exists and that file is supplied by the bash package.


Jin, Jîyan, Azadî

Offline

#4 2024-01-20 22:55:04

LittleSandra
Member
Registered: 2021-01-25
Posts: 86

Re: [SOLVED] Possible to start i3wm from tty1 ?

ewaller wrote:

Have you configured your ~/.xinitrc file?  Can you please post it here?

I don't have one it seams.

ewaller wrote:

With that .xinitrc, one would start i3 with:  WM=i3 startx

Interesting. In which file would I put WM=i3 startx ?

Offline

#5 2024-01-20 22:57:27

LittleSandra
Member
Registered: 2021-01-25
Posts: 86

Re: [SOLVED] Possible to start i3wm from tty1 ?

Head_on_a_Stick wrote:

I use different TTYs for different desktops:

# ~/.profile

case "$(tty)" in
   /dev/tty1) exec sway > ~/.local/share/sway/sway.log 2>&1 ;;
   /dev/tty2) exec startx ;;
   /dev/tty3) exec tty-clock -cs
esac

Note that ~/.profile doesn't need a shebang line.

I'm surprised ~/.profile works for the OP though because bash won't read it if ~/.bash_profile exists and that file is supplied by the bash package.

It is really interesting that you mention that, because it doesn't work, and I couldn't figure out why! Thanks for solving that problem with the shebang smile

That looks like a really nice solution. So when you switch to tty2 then i3wm starts?

Offline

#6 2024-01-20 22:58:48

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,042

Re: [SOLVED] Possible to start i3wm from tty1 ?

LittleSandra wrote:

I don't have one it seams.

That's the problem. How do you expect startx to run i3 if you're not telling it to?

#!/bin/sh

if [ -d /etc/X11/xinit/xinitrc.d ]; then
  for f in /etc/X11/xinit/xinitrc.d/*; do
    [ -x "$f" ] && . "$f"
  done
  unset f
fi
[[ -f ~/.Xresources ]] && xrdb -merge -I$HOME ~/.Xresources

exec i3

Online

#7 2024-01-20 23:10:25

LittleSandra
Member
Registered: 2021-01-25
Posts: 86

Re: [SOLVED] Possible to start i3wm from tty1 ?

That solved the problem smile Thanks a lot smile

Offline

#8 2024-01-20 23:25:52

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,642

Re: [SOLVED] Possible to start i3wm from tty1 ?

LittleSandra wrote:

Interesting. In which file would I put WM=i3 startx ?

That is the command one enters into the shell.    It sets the environmental variable WM to i3, then runs startx.  Same thing if I want to run plasma-wayland

If I don't set WM, then it defaults to plasma on x11


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

Board footer

Powered by FluxBB