Simplify KVM scripts - monitor only, manual peripheral switch
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
2026-02-01 16:42:04 +02:00
parent 2a3bdb9934
commit 663542ff17
3 changed files with 41 additions and 147 deletions

View File

@@ -1,127 +1,82 @@
# KVM Switch: Mac ↔ Nobara # KVM Switch: Mac ↔ Nobara
Software KVM to switch Dell U3821DW monitor and Logitech MX peripherals between Mac and Nobara. Simple monitor switching via DDC/CI. Peripherals switched manually via Easy-Switch button.
## Hardware ## Hardware
- **Monitor:** Dell U3821DW (USB-C to Mac, HDMI 2 to Nobara) - **Monitor:** Dell U3821DW (USB-C to Mac, HDMI 2 to Nobara)
- **Keyboard:** Logitech MX Keys S - **Keyboard:** Logitech MX Keys S
- **Mouse:** Logitech MX Master 3S - **Mouse:** Logitech MX Master 4
- **Bolt #1:** Connected directly to Nobara - **Bolt #1:** Connected to Nobara (Channel 2)
- **Bolt #2:** Connected to Dell monitor USB hub (routes to Mac via USB-C) - **Bolt #2:** Connected to Mac via monitor USB hub (Channel 3)
## Channel Setup ## Channel Setup
| Channel | Code | Connection | Computer | | Channel | Connection | Computer |
|---------|------|------------|----------| |---------|------------|----------|
| 2 | 0x01 | Bolt #1 | Nobara | | 2 | Bolt #1 | Nobara |
| 3 | 0x02 | Bolt #2 (via monitor) | Mac | | 3 | Bolt #2 | Mac |
## Mac Setup ## Mac Setup
### Prerequisites ### Install m1ddc
```bash ```bash
# Install m1ddc (DDC control for Apple Silicon)
brew install m1ddc 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 ### Copy script
```bash ```bash
mkdir -p ~/scripts mkdir -p ~/scripts
cp to_nobara.sh ~/scripts/ cp to_nobara.sh ~/scripts/
chmod +x ~/scripts/to_nobara.sh chmod +x ~/scripts/to_nobara.sh
``` ```
### Keyboard Shortcut (Logi Options+) ### Usage
1. Logi Options+ → MX Keys S → Smart Actions ```bash
2. Create action triggered by F12 ~/scripts/to_nobara.sh
3. Action: Open File → ~/scripts/to_nobara.sh # Then press Easy-Switch on keyboard/mouse to Channel 2
```
## Nobara Setup ## Nobara Setup
### Prerequisites ### Install ddcutil
```bash ```bash
# Install ddcutil sudo dnf install ddcutil
sudo dnf install -y ddcutil
# Add user to i2c group (REBOOT REQUIRED)
sudo usermod -aG i2c $USER sudo usermod -aG i2c $USER
# Reboot required
# 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 ### Copy script
```bash ```bash
mkdir -p ~/scripts mkdir -p ~/scripts
cp to_mac.sh ~/scripts/ cp to_mac.sh ~/scripts/
chmod +x ~/scripts/to_mac.sh chmod +x ~/scripts/to_mac.sh
``` ```
### Keyboard Shortcut (GNOME) ### Set 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 ```bash
sudo dnf install solaar # Add custom shortcut for Ctrl+Shift+Up
solaar & gsettings set org.gnome.settings-daemon.plugins.media-keys custom-keybindings "['/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/kvm/']"
# Click "Pair new device" while peripheral is blinking gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/kvm/ name 'KVM to Mac'
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/kvm/ command '/home/$USER/scripts/to_mac.sh'
gsettings set org.gnome.settings-daemon.plugins.media-keys.custom-keybinding:/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/kvm/ binding '<Shift><Control>Up'
``` ```
## Troubleshooting ### Usage
### 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 ```bash
# On Linux with solaar ~/scripts/to_mac.sh
solaar show # Then press Easy-Switch on keyboard/mouse to Channel 3
# Or query via HID++
hidapitester --vidpid 046d/c548 --list-detail
``` ```
## DDC Input Codes (Dell U3821DW) ## DDC Input Codes (Dell U3821DW)
| Input | Code | | Input | Code |
|-------|------| |-------|------|
| HDMI 1 | 17 |
| HDMI 2 | 18 | | HDMI 2 | 18 |
| USB-C | 27 | | USB-C | 27 |
| DP 1 | 15 |
| DP 2 | 16 | ## Troubleshooting
### Monitor doesn't switch
- Enable DDC/CI: Monitor Menu → Others → DDC/CI → On
- Linux: Ensure user in i2c group, reboot after adding

View File

@@ -1,39 +1,12 @@
#!/bin/bash #!/bin/bash
# KVM Switch: Nobara → Mac # KVM Switch: Nobara → Mac
# Switches monitor to USB-C and peripherals to Host 3 (Mac) # Switches monitor to USB-C
# # Peripherals: manually press Easy-Switch to Channel 3
# 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"
echo "Switching to Mac..." echo "Switching to Mac..."
# 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..." echo " Monitor -> USB-C..."
if command -v ddcutil &>/dev/null; then if command -v ddcutil &>/dev/null; then
ddcutil setvcp 60 27 2>/dev/null || \ ddcutil setvcp 60 27 2>/dev/null && echo "Done! Press Easy-Switch for Channel 3" || echo "Monitor switch failed"
echo " [WARN] Monitor switch failed (DDC/CI disabled or permissions issue)"
else else
echo " [WARN] ddcutil not installed" echo "ddcutil not installed: sudo dnf install ddcutil"
fi fi
echo "Done!"

View File

@@ -1,42 +1,8 @@
#!/bin/bash #!/bin/bash
# KVM Switch: Mac → Nobara # KVM Switch: Mac → Nobara
# STATUS: NEEDS WORK - HID++ feature indices need to be discovered on Mac # Switches monitor to HDMI 2
# # Peripherals: manually press Easy-Switch to Channel 2
# 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"
echo "Switching to Nobara..." echo "Switching to Nobara..."
# 1. Switch Monitor to HDMI 2 (Dell U3821DW input code: 18)
echo " Monitor -> HDMI 2..." echo " Monitor -> HDMI 2..."
if command -v m1ddc &>/dev/null; then m1ddc set input 18 2>/dev/null && echo "Done! Press Easy-Switch for Channel 2" || echo "Monitor switch failed"
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 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,0x03,0x0E,0x10,0x01,0x00,0x00 2>/dev/null || \
echo " [WARN] Mouse switch failed"
# 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,0x0A,0x10,0x01,0x00,0x00 2>/dev/null || \
echo " [WARN] Keyboard switch failed"
echo "Done!"