Klaus Knopper answers your Linux questions

Ask Klaus

Article from Issue 189/2016
Author(s):

Klaus talks about the gpm mouse driver for ncurses, auto-login without a password, using Live discs, and associating MIME types.

Gpm and Auto-Login

Dear Klaus:

It seems like it should be possible using gpm or perhaps mev to have a mouse click either send a startx or Kodi command to the shell. For example, the man [page for the] gpm command indicates that something like

gpm -S "kodi:startx:sudo shutdown -h now"

could be used to set up the mouse so that the left mouse button starts Kodi, the middle button starts X windows, and the right button shuts down the system, but it must be more complicated than this because this does not work.

The second issue is how to auto-login at the command line without a password to begin with.

Kind regards, Charles

Indeed, the -S special command in gpm is really special. Before getting to the point, I'll tell you some more about Gpm.

Gpm is a "mouse driver" for the Linux text console that allows you to select, copy and paste text, and navigate in ncurses-enabled programs such as dialog. For example, you can use the text browser elinks on the text console and click on links or menus with the "text mouse cursor" that's enabled with Gpm.

Because no Xorg as a graphical interface is running on the text console, Gpm has to provide its own drivers. In the case of an old PS/2 mouse, this is done with

gpm -m /dev/psaux -t ps2

(which I use in Qemu/KVM for testing mouse emulation), or

gpm -m /dev/input/mice -t evdev

for some USB mice. Each mouse type has its own special features and buttons; for example

gpm -m /dev/input/mice -t help

shows a list of available drivers. Note that Gpm launches itself as a background process with (almost) no visible status or error messages. It logs its output to syslog, where you can read it using systemd's journalctl command, or

tail -f /var/log/messages

for SysVinit Linux distros. So, if Gpm fails, you will have to check the log to determine why. Often the error message simply tells to use the correct combination of -m /dev/mouse-device and -t driver.

Once you have Gpm running with the correct driver, you can select text with the left button and paste it with the middle mouse button or use a combination of left and right button as the middle mouse button replacement. Until you get the buttons and mouse movements to work correctly with the -t and -m arguments, it is useless trying to add the -S option.

To make sure no background Gpm process is still running, you can terminate Gpm by issuing gpm -k.

Now the -S option comes into play, allowing you to associate commands with special gestures. The short version of the online help may be a little misleading: The commands set with

gpm -m /dev/input/mice -t driver -S 'left_button_command:middle_button_command:right_button_command'

are NOT executed when simply pressing a button. You first have to activate "command mode" with a special gesture the man page calls "triple clicking the left and right mouse button," which you can accomplish by holding the left button down and tapping the right button three times. Doing so should produce a message on the console telling you to release all mouse buttons and start the associated actions by clicking on the desired button.

For example, enter:

gpm -m /dev/psaux -t ps2 -S "echo left:echo middle: echo right"

Now press and hold the left mouse button and then triple-click on the right button. Next, release all buttons and click the left, middle, or right mouse button just once. Depending on which button you clicked, the text left, middle, or right should appear. Similarly, the commands you sent in your question would be executed. Only commands that normally work on the text console can be executed successfully by Gpm button gestures. The startx command in your example will start the graphical desktop as root (i.e., the user running Gpm).

About your second question: Depending on your Linux distribution and init system, there are getty processes running on text consoles /dev/tty1 through /dev/tty10 that use the login command for authentication. A typical example for SysVinit is given in the init configuration file /etc/inittab:

1:2345:respawn:/sbin/getty 38400 tty1
2:2345:respawn:/sbin/getty 38400 tty2

Change this to:

1:2345:respawn:/bin/bash -login >/dev/tty1 </dev/tty1 2>&1
2:2345:respawn:/bin/su -l -c /bin/bash knopper >/dev/tty2 </dev/tty2 2>&1

In this example, the first line gives you a root shell on console 1, and the second line starts a shell for user knopper on console 2.

Gnome Commander Problem

Hi Klaus:

Thanks for your earlier help with mounting partitions.

I have been using Gnome Commander 1.2.8.17 in Linux Mint 17.2 Cinnamon 64 bit for some time, being spoiled with dual-screen filesystems for a long time on proprietary systems.

Double-clicking normally opens many file types, but recently my GCMD has stopped opening HTML and related file types. I may have also clobbered the same for some other file types. I have not located any folder or file that I can try to edit to repair my losses to file types, if any exist. Am I likely to guess correctly what to do if I find an editing point?

I have not been able to find any hints how to repair this. A right-click on the lost file type offers an Open or Open with entry to a fix, but there is no information on how to proceed to repair this feature. As I have many GCMD bookmarks set up, I hesitate to uninstall and reinstall to see if that restores all I had before I managed to kill my "open HTML file type" feature.

Further, what accidental mousing or other actions must I have done to wipe the open (HTML, etc.) file types? Also, will just upgrading to a later version repair my lost file-type opening features? What backups do I need to save my bookmarks and any other GCMD settings I may want to keep?

Also, what would be nice to have are links to where more GCMD guides or manuals may be found if any are available. Searching within forums seems a never-ending process of chasing unrelated tangents.

Thanks in advance for even considering to help.

Dee Shoolingin

The gnome-commander program apparently uses the standard mechanism defined for freedesktop.org-compatible desktop systems for associating file types (MIME types) to commands for "opening." You should find a configuration file in your home directory called .local/share/applications/defaults.list, which looks like this:

[Default Applications]
application/pdf=evince.desktop
application/zip=xarchiver.desktop
application/vnd.ms-excel=openoffice.org-calc.desktop
application/vnd.ms-powerpoint=openoffice.org-writer.desktop

The listed applications are referenced by their corresponding .desktop files, not by the actual command names. Those .desktop files are usually created during program installation by the package manager in the directory /usr/share/applications.

It may be that "opening HTML files" was associated with iceweasel.desktop, which has now become firefox.desktop, and the old entry is still present in defaults.list. You can edit the file with any text editor. A restart of Gnome Commander may be required for change notification.

See also the main documentation for Gnome Commander [1].

If you cannot find the .local directory in your file manager, make sure that "hidden" files and directories (those starting with a dot) are set to be visible.

Live Discs

Hello Klaus, Could you please tell me how to run Knoppix 7.7 without installing? I could not find instructions in the magazine or on the DVD. I expected a "Read Me" file or something. The two pages in the magazine did not mean much to me (only a beginner to Linux).

I have installed Mint from a burnt ISO disc without too much trouble.

Thanks, Henry Young

Your computer should be set to start from DVD, as for your "Mint" installation disk. Once started from DVD, Knoppix runs Live, including the desktop, and does not require a hard disk installation. However, you can install Knoppix to flash disk, which makes it run about five times faster.

If the Knoppix DVD is not bootable on your computer, please check the surface for visible scratches or defects. You may get a free replacement if the DVD included in the magazine was damaged for some reason.

Infos

  1. Gnome Commander docs: https://gcmd.github.io/doc.html

The Author

Klaus Knopper is an engineer, creator of Knoppix, and co-founder of LinuxTag expo. He works as a regular professor at the University of Applied Sciences, Kaiserslautern, Germany. If you have a configuration problem, or if you just want to learn more about how Linux works, send your questions to: mailto:klaus@linux-magazine.com

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

comments powered by Disqus

Direct Download

Read full article as PDF:

Price $2.95

News