@Harry Huang
1) Can the input be switched thru a GPIO command (and not just ctrl-ctrl-x)?
The PC input can be switched via the GPIO webterm menu feature of PiKVM:
add the following to /etc/kvmd/override.yaml
kvmd:
gpio:
drivers:
switch_input_1:
type: cmd
cmd: [/usr/bin/bash, /etc/kvmd/scripts/switch_input.sh, 1]
switch_input_2:
type: cmd
cmd: [/usr/bin/bash, /etc/kvmd/scripts/switch_input.sh, 2]
switch_input_3:
type: cmd
cmd: [/usr/bin/bash, /etc/kvmd/scripts/switch_input.sh, 3]
switch_input_4:
type: cmd
cmd: [/usr/bin/bash, /etc/kvmd/scripts/switch_input.sh, 4]
scheme:
switch_input_1_button:
driver: switch_input_1
mode: output
switch: false
switch_input_2_button:
driver: switch_input_2
mode: output
switch: false
switch_input_3_button:
driver: switch_input_3
mode: output
switch: false
switch_input_4_button:
driver: switch_input_4
mode: output
switch: false
view:
header:
title: PC Input
table:
- ["#PC Input"]
- ["switch_input_1_button|input 1"]
- ["switch_input_2_button|input 2"]
- ["switch_input_3_button|input 3"]
- ["switch_input_4_button|input 4"]
and create /etc/kvmd/scripts/switch_input.sh
#!/bin/bash
# Check for a valid argument (1, 2, 3, or 4)
if [ "$#" -ne 1 ] || ! [[ "$1" =~ ^[1-4]$ ]]; then
echo "Usage: $0 [1, 2, 3, or 4]"
exit 1
fi
# Define the USB keyboard codes for 1, 2, 3, and 4
usb_codes=("1e" "1f" "20" "21")
# Send two Ctrl key presses
echo -ne "\x1\0\0\0\0\0\0\0" > /dev/kvmd-hid-keyboard
echo -ne "\0\0\0\0\0\0\0\0" > /dev/kvmd-hid-keyboard
echo -ne "\x1\0\0\0\0\0\0\0" > /dev/kvmd-hid-keyboard
echo -ne "\0\0\0\0\0\0\0\0" > /dev/kvmd-hid-keyboard
# Send the USB keyboard code corresponding to the argument value
usb_code="${usb_codes[$1 - 1]}"
echo -ne "\0\0\x$usb_code\0\0\0\0\0" > /dev/kvmd-hid-keyboard
echo -ne "\0\0\0\0\0\0\0\0" > /dev/kvmd-hid-keyboard
I have been meaning to read this and just never obtained a chance. It’s an issue that I’m really interested in, I just started reading and I’m glad I did. You’re a fantastic blogger, one of the best that I’ve seen. This weblog undoubtedly has some facts Angels 2023 Ed Schmitt Jacket on a topic that I just wasn’t aware of. Thanks for bringing this stuff to light.