LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 07-02-2022, 04:31 PM   #1
dracolich
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 1,274

Rep: Reputation: 63
Fluxbox USB keyboard stops responding after disconnect/reconnect


Hello, LQ. This has been a minor annoyance for a long time. I have searched several times here and using Google and haven't found an answer.

I have multiple computers connected to my monitor on its various inputs, and to share the same keyboard with them I use a 4-port USB switch like this. Switching works fine but when using Fluxbox on this computer and after having switched from/back to it the keyboard works for one keystroke then stops until X is xlosed.

Example: Computer #1 is on button A of the switch and HDMI1 of the monitor. I'm working in an xterm window in Fluxbox, then switch to computer #2 on HDMI2 and push button B to switch the keyboard to it. Few minutes later I return to computer #1 and push button A to return the keyboard and mouse to computer #1. I begin to type something into xterm, and the first letter appears then stops responding - and it does not respond in any other app including the hotkey for the menu and Ctrl+Alt+BkSpc to close X. I have to use the mouse to open the menu and choose Exit to return to the console where the keyboard works again.

The mouse is not connected to the switch as it only takes one input and the other computers don't need a mouse. The keyboard has backlit keys and when it stops responding the backlight is still on; and the caps lock, num lock, and scroll lock keys still toggle their indicators.

As a test I have taken the keyboard off of the switch and plugged it directly into the computer. I then started Fluxbox, unplugged the keyboard, reconnected it, and the same behavior happens. I then tried it on different USB ports and get the same thing. Then I tried a different keyboard without backlight and get the same thing. The mouse does not exibit this behavior.

As another test I tried KDE and XFCE and it does not happen in those DEs. Also, if X is not started it does not happen. Also also, if I boot this computer into Windows it does not happen.
 
Old 07-03-2022, 09:28 AM   #2
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,137
Blog Entries: 6

Rep: Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826
Couple of thoughts. Since no one else has answered.

Rescan usb bus for devices on event, make a rule for it of some kind. udev, systemd

https://www.linuxquestions.org/quest...evices-754916/
https://michlstechblog.info/blog/lin...es-of-devices/

People have written code for that.

Example, not tried, just an example:
Code:
#include <stdio.h>
#include <usb.h>

int main(void)
{
    struct usb_bus *busses;
    usb_init();
    usb_find_busses();
    usb_find_devices();
    busses = usb_get_busses();
    struct usb_bus *bus;
    int c, i, a;

    for (bus = busses; bus; bus = bus->next) {
        struct usb_device *dev;
        int val;
        usb_dev_handle *junk;
        for (dev = bus->devices; dev; dev = dev->next) {
            char buf[1024];
            junk = usb_open ( dev );
            usb_get_string_simple(junk,2,buf,1023);
            if ( junk == NULL ){
                printf("Can't open %p (%s)\n", dev, buf );
            } else {
                val = usb_reset(junk);
                printf( "reset %p %d (%s)\n", dev, val, buf );
            }
            usb_close(junk);
        }
    }
}

//gcc -lusb resetusb.c -o resetusb
Another Example:

usbreset.c
Code:
/* usbreset -- send a USB port reset to a USB device */

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>

#include <linux/usbdevice_fs.h>

int main(int argc, char **argv)
{
	const char *filename;
	int fd;
	int rc;

	if (argc != 2) {
		fprintf(stderr, "Usage: usbreset device-filename\n");
		return 1;
	}
	filename = argv[1];

	fd = open(filename, O_WRONLY);
	if (fd < 0) {
		perror("Error opening output file");
		return 1;
	}

	printf("Resetting USB device %s\n", filename);
	rc = ioctl(fd, USBDEVFS_RESET, 0);
	if (rc < 0) {
		perror("Error in ioctl");
		return 1;
	}
	printf("Reset successful\n");

	close(fd);
	return 0;
}
Code:
lsusb
Bus 003 Device 022: ID 18a5:0304 Samsung, #Made up
usbreset /dev/bus/usb/003/022

Last edited by teckk; 07-03-2022 at 09:29 AM.
 
Old 07-03-2022, 09:50 AM   #3
dracolich
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 1,274

Original Poster
Rep: Reputation: 63
Thanks for the replay and the idea. I'll try it later if nobody else chimes in.

