this post was submitted on 04 Jan 2025
18 points (100.0% liked)

Linux

48867 readers
1009 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 5 years ago
MODERATORS
 

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!

top 2 comments
sorted by: hot top controversial new old
[–] Arghblarg@lemmy.ca 1 points 1 day 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.

[–] Arghblarg@lemmy.ca 1 points 2 days ago* (last edited 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.