EDIT see my comment below which uses a much cleaner method that avoids the noisy multple udev events and doesn't require udev/eudev at all
This activates/de-activates the secondary display underneath the removeable keyboard properly. Note though that the keyboard is a composite unit and causes a whole train of udev events, rather than a single one, which means the desktop will flicker multiple times on each re-attachment of the keyboard :(. If anyone knows how to just run the scripts on the 'last' udev event, it would make for a cleaner experience. (XFCE sometimes crashes out on me due to the rapid xrandr reconfigs but it's mostly usable).
[/usr/local/bin/usb-0b05_1b2c-in]
#!/bin/bash
if [ "$(xrandr --listmonitors | wc -l)" -gt "2" ]; then
#logger -p user.info "=== KEYBOARD REPLACED ==="
xrandr --output eDP-2 --off
fi
[/usr/local/bin/usb-0b05_1b2c-in_udev]
#!/bin/bash
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
/usr/local/bin/usb-0b05_1b2c-in &
[/usr/local/bin/usb-0b05_1b2c-out]
#!/bin/bash
if [ "$(xrandr --listmonitors | wc -l)" -lt "3" ]; then
#logger -p user.info "=== KEYBOARD REMOVED ==="
xrandr --auto && xrandr --output eDP-2 --below eDP-1
fi
[/usr/local/bin/usb-0b05_1b2c-out_udev]
#!/bin/bash
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
/usr/local/bin/usb-0b05_1b2c-out &
[/etc/udev/rules.d/99-zbduo2024-kbd.rules]
ACTION=="add", ATTRS{idVendor}=="0b05", ATTRS{idProduct}=="1b2c", ENV{XAUTHORITY}="/home/username/.Xauthority", ENV{DISPLAY}=":0", OWNER="username", RUN+="/usr/local/bin/usb-0b05_1b2c-in_udev"
ACTION=="remove", ENV{ID_MODEL}="ASUS_Zenbook_Duo_Keyboard", RUN+="/usr/local/bin/usb-0b05_1b2c-out_udev"
Now, to get your laptop keyboard working when removed, in bluetooth mode, one must
- Ensure bluetooth-ctl is running and initiate 'pair' in Bluetooth by clicking 'Create pairing with this device' (key icon in the 'Blueman-Manager' window)
- Turn on bluetooth (switch on the left of the keyboard)
- Remove the keyboard
- Hold F10 for 4-5 seconds until its blue LED starts blinking rapidly (kbd in pairing mode)
- Watch your desktop notifications for the connection message with the BT challenge pin code (6 digits)
- type the challenge PIN code on the keyboard
- Now the keyboard should be paired.
... now if only I could get the sound device (Intel HD Audio) and brightness control working for both screens!