I just remembered another detail. I first noticed this behavior 5-6 years ago when I was using a Trendnet KVM with VGA monitor connectors and separate USB inputs for mouse and keyboard. During that time the keyboard did this same thing after switching between computers, but the mouse was unaffected. That began not long after Slackware 14.2's release and while using 4.4.x kernels, then 4.10.x, and more recently the 5.4.x and 5.10.x
 
Old 07-03-2022, 07:57 PM   #4
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,324
Blog Entries: 28

Rep: Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142Reputation: 6142
Quote:
I first noticed this behavior 5-6 years ago when I was using a Trendnet KVM
I've used a KVM for years. Although I'm not running Slackware on bare metal at the moment (I do have a VM), I did not have any such problem with Slackware under Fluxbox. Currently, the two computers connected to the KVM are running Magiea and Ubuntu MATE with Fluxbox. Again, no issues.
 
Old 07-04-2022, 02:16 AM   #5
allend
LQ 5k Club
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware64-15.0
Posts: 6,371

Rep: Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750Reputation: 2750
If it works in KDE and XFCE, but not in Fluxbox, perhaps you need a DBUS notification service running in Fluxbox.
As a test, you could try starting a background instance of xfce4-notifyd from a terminal in Fluxbox with
Code:
/usr/lib64/xfce4/notifyd/xfce4-notifyd &
and then try the switching.
 
Old 07-06-2022, 09:53 AM   #6
dracolich
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 1,274

Original Poster
Rep: Reputation: 63
allend, I think that is working. I launched nm-applet wifi manager which loads some background dbus stuff including notifyd. Then I switched to-and-from a few times without a problem. But I think I will try it a few more times before I am fully convinced.

frankbell, does your Fluxbox have similar background services running?
 
Old 07-06-2022, 11:55 AM   #7
coralfang
Member
 
Registered: Nov 2010
Location: Bristol, UK
Distribution: Slackware, FreeBSD
Posts: 836
Blog Entries: 3

Rep: Reputation: 297Reputation: 297Reputation: 297
If the issue is related to dbus, edit;
/etc/X11/xinit/xinitrc.fluxbox

Code:
# Start the window manager:
if [ -z "$DESKTOP_SESSION" -a -x /usr/bin/ck-launch-session ]; then
  exec ck-launch-session /usr/bin/startfluxbox
else
  #exec /usr/bin/startfluxbox
  exec dbus-launch /usr/bin/startfluxbox
fi
inserting dbus-launch at the end there ^
 
1 members found this post helpful.
Old 07-07-2022, 07:20 AM   #8
dracolich
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 1,274

Original Poster
Rep: Reputation: 63
Ok, I did a few more tests. First I launched Fluxbox again with almost all of my startup apps disabled - only fbsetbg and gkrellm left. After startx I launched the mrxvt terminal and checked ps x
Code:
PID TTY      STAT   TIME COMMAND
 1482 tty1     Ss     0:00 -bash
 1785 pts/0    Ss+    0:00 bash
 2298 tty1     S+     0:00 /bin/sh /usr/bin/startx -- -dpi 92
 2322 tty1     S+     0:00 xinit /home/daniel/.xinitrc -- /usr/bin/X :0 -dpi 92
 2330 tty1     S      0:00 /usr/X11R6/bin/fluxbox -log /home/daniel/.fluxbox/log
 2365 tty1     S      0:00 dbus-launch --autolaunch 075a63d514a3e4aefc064fc45d3d
 2366 ?        Ss     0:00 /usr/bin/dbus-daemon --syslog-only --fork --print-pid
 2368 ?        Sl     0:00 /usr/libexec/at-spi-bus-launcher
 2373 ?        S      0:00 /usr/bin/dbus-daemon --config-file=/etc/at-spi2/acces
 2408 tty1     Sl     0:00 cdemu-daemon
 2409 tty1     S      0:00 gkrellm -w
 2410 tty1     S      0:00 volumeicon
 2455 ?        Sl     0:00 /usr/libexec/at-spi2-registryd --use-gnome-session
 2487 ?        Rs     0:00 mrxvt
 2488 pts/1    Ss     0:00 bash
So a dbus daemon is launching with Fluxbox. I did the switch thing and the keyboard stopped again.

