From 2d67ba5cb5dcc3c0043d210136ee18dd42af4c08 Mon Sep 17 00:00:00 2001 From: XTRM-Unraid Date: Sun, 1 Feb 2026 11:46:24 +0200 Subject: [PATCH] Add KVM scripts for Mac/Nobara switching - to_mac.sh: Switch from Nobara to Mac (monitor USB-C, peripherals Ch3) - to_nobara.sh: Switch from Mac to Nobara (monitor HDMI2, peripherals Ch2) - README.md: Setup instructions for both machines Uses DDC/CI for monitor and HID++ for Logitech Bolt peripherals. --- scripts/kvm/README.md | 127 +++++++++++++++++++++++++++++++++++++++ scripts/kvm/to_mac.sh | 39 ++++++++++++ scripts/kvm/to_nobara.sh | 35 +++++++++++ 3 files changed, 201 insertions(+) create mode 100644 scripts/kvm/README.md create mode 100755 scripts/kvm/to_mac.sh create mode 100755 scripts/kvm/to_nobara.sh diff --git a/scripts/kvm/README.md b/scripts/kvm/README.md new file mode 100644 index 0000000..013c07d --- /dev/null +++ b/scripts/kvm/README.md @@ -0,0 +1,127 @@ +# KVM Switch: Mac ↔ Nobara + +Software KVM to switch Dell U3821DW monitor and Logitech MX peripherals between Mac and Nobara. + +## Hardware + +- **Monitor:** Dell U3821DW (USB-C to Mac, HDMI 2 to Nobara) +- **Keyboard:** Logitech MX Keys S +- **Mouse:** Logitech MX Master 3S +- **Bolt #1:** Connected directly to Nobara +- **Bolt #2:** Connected to Dell monitor USB hub (routes to Mac via USB-C) + +## Channel Setup + +| Channel | Code | Connection | Computer | +|---------|------|------------|----------| +| 2 | 0x01 | Bolt #1 | Nobara | +| 3 | 0x02 | Bolt #2 (via monitor) | Mac | + +## Mac Setup + +### Prerequisites +```bash +# Install m1ddc (DDC control for Apple Silicon) +brew install m1ddc + +# Install hidapitester +curl -sL https://github.com/todbot/hidapitester/releases/latest/download/hidapitester-macos-arm64.zip -o /tmp/hidapitester.zip +unzip -o /tmp/hidapitester.zip -d ~/bin/ +chmod +x ~/bin/hidapitester +``` + +### Install Script +```bash +mkdir -p ~/scripts +cp to_nobara.sh ~/scripts/ +chmod +x ~/scripts/to_nobara.sh +``` + +### Keyboard Shortcut (Logi Options+) +1. Logi Options+ → MX Keys S → Smart Actions +2. Create action triggered by F12 +3. Action: Open File → ~/scripts/to_nobara.sh + +## Nobara Setup + +### Prerequisites +```bash +# Install ddcutil +sudo dnf install -y ddcutil + +# Add user to i2c group (REBOOT REQUIRED) +sudo usermod -aG i2c $USER + +# Install hidapitester +mkdir -p ~/bin +curl -sL https://github.com/todbot/hidapitester/releases/latest/download/hidapitester-linux-amd64.zip -o /tmp/hidapitester.zip +unzip -o /tmp/hidapitester.zip -d ~/bin/ +chmod +x ~/bin/hidapitester +rm /tmp/hidapitester.zip + +# Udev rule for non-root HID access +echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="046d", ATTRS{idProduct}=="c548", MODE="0666"' | \ + sudo tee /etc/udev/rules.d/99-logitech-bolt.rules +sudo udevadm control --reload-rules && sudo udevadm trigger +``` + +### Install Script +```bash +mkdir -p ~/scripts +cp to_mac.sh ~/scripts/ +chmod +x ~/scripts/to_mac.sh +``` + +### Keyboard Shortcut (GNOME) +1. Settings → Keyboard → Custom Shortcuts +2. Add shortcut: + - Name: KVM to Mac + - Command: /home/USER/scripts/to_mac.sh + - Shortcut: F12 + +## Pairing Peripherals + +Each device must be paired to BOTH Bolt receivers: + +### MX Master 3S / MX Keys S +1. Press Easy-Switch button to select channel (2 for Nobara, 3 for Mac) +2. Hold 3 seconds until LED blinks fast +3. Use Logi Options+ (Mac) or Solaar (Linux) to complete pairing + +### Install Solaar (Linux) +```bash +sudo dnf install solaar +solaar & +# Click "Pair new device" while peripheral is blinking +``` + +## Troubleshooting + +### Monitor doesn't switch +- Check DDC/CI is enabled: Monitor Menu → Others → DDC/CI → On +- Mac: Ensure USB-C cable supports data (not video-only) +- Linux: Ensure user is in i2c group and rebooted + +### Peripherals don't switch +- Verify devices are paired to both Bolt receivers +- Check device indices with: `solaar show` (Linux) +- Device indices (0x01, 0x02) depend on pairing order + +### Find correct device indices +```bash +# On Linux with solaar +solaar show + +# Or query via HID++ +hidapitester --vidpid 046d/c548 --list-detail +``` + +## DDC Input Codes (Dell U3821DW) + +| Input | Code | +|-------|------| +| HDMI 1 | 17 | +| HDMI 2 | 18 | +| USB-C | 27 | +| DP 1 | 15 | +| DP 2 | 16 | diff --git a/scripts/kvm/to_mac.sh b/scripts/kvm/to_mac.sh new file mode 100755 index 0000000..146c126 --- /dev/null +++ b/scripts/kvm/to_mac.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# KVM Switch: Nobara → Mac +# Switches monitor to USB-C and peripherals to Channel 3 (Mac Bolt via monitor hub) +# +# Channel setup: +# Channel 2 (0x01): Bolt #1 → Nobara +# Channel 3 (0x02): Bolt #2 → Mac (via monitor USB hub) + +set -e + +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) +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" +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!" diff --git a/scripts/kvm/to_nobara.sh b/scripts/kvm/to_nobara.sh new file mode 100755 index 0000000..e87064c --- /dev/null +++ b/scripts/kvm/to_nobara.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# KVM Switch: Mac → Nobara +# Switches monitor to HDMI 2 and peripherals to Channel 2 (Nobara Bolt) +# +# Channel setup: +# Channel 2 (0x01): Bolt #1 → Nobara +# Channel 3 (0x02): Bolt #2 → Mac (via monitor USB hub) + +set -e + +HIDAPITESTER="$HOME/bin/hidapitester" + +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)" +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..." +"$HIDAPITESTER" --vidpid 046d/c548 --usage 0x0001 --usagePage 0xff00 \ + --open --length 7 --send-output 0x10,0x01,0x09,0x1b,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..." +"$HIDAPITESTER" --vidpid 046d/c548 --usage 0x0001 --usagePage 0xff00 \ + --open --length 7 --send-output 0x10,0x02,0x09,0x1b,0x01,0x00,0x00 2>/dev/null || \ + echo " [WARN] Keyboard switch failed" + +echo "Done!"