0

My setup has 2 computers, and I use a hardware USB switch to constantly switch (plug in) the keyboard between 1st and 2nd computer.

Often I start typing and realize the switch was set to the wrong computer (which can be a security issue if I'm prompted for a password, I start typing, and don't realize I'm typing my password in Telegram on the other computer in the open).

Is there some way I can have an icon in the KDE System Tray indicate that a particular USB keyboard is currently "plugged-in"? The System Tray has something like this for USB storage devices, but I haven't found anything to indicate the keyboard.

:~$ lsusb
Bus 001 Device 052: ID 17f6:2862 Unicomp, Inc. Aristides 2862

It's a regular Unicomp Model M, nothing fancy (no special driver). It is always plugged into the same USB port.

Running Debian 12 (stable) with KDE 5.27.5 (latest stable)

Thanks in advance!

  • P.S. the hardware solution wouldn't work; my desk is small and the USB switch is under the desk (not directly visible) – Nick Bailuc Aug 03 '23 at 07:51
  • First check whether the usb switch is actually disconnecting the keyboard when it switches. Some KVMs will keep the usb connection alive so that the target machines don't see the keyboard disappearing/re-appearing each time. Eg, do udevadm monitor and see if any events are seen when swiched out and back in again. – meuh Aug 03 '23 at 16:55
  • @meuh based on udevadm, seems its physical (they are physical switches not touch) if i put it in switch 2 and unplug or plug computer 1, udevadm output shows nothing And if i physically unplug keybnoard from the switch, it shows the same output as clicking the switch when the switch is in position 1 and i test in computer 1 (if that makes sense) so based on that command, i think its physical – Nick Bailuc Aug 06 '23 at 21:53
  • 1
    It seems adding items to the system tray in KDE is pretty difficult, as you need to program in JavaScript and/or XML using the provided API. If you look through the docs there is a section on "widgets", and even an example "Adding a widget to the System Tray" which might do something you want? It's easier to use an existing answer to change the wallpaper from the command line, eg to a solid red image, if no kbd. – meuh Aug 07 '23 at 13:12
  • @meuh what about the CPU & different sensors Usage monitors (i use those a lot on the panel). I'd prefer to make some kind of text-only sensor. Do you know if that'd be possible/easier? – Nick Bailuc Aug 08 '23 at 04:20
  • 1
    There is a kde store, mostly full of appearance themes, but there are many contributed extensions that provide a variety of interesting features. You might look down them to see if you can find one that fits your needs. For example, this ecowatt applet seems to show text in a different colour depending on a program script.py you can replace with your own, without needing to understand or change the QML applet itself. – meuh Aug 08 '23 at 07:48

1 Answers1

1

Use Barrier:
Perhaps I have a better solution for you, use barrier. It's a program that extends your mouse to multiple computers using network, so you don't need a USB switch. The experience is very seamless. Barrier is available for macos, windows and linux. So it's no problem if you want to use different operating systems in each computer.

Barrier is open-source and free. And it's available in debian repositories, so you can install it using apt.

Using udev and yad:
In the other hand, about your question. Yes, you can achieve this relatively easily with two things, udev and yad.

udev is a dynamic device manager that controls and handles hardware devices in the system. So you can use that to trigger a bash script that do the system notification. This link talks about that.

And yad is a program in which you can create graphic dialogs and notifications by command-line. This program is available in debian repositories. For example, to send a notification to the system, you would use the following command:

yad --notification --image=terminal &  

So, you would create a little script in sh that runs yad notification and set up the triggers for this script using udev.

Magenta
  • 15
  • Tried the barrier thing, couldnt get it to work (either computer 1 as server or 2) Tried launching with different ports, same thing, the client always says something like 'connecting'. THeres a startup warning of running wayland, definitely dont want to switch to xorg just to get this working (also not too confident for doing this over network) – Nick Bailuc Aug 20 '23 at 20:55
  • unfortunately if i just wanted a notification id probably use something like notify-send, but what I'm looking for is a system tray icon thats constantly there to display which comp the keyboard is connected to (or simply its presence) i would've assumed I could somehow turn the usb device into a sensor, and use one of KDE's many sensor programs like a regular text based sensor that shows true or false – Nick Bailuc Aug 20 '23 at 20:57
  • what i meant is KDE has great widgets that can be placed in the panel for hardware/software things, and I usually use the text based sensors – Nick Bailuc Aug 20 '23 at 20:58
  • @NickBailuc Jmmm...a solution would be make a little python script and execute it as a daemon when computer turns on. You can make the script with pyudev and wx python libraries. – Magenta Sep 01 '23 at 03:43