Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux console and gpm #125

Closed
jocutajar opened this issue Nov 10, 2021 · 8 comments
Closed

Linux console and gpm #125

jocutajar opened this issue Nov 10, 2021 · 8 comments

Comments

@jocutajar
Copy link

I've noticed that running vtm on the linux console and with gpm doesn't quite work. Is it meant to? Would it be difficult to support? Or am I doing something wrong? It seems that GPM mouse events are simply ignored. I'm not sure if I can achieve anything without a mouse there.

@o-sdn-o
Copy link
Collaborator

o-sdn-o commented Nov 10, 2021

vtm already supports mouse in Linux console.

The following conditions must be met

  • RW access to the /dev/input/mice meta device
    • One time access (until reboot):
       sudo chmod 666 /dev/input/mice
    • Permanent access (set udev rules):
      sudo echo 'SUBSYSTEM=="input", KERNEL=="mice", MODE="666"' > /etc/udev/rules.d/85-vtm-mouse-access.rules
      sudo udevadm control --reload-rules && udevadm trigger
  • and the presence of TERM=linux (by default for the linux console)

GPM is not used, vtm works with mouse events directly through /dev/input/mice.

@o-sdn-o
Copy link
Collaborator

o-sdn-o commented Nov 10, 2021

There are several limitations when working in the linux console:

  • The mouse will not work when connecting to vtm remotely directly from the linux console prompt, the remote vtm does not have access to local /dev/input/mice and GPM doesn't support xterm-style mouse reporting. Run vtm locally in the linux console, and then connect remotely via the built-in vtm terminal.
  • Only a mouse that supports the imps2 (ImPS/2 Generic Wheel Mouse) protocol works in vtm, but it seems to me that now all mice support it.

If your mouse doesn't work, write me your mouse model and I will add support for the protocol it uses.

@o-sdn-o
Copy link
Collaborator

o-sdn-o commented Nov 10, 2021

GPM interferes with vtm. To use the mouse in vtm in the Linux console, GPM must be disabled or uninstalled. Otherwise, GPM will highlight text in the console when dragging with the mouse for example.

@jocutajar
Copy link
Author

Thanks for your excellent support. I got it working with disabling the GPM and adding my user to the input group + login again.

$ ls -la /dev/input/mice 
crw-rw---- 1 root input 13, 63 Nov  2 23:58 /dev/input/mice

I didn't like making the mice world writeable so I chose the more conservative approach.

@o-sdn-o
Copy link
Collaborator

o-sdn-o commented Nov 10, 2021

adding my user to the input group

Adding a specific user to the input group opens read/write access to the keyboard device for all processes running on behalf of that user. File /dev/input/event* logs keyboard events, for example.

Instead, you can restrict access only to the mouse device, but for this you need to create a separate device node:

#!/bin/bash
# Create a separate mice device node and allow users to access it.

# Group for allowed users.
sudo groupadd vtm

# Script for node init.
sudo bash -c 'cat <<EOF > /etc/udev/rules.d/mice.vtm.sh
#!/bin/bash
mice=/dev/input/mice.vtm
# See https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/admin-guide/devices.txt
mknod --mode=660 \$mice c 13 63
chown root:vtm \$mice
EOF'

# Allow execution
sudo chmod +x /etc/udev/rules.d/mice.vtm.sh

# Script run rule.
sudo bash -c "echo 'SUBSYSTEM==\"input\", KERNEL==\"mice\", RUN+=\"/etc/udev/rules.d/mice.vtm.sh\"' > /etc/udev/rules.d/85-mice.vtm.rules"

# Trigger udev to reload rules
sudo udevadm control --reload-rules && sudo udevadm trigger

# Adding user to the vtm group
sudo usermod -a -G vtm user_name

user_name - Your linux user name/login.

I added an option to vtm so that it tries to open not only /dev/input/mice, but also /dev/input/mice.vtm. I will make this option configurable in the future.

@ghost
Copy link

ghost commented Feb 8, 2022

I see you mentioned GPM having unsolvable problems on Reddit. Can you mention what can't work? I'm just curious to try it out and see. :-) My GPM code is here, but a bit messy: I directly adapted it from ncurses mouse model (where I have to track all the buttons to know what to release later), and could probably simplify it a lot.

@o-sdn-o
Copy link
Collaborator

o-sdn-o commented Feb 9, 2022

I don’t remember it exactly, and I didn’t document it, but offhand there were such problems:

I was also very confused by this issue, I thought that I should not rely on gpm at all.

@ghost
Copy link

ghost commented Feb 9, 2022

Thank you!

And of course direct gpm dependency itself

That's a good point too. I couldn't build on Alpine Linux for a while because their gpm package didn't install correctly, and somehow no one noticed before me. (It's fixed now.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants