Asus Zenbook Duo (2024 / UX8406MA) & NixOS

Quick python script to enable the brightness control using keyboard for both displays. I wrote this in an hour. Currently hardcoded to 2 screens and device selection disabled. It works when keyboard is detached, i.e in bluetooth mode.

Next step is to attempt to allow brightness control when keyboard is attached, i can see the event for Fn key using hid-recorder, the trick is to disable the function keys when Fn + F5 is pressed and instead control the brightness.

Running on Fedora 40 under KDE Plasma 6 on X11 Kernel: 6.8.5-301.fc40.x86_64 (64-bit):

1 Like

This kernel patch fixes the rfkill keypress from being emitted when the Zenbook’s wireless keyboard is connected.

2 Likes

Hi @ultramarine,

Kinda noob here, so if something doesn’t makes sense, let me know.

Regarding

your linux-firmware package is tied to the kernel update on fedora?

It doesn’t seems to be that way, currently I’m using kernel 6.8.12-300 and the the linux-firmware is 20240811-2.fc40.
The latter was update much more recently (2024-08-19) than the kernel 6.8 I’m using with it (2024-07-04). Kernel 6.10.5 was installed on 2024-08-20

I do not have the packages needed to downgrade to a version of 202407 (did a quick web search and found there is one 20240709 for fedora 40, probably will try after work).


To check linux-firmware version and available packages I used:
dnf list --showduplicates linux-firmware

linux-firmware.noarch                                     20240811-2.fc40                                     @updates
Available Packages
linux-firmware.noarch                                     20240312-1.fc40                                     fedora  
linux-firmware.noarch                                     20240811-2.fc40                                     updates 

To get more data on my current linux-firmware version I used rpm -qi linux-firmware

Version     : 20240811
Release     : 2.fc40
Architecture: noarch
Install Date: lun 19 ago 2024 01:51:16
Group       : Unspecified
Size        : 39114245
License     : GPL+ and GPLv2+ and MIT and Redistributable, no modification permitted
Signature   : RSA/SHA256, vie 16 ago 2024 07:29:12, Key ID 0727707ea15b79cc
Source RPM  : linux-firmware-20240811-2.fc40.src.rpm
Build Date  : vie 16 ago 2024 06:44:41
Build Host  : buildvm-s390x-01.s390.fedoraproject.org
Packager    : Fedora Project
Vendor      : Fedora Project
URL         : http://www.kernel.org/
Bug URL     : https://bugz.fedoraproject.org/linux-firmware
Summary     : Firmware files used by the Linux kernel
Description :
This package includes firmware files required for some devices to
operate.

EDIT:

I couldn’t help myself and went for it. I tried installing:

  • intel-gpu-firmware-20240709-1.fc40.noarch.rpm
  • linux-firmware-20240709-1.fc40.noarch.rpm

from linux-firmware-20240709-1.fc40 | Build Info | koji
First I only the gpu-firmware, then with both. But I had no luck, 6.10.5 kernel is still not working for me (6.10.6 neither).
Guess I should try installing all the rpm files there (or use the .src one), but I have not much time to keep trying this right now. Will try later.

I personally used an utility called downgrade to revert only linux-firmware and I kept the rest up to date.
Just to add to the weird bugs and glitches that this dual setup is suffering for me at the moment:

  1. Using gnome 40 and wayland sometimes if I have the pointer on specific areas of the upper screen, namely the ones close to the dockbar, the lower screen weirdly shifts rapidly and horizontally like in a flicker.
  2. From the recent updates when I wake the system from sleep with the keyboard detached the touchpad is wrongly configured, specially scrolling with two fingers does not work. Attaching/detaching the keyboard solves the issue.

Did any of you experience one of these and maybe managed to fix?

Hi @ultramarine

I assume you meant Fedora 40 (gnome is actually through v46), so:

  1. The same weird horizontal movement happened to me until I disabled PSR. To fix it, open a terminal:

sudo nano /etc/default/grub

in grub, search for this line below and add i915.enable_psr=0 after the existing parameters, like this:

GRUB_CMDLINE_LINUX=“rhgb quiet i915.enable_psr=0”

Then Ctrl+X to exit and ensure to save the file

After modifying GRUB, update the config with this command:

sudo grub2-mkconfig -o /boot/grub2/grub.cfg

  1. I have the same behavior with the keyboard, but what is really annoying for me is that palm rejection is not working. Even if I have the option ‘Disable trackpad when typing’ enabled, when I’m typing, the slightest movement on the trackpad causes the cursor to go to another position, and is really a pain. Don’t know if anyone else is having this issue and has managed to fix it.

Lastly, I’ve managed to fix the touchscreen issues with asus pen (bottom screen redirecting to top) following those steps, just in case you’re interested in fixing this:

  1. Run alesya script with parameter set-tablet-mapping
  2. Open Gnome Settings and go to Wacom tablet settings.
  3. From there, change the monitor assignment for both screens to automatic, run the calibration in both screen and cancel it with Esc key.
  4. Enable and disable ‘Keep aspect ratio’
  5. Switch back from automatic to ‘Whole screens’ and then install dconf-editor if you haven’t already with sudo dnf install dconf-editor
  6. All this steps done from gnome parameters GUI will create some keys that will be visible if you run dconf-editor.

Keys are located in /org/gnome/desktop/peripherals/tablets/04f3:425a and b respectively. So you can modify the keys to have the following values for each monitor:

[04f3:425a]
area=[0.0, 0.0, -1.0, 0.0]
keep-aspect=false
mapping=‘absolute’
output=[‘SDC’, ‘0x419d’, ‘0x00000000’, ‘eDP-2’]

[04f3:425b]
area=[0.0, 0.0, 0.0, -1.0]
keep-aspect=false
mapping=‘absolute’
output=[‘SDC’, ‘0x419d’, ‘0x00000000’, ‘eDP-1’]

I’m afraid I’m a linux newbie and I haven’t managed to do this setup through an script, so I’ve fiddled with gnome gui to create the dconf keys, and then modifying them.

PD. This fixes touch with a stylus, but If I use fingers, the bottom screen still redirects to the top. Wonder if someone have fixed this as well. Anyway, at least for me, the biggest issue is the palm rejection not working.

Yeah I meant the latest gnome version. Thank you for the first tip, I’ll try today.
2. Yes palm rejection is not working also for me, enabling click only on touchpad physical press somewhat helps but still does not solve the issue. At least you don’t get random clicks.

Hi all, is anybody experiencing Emergency Mode on reboot? It looks like the error is related to initrd-switch-root.service Failure.



One issue that is driving me mad which I don’t know if it is device specific but I never had on previous gnome installations. Vscode which is the main program I use daily is also the only one displaying blurry, I added all the flags to make it run natively under wayland but with lo luck.
https://wiki.archlinux.org/title/Visual_Studio_Code#Running_natively_under_Wayland
I don’t know if it is screen related, driver related or something else entirely. The screens are set at 200% so it’s not even fractional scaling.

I am suddenly getting an issue where the 2nd monitor not only stops to be synchronized (with zenbook-duo), but the primary monitor is also stuck at 100%. Not sure if it was from an update, but I have blocked updates from the Linux-firmware package as it was causing issues.

I also noticed that when I run duo sync-backlight, it gets the brightness level from the directory in /sys/class and the intel_backlight and card1-eDP-2-backlight directories are not shown, there is only an asus_screenpad folder. Not sure what this means but maybe there was a change to a driver?

What updates did you apply when this occurred? I haven’t seen similar myself yet.

It didnt apply directly after any updates, and I dont remember updating anything major. Just thought I would post it to see if anyone else had the same issue.

A couple updates:

  • linux-firmware 20240909 has been released which doesn’t have the same secondary display problems.
  • However, coincidental with the firmware 20240909, I did get a mysterious third display registering on my system on first boot… but I’m not sure if this is going to be a persistent problem/confusion or not. I’ve disabled it for now and I’ll see if anything else weird occurs.
  • The patch for the wireless disconnecting after connecting the keyboard has been included in Linux 6.11, which should be released as a new stable kernel soon. However, I haven’t tested this kernel to see if any other issues come up.
1 Like

A new commit was submitted that allows you to control the keyboard brightness. Limitations:

  • works only when the keyboard is attached
  • does not work through the FN key, only through command line (or I don’t know how to map the FN key yet)
1 Like

Hi, thank you everyone for your efforts to get full support for this laptop working! I just purchased last week, and though I’m not using NixOS, I am hopeful all your hard work will end upstream for other distros to use as well.

So far, Devuan ‘daedalus’ with 6.9.x kernel appears to work reasonably well on this model, with the same issues originally reported in this discussion (no second screen, no sound; bluetooth controller is not found). (Devuan ‘daedalus’ default kernel which is < 6.9 doesn’t find wifi, due to an error in the firmware filenames expected, but upgrading to 6.9.x resolves that part at least).

Hey all!

I’ve been working on implementing screen rotation for my Asus Zenbook Duo and wanted to share the current progress. I had previously implemented a similar feature for my old laptop using a flake in this repo: xrandr-auto-rotate. While it’s partially functional on this machine, there are still a few issues to iron out, and I’m planning on making it fully operational when I get more time.

Here’s the current status:

  1. When only the top screen is in use, the rotation works as intended, but the mouse’s orientation follows the screen rotation, which is not the desired behavior.
  2. When both screens are in use and the laptop is rotated, the top monitor gets disabled while the bottom one rotates correctly. However, the mouse behavior remains incorrect in this scenario as well.

I’m accepting pull requests if anyone wants to help fix it in the meantime. Thanks to everyone for the great work being done on NixOS, and looking forward to any feedback or contributions!

Best,
nilp0inter

Thanks for the patch @mfenniak

There is a problem with this patch that on ASUS Zenbook Duo UX8406MA you can’t detect integrated keyboard attach/detach event anymore. It would be imho better to not to ignore the WMI code 0x5e but to change it to some meaninful code which can be later remapped (using asus_nb_wmi_keymap) to KEY_xy other then KEY_WLAN to not toggle wifi on/off.

In my setup (Fedora 40) I’m using systemd hwdb to remap 0x5e WMI key to KEY_CONFIG which is later used in Cinnamon desktop manager to trigger a script handling duo’s screens (GitHub - alesya-h/zenbook-duo-2024-ux8406ma-linux: automatic screen on/off, brightness sync, battery limiter).

/etc/udev/hwdb.d/61-asus-duo.hwdb:

evdev:input:b0019v0000p0000e0000-*
KEYBOARD_KEY_5e=config

As your patch is already in 6.10.12 kernel I have to revert it using dkms built asus_nb_wmi.ko module with your back deactivated in order to get keyboard events back :slight_smile:

The problem with that is (as far as I’m aware) the signal is the same for both attaching and detaching the keyboard. This means that this method cannot reliably indicate the state of the laptop.

IMHO it’d be cleaner to use the USB connection status instead. IIRC the device ID is different when using the POGO pins and the external Type-C port, so that won’t be an issue.

I’d love to get this working at a kernel level, so I’m not sure what’s easier to hook up to i915/DRM - either USB events or ASUS WMI could work there I guess, with that limitation in mind though.

@hacker1024

After looking into ACPI DSDT table I found a WMI device with devid 0x00050051 where you can find a status bit indicating the state of the keyboard. I’m using following bash function (added to duo script from GitHub - alesya-h/zenbook-duo-2024-ux8406ma-linux: automatic screen on/off, brightness sync, battery limiter) to test the state of the keyboard and it works 100% reliably:

kbd_connected() {
  echo "0x00050051" | suenv tee "/sys/kernel/debug/asus-nb-wmi/dev_id"
  [ "$(suenv cat '/sys/kernel/debug/asus-nb-wmi/dsts'|cut -d' ' -f3)" == "0x10000" ]
}
1 Like

regarding the detection of the keyboard state using usb dev id, in my case vendor/device id is the same for both pogo and usb connection, I can’t use those ids for detection (Fedora 40)

I had mapped the attach/detach signal to trigger duo set-displays, had been working OK for me when at least when no external display was present (still on kernel 6.8)