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

  1. Ensure bluetooth-ctl is running and initiate ‘pair’ in Bluetooth by clicking ‘Create pairing with this device’ (key icon in the ‘Blueman-Manager’ window)
  2. Turn on bluetooth (switch on the left of the keyboard)
  3. Remove the keyboard
  4. Hold F10 for 4-5 seconds until its blue LED starts blinking rapidly (kbd in pairing mode)
  5. Watch your desktop notifications for the connection message with the BT challenge pin code (6 digits)
  6. type the challenge PIN code on the keyboard
  7. 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!

  • ArghblargOP
    link
    fedilink
    arrow-up
    1
    ·
    2 days ago

    Keyboard media keys (Fn + F keys, eg. vol mute, +/-, brightness etc.) do NOT yet work in mainline kernel. There is some good work going on over here on github but it’s preliminary.

    Also note kernel 6.10 broke the bottom display it would appear; I’m using kernel 6.13-rc4 currently.

  • ArghblargOP
    link
    fedilink
    arrow-up
    1
    ·
    edit-2
    2 days ago

    NEW METHOD which avoids the udev ‘event storm’ caused by docking/undocking the keyboard


    [/usr/local/bin/asusUX8406_kbdwatch]

    #!/bin/bash
    
    me=$(basename "$0")
    laststate=2
    
    while true; do
      sleep 3
      output=$(lsusb -d 0b05:1b2c)
      stat=$?
      if [ $stat == 1 ] && [ $laststate != 1 ]; then
        ## kbd removed, enable lower display
        laststate=1
        logger -p user.info "${me} KEYBOARD REMOVED"
        xrandr --auto && xrandr --output eDP-2 --below eDP-1
      elif [ $stat == 0 ] && [ $laststate != 0 ]; then
        ## kbd replaced, disable lower display
        laststate=0
        logger -p user.info "${me} KEYBOARD DOCKED"
        xrandr --output eDP-2 --off
      fi
    done
    

    Hook this up to your init system, or run from a nohup session redirected to /dev/null on login or session startup … for example, on my system I am member of group video, so installing it to /usr/local/bin and setting ownership to root:video and sudo chmod ug+rx allows it to be run on session login automatically.