Then I exited X and re-enabled my other startup items - 3ddeskd, nm-applet and gcdemu. Again I opened mrxvt to check ps x
Code:
 PID TTY      STAT   TIME COMMAND
 1482 tty1     Ss     0:00 -bash
 1785 pts/0    Ss+    0:00 bash
 3577 tty1     S+     0:00 /bin/sh /usr/bin/startx -- -dpi 92
 3601 tty1     S+     0:00 xinit /home/daniel/.xinitrc -- /usr/bin/X :0 -dpi 92
 3609 tty1     S      0:00 /usr/X11R6/bin/fluxbox -log /home/daniel/.fluxbox/log
 3644 tty1     S      0:00 dbus-launch --autolaunch 075a63d514a3e4aefc064fc45d3d
 3645 ?        Ss     0:00 /usr/bin/dbus-daemon --syslog-only --fork --print-pid
 3647 ?        Sl     0:00 /usr/libexec/at-spi-bus-launcher
 3652 ?        S      0:00 /usr/bin/dbus-daemon --config-file=/etc/at-spi2/acces
 3687 tty1     Sl     0:00 cdemu-daemon
 3688 tty1     Sl     0:00 nm-applet
 3689 tty1     S      0:00 gkrellm -w
 3690 tty1     S      0:00 volumeicon
 3691 tty1     Sl     0:00 python3 /usr/bin/gcdemu
 3745 ?        Sl     0:00 /usr/libexec/at-spi2-registryd --use-gnome-session
 3785 ?        S      0:00 /usr/bin/dbus-daemon --syslog-only --fork --print-pid
 3788 ?        Sl     0:00 /usr/bin/plasma_waitforname org.freedesktop.Notificat
 3794 ?        Sl     0:00 /usr/libexec/xdg-desktop-portal
 3799 ?        Sl     0:00 /usr/libexec/xdg-document-portal
 3803 ?        Sl     0:00 /usr/libexec/xdg-permission-store
 3818 ?        Sl     0:00 /usr/lib64/libexec/xdg-desktop-portal-kde
 3824 ?        Sl     0:00 /usr/bin/gnome-keyring-daemon --start --foreground --
 3854 ?        Rs     0:00 mrxvt
 3855 pts/1    Ss     0:00 bash
As part of XFCE nm-applet triggers a plasma process, gnome-keyring-daemon and some xdg services. I switched the keyboard and it stopped again.

Now I thought about what is different from the day before yesterday and in the past when using KDE. In KDE I mostly used its konsole, and in XFCE I mostly use xfce4-terminal. Recently I discovered xfce4-terminal's dropdown feature and added it to my Fluxbox menu. When I tried allend's dbus idea I was using xfce4-terminal.

So, I exited X and started again, this time opening urxvt. The keyboard didn't stop.
Tried again with xterm and xfce4-terminal. The keyboard didn't stop.

So it seems to be caused by mrxvt. Bummer, because it has been a favorite terminal of mine for many years, even this long after development was abandoned. I guess it's time to say goodbye to it

Thanks for the help, guys

Last edited by dracolich; 07-07-2022 at 07:22 AM.
 
Old 07-07-2022, 09:18 AM   #9
jmccue
Member
 
Registered: Nov 2008
Location: US
Distribution: slackware
Posts: 688
Blog Entries: 1

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
coralfang -

Thanks, I was messing around with this but did not think of what you found.

But FWIW, in my testing I found the issue also occurring with fvwm2.

The interesting thing is, so far, the issue did not strike fvwm3, ctwm, vtwm and cwm. I was trying different window managers to see if a pattern occurred.

I was thinking it was a elogind issue when using xdm(1), but was not sure how to test for that. Your post makes a lot of sense.

John
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
disconnect and reconnect wireless after ubuntu 11 update. taste Linux - Newbie 2 08-29-2011 07:22 AM
No network packets sent immediately after quick physical disconnect and reconnect miracles Linux - Newbie 10 03-09-2011 11:48 PM
USB Keybooard/Mouse disconnect/reconnect issue (Genius TwinTouch Optical Office) 2Pacalypse Linux - Hardware 0 09-22-2007 05:06 AM
Mount / unmount / ejecting CD/DVD makes LAN disconnect & reconnect...! GrapefruiTgirl Slackware 9 03-06-2007 10:48 PM
Laptop keyboard stops responding after usb mouse installed koloth Slackware 2 07-11-2005 07:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 12:17 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration