RedBearAK / toshy

Keymapper config to make Linux work like a 'Tosh!
https://toshy.app
GNU General Public License v3.0
379 stars 19 forks source link

[BUG] Installation on Ubuntu 22.04: `Unknown session type: tty` #383

Open kostrykin opened 3 months ago

kostrykin commented 3 months ago
Bare metal or virtual machine: 
Bare metal

Linux distro name: Ubuntu 22.04

$ cat /etc/issue
Ubuntu 22.04.4 LTS \n \l

$ uname -a
Linux hostname 6.8.0-40-generic #40~22.04.3-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 30 17:30:19 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

Keyboard type: Apple, connected via NoMachine

Problem observed:

Following the instructions for installation: https://github.com/RedBearAK/toshy?tab=readme-ov-file#how-to-install

./setup_toshy.py install
(DD) Home user local bin not part of PATH string.

(!!) NOTICE: It is ESSENTIAL to have your system completely updated.

Have you updated your system recently? [y/N]: y

The "~/.local/bin" folder is not in PATH. OK to add it? [Y/n]: Y

§  Getting environment information...
================================================================================
The active init system is: 'systemd' (Systemd)

Traceback (most recent call last):
  File "/tmp/toshy-main/./setup_toshy.py", line 3515, in <module>
    handle_cli_arguments()
  File "/tmp/toshy-main/./setup_toshy.py", line 3328, in handle_cli_arguments
    main(cnfg)
  File "/tmp/toshy-main/./setup_toshy.py", line 3377, in main
    get_environment_info()
  File "/tmp/toshy-main/./setup_toshy.py", line 308, in get_environment_info
    env_info_dct   = env.get_env_info()
  File "/tmp/toshy-main/lib/env.py", line 215, in get_env_info
    raise EnvironmentError(f'\n\nENV: Unknown session type: {SESSION_TYPE}.\n')
OSError: 

ENV: Unknown session type: tty.
RedBearAK commented 3 months ago

Were you actually in a TTY (virtual terminal) at the time? Not logged into a graphical desktop environment? Toshy is designed to only be active in a graphical session. I’ve never seen that error in a graphical session.

kostrykin commented 3 months ago

No, I was on the default Ubuntu 22.04 terminal app, I think it's gnome-terminal

RedBearAK commented 3 months ago

So you're just in a regular Ubuntu 22.04 desktop environment (GNOME), and probably logged into Wayland (that's been the default session type for a long time). But you're remoting in with NoMachine. That's probably going to mess with the way the modifier keys work. Many remote desktop apps fail to pass certain keys like the Meta/Super/Win/Cmd key. I'm not sure how that's going to work out.

Yet I don't know how that would cause the session type to be detected as "tty" unless you had some non-standard desktop environment. I've literally never seen that come up as "tty" in hundreds of tests on all sorts of different Linux distros and desktop environments. Even a tiling window manager should have the session type set to either "x11" or "wayland".

Can you do this and see what comes out?

echo $XDG_SESSION_TYPE

If it still says "tty" you can try to set it to "wayland" manually before running the Toshy setup script. But, without knowing why it would say "tty" in the first place, Toshy still wouldn't necessarily work after installing, if it just saw "tty" as the session type every time it tried to start.

export XDG_SESSION_TYPE="wayland"

Give it a try to at least get through the install. But unless this is caused by NoMachine, I really don't understand what's going on.

I may have to modify the environment module to keep it from raising the EnvironmentError exception in this case.

RedBearAK commented 3 months ago

In the Downloads folder where the Toshy install files were extracted (usually "toshy-main"), you can open up lib/env.py and look for this:

    if SESSION_TYPE not in ['x11', 'wayland']:
        raise EnvironmentError(f'\n\nENV: Unknown session type: {SESSION_TYPE}.\n')

Then change it to this:

    if SESSION_TYPE not in ['x11', 'wayland', 'tty']:
        error(f'\n\nENV: Unknown session type: {SESSION_TYPE}.\n')

This will let the install proceed without the immediate error, but if that value is still "tty" once the keymapper tries to start, the keymapper will have no idea how to get the window context.

There is a way in the config file to override any part of the detected environment, but that's basically never been used by anyone that I know of. Before trying that, I'd like to figure out why the session type comes up as "tty".

RedBearAK commented 3 months ago

I can't replicate the "tty" session type, even after installing Ubuntu 22.04.4 LTS in a virtual machine and remoting into it with NoMachine.

Unless you can think of something unusual about your Ubuntu install that might be causing this, I have no idea what's going on with that session type coming up as "tty". That's really not normal.

RedBearAK commented 2 months ago

@kostrykin

Can I ask if you start your desktop environment manually, without using a display/login manager like GDM or SDDM? I'm seeing this "tty" session type when manually starting miracle-wm-session on a new Fedora 41 spin. Never seen it anywhere else.