Files
infrastructure/scripts/kvm/to_mac.sh

39 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
# KVM Switch: Nobara → Mac
# Switches monitor to USB-C and peripherals to Host 3 (Mac)
#
# Device mapping:
# Keyboard: device 0x02, feature 0x0A
# Mouse: device 0x03, feature 0x0E
#
# Host mapping:
# Host 2 (0x01): Nobara
# Host 3 (0x02): Mac
HIDAPITESTER="$HOME/bin/hidapitester"
echo "Switching to Mac..."
# 1. Switch Mouse 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 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
echo " Monitor -> USB-C..."
if command -v ddcutil &>/dev/null; then
ddcutil setvcp 60 27 2>/dev/null || \
echo " [WARN] Monitor switch failed"
else
echo " [WARN] ddcutil not installed"
fi
echo "Done!"