Fix KVM switch: working Nobara → Mac with correct HID++ commands
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

- Discovered correct HID++ feature indices per device
- Updated to_mac.sh with working hidapitester commands
- Updated docs with complete setup instructions
- Mac → Nobara direction still needs work (TODO)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Kaloyan Danchev
2026-02-01 13:38:17 +02:00
parent 2d67ba5cb5
commit 2a3bdb9934
3 changed files with 233 additions and 148 deletions

View File

@@ -1,39 +1,39 @@
#!/bin/bash
# KVM Switch: Nobara → Mac
# Switches monitor to USB-C and peripherals to Channel 3 (Mac Bolt via monitor hub)
# Switches monitor to USB-C and peripherals to Host 3 (Mac)
#
# Channel setup:
# Channel 2 (0x01): Bolt #1 → Nobara
# Channel 3 (0x02): Bolt #2 → Mac (via monitor USB hub)
set -e
# Host mapping (0-indexed in HID++):
# Host 1 (0x01): Nobara (xtrm-pc)
# Host 3 (0x02): Mac (Kaloyan's MacBook Air)
#
# HID++ command format: ReportID, DeviceIdx, FeatureIdx, Function, HostIdx, 0, 0
# Mouse: device 0x03, feature 0x0E (CHANGE_HOST)
# Keyboard: device 0x02, feature 0x0A (CHANGE_HOST)
# Function 0x10 = setCurrentHost (function 0 << 4)
HIDAPITESTER="$HOME/bin/hidapitester"
[ -x "$HIDAPITESTER" ] || HIDAPITESTER="/usr/local/bin/hidapitester"
echo "Switching to Mac..."
# 1. Switch Monitor to USB-C (Dell U3821DW input code: 27)
# 1. Switch Mouse (MX Master 4) to Host 3 (Mac)
echo " Mouse -> Mac..."
"$HIDAPITESTER" --vidpid 046d/c548 --usage 0x0001 --usagePage 0xff00 \
--open --length 7 --send-output 0x10,0x03,0x0E,0x10,0x02,0x00,0x00 2>/dev/null || \
echo " [WARN] Mouse switch failed"
# 2. Switch Keyboard (MX Keys S) to Host 3 (Mac)
echo " Keyboard -> Mac..."
"$HIDAPITESTER" --vidpid 046d/c548 --usage 0x0001 --usagePage 0xff00 \
--open --length 7 --send-output 0x10,0x02,0x0A,0x10,0x02,0x00,0x00 2>/dev/null || \
echo " [WARN] Keyboard switch failed"
# 3. Switch Monitor to USB-C (Dell U3821DW input code: 27)
echo " Monitor -> USB-C..."
if command -v ddcutil &>/dev/null; then
ddcutil setvcp 60 27 2>/dev/null || \
echo " [WARN] Monitor switch failed (DDC/CI disabled or permissions issue)"
else
echo " [WARN] ddcutil not installed: sudo dnf install ddcutil"
echo " [WARN] ddcutil not installed"
fi
# 2. Switch Mouse (MX Master 3S) to Channel 3 (Mac Bolt)
# Device index 0x01 - adjust if mouse was paired in different order
echo " Mouse -> Channel 3..."
"$HIDAPITESTER" --vidpid 046d/c548 --usage 0x0001 --usagePage 0xff00 \
--open --length 7 --send-output 0x10,0x01,0x09,0x1b,0x02,0x00,0x00 2>/dev/null || \
echo " [WARN] Mouse switch failed"
# 3. Switch Keyboard (MX Keys S) to Channel 3 (Mac Bolt)
# Device index 0x02 - adjust if keyboard was paired in different order
echo " Keyboard -> Channel 3..."
"$HIDAPITESTER" --vidpid 046d/c548 --usage 0x0001 --usagePage 0xff00 \
--open --length 7 --send-output 0x10,0x02,0x09,0x1b,0x02,0x00,0x00 2>/dev/null || \
echo " [WARN] Keyboard switch failed"
echo "Done!"

View File

@@ -1,12 +1,16 @@
#!/bin/bash
# KVM Switch: Mac → Nobara
# Switches monitor to HDMI 2 and peripherals to Channel 2 (Nobara Bolt)
# STATUS: NEEDS WORK - HID++ feature indices need to be discovered on Mac
#
# Channel setup:
# Channel 2 (0x01): Bolt #1 → Nobara
# Channel 3 (0x02): Bolt #2 → Mac (via monitor USB hub)
set -e
# Host mapping (0-indexed in HID++):
# Host 2 (0x01): Nobara (xtrm-pc)
# Host 3 (0x02): Mac (Kaloyan's MacBook Air)
#
# TODO: Find correct HID++ feature indices on Mac's Bolt receiver
# The feature indices discovered on Nobara were:
# Mouse (device 0x03): feature 0x0E
# Keyboard (device 0x02): feature 0x0A
# These may differ on Mac - need to verify with hidapitester or similar tool
HIDAPITESTER="$HOME/bin/hidapitester"
@@ -14,22 +18,25 @@ echo "Switching to Nobara..."
# 1. Switch Monitor to HDMI 2 (Dell U3821DW input code: 18)
echo " Monitor -> HDMI 2..."
if ! m1ddc set input 18 2>/dev/null; then
echo " [WARN] Monitor switch failed (DDC/CI disabled or not connected via USB-C)"
if command -v m1ddc &>/dev/null; then
m1ddc set input 18 2>/dev/null || \
echo " [WARN] Monitor switch failed (DDC/CI disabled or not connected via USB-C)"
else
echo " [WARN] m1ddc not installed: brew install m1ddc"
fi
# 2. Switch Mouse (MX Master 3S) to Channel 2 (Nobara Bolt)
# Device index 0x01 - adjust if mouse was paired in different order
echo " Mouse -> Channel 2..."
# 2. Switch Mouse (MX Master 4) to Host 2 (Nobara)
# TODO: Verify device index and feature index on Mac
echo " Mouse -> Nobara..."
"$HIDAPITESTER" --vidpid 046d/c548 --usage 0x0001 --usagePage 0xff00 \
--open --length 7 --send-output 0x10,0x01,0x09,0x1b,0x01,0x00,0x00 2>/dev/null || \
--open --length 7 --send-output 0x10,0x03,0x0E,0x10,0x01,0x00,0x00 2>/dev/null || \
echo " [WARN] Mouse switch failed"
# 3. Switch Keyboard (MX Keys S) to Channel 2 (Nobara Bolt)
# Device index 0x02 - adjust if keyboard was paired in different order
echo " Keyboard -> Channel 2..."
# 3. Switch Keyboard (MX Keys S) to Host 2 (Nobara)
# TODO: Verify device index and feature index on Mac
echo " Keyboard -> Nobara..."
"$HIDAPITESTER" --vidpid 046d/c548 --usage 0x0001 --usagePage 0xff00 \
--open --length 7 --send-output 0x10,0x02,0x09,0x1b,0x01,0x00,0x00 2>/dev/null || \
--open --length 7 --send-output 0x10,0x02,0x0A,0x10,0x01,0x00,0x00 2>/dev/null || \
echo " [WARN] Keyboard switch failed"
echo "Done!"