Wayland support

Hi, is anyone running the agent on Wayland?

I’m getting this error trying to run it in Arch: Missing X server or $DISPLAY. Passing --ozone-platform-hint=auto doesn’t work, it looks like UHK Agent doesn’t pass this to Electron.

The error is coming from ozone_platform_x11.cc so it’s clearly trying to run it on X11.

UPDATE: To get UHK to work in Wayland (and probably ANY electron-based application) - do export ELECTRON_OZONE_PLATFORM_HINT=auto

I am running Agent on Ubuntu 24.10 with a Wayland session. I had to install libfuse2 (whatever the latest version of that is) to get AppImages to work. I also had to pass --no-sandbox to the .AppImage in order to run it.

2 Likes

Thanks! Yeah I stumbled upon your post however --no-sandbox --enable-features=UseOzonePlatform,WaylandWindowDecorations --ozone-platform-hint=auto did not work for me. But I did not install libfuse2 nor did I edit the configuration file for UHK. I’ll try that and let you know how it goes.

Agent runs just fine on my Pop_OS! 22.04 system in a Wayland session. I did not have to pass any parameters, nor install any extra libraries.

1 Like

actually fuse2 was installed as a dependency during the uhk-agent-appimage installation, no luck

Installed from here: AUR (en) - uhk-agent-appimage

for the reference, I have the worst possible combo: wayland + sway + nvidia with proprietary driver, although I’m sure the problem is not because of gpu, from the error it looks like uhk is trying to launch in X11 mode completely ignoring the flags

the aur package seems to be updated January this year so it should be up to date

Shouldn’t it run via Xwayland if it starts up as an X11 application? What happens if you start it without any extra parameters?

The same error if I run it without the parameters. Chrome & chromium also doesn’t start btw unless you specify --ozone-platform-hint=auto, afaik this parameter needs to be passed to electron so that it would work with wayland. So in order to run chrome in wayland I needed to run it with this parameter, and then I went to ://flags and enabled ozone-platform=auto so that I can run it without the parameter. And chrome is not the only application that requires this parameter, basically anything that has electron underneath requires it too

I had some other application can’t remember what it was but it wasn’t starting in wayland too, until I passed this parameter. And then it said “unsupported parameter ozone-platform-hint, but passing it to electron” and it did run

I suppose electron has wayland support it just needs to know that it’s being executed by wayland and not by X, but judging from the error message it wants to execute under X (which is absent). not sure how it’s being handled in ubuntu-like distros

also the issue is completely reproducible on a fresh arch install & uhk agent from aur, on a new virtual box machine. so doesn’t look like it’s because of drivers or devices, the app just wants X for some reason and I can’t for the life of me figure out how to get it to use wayland. I mean I knew I was destined for the world of pain picking arch and wayland being an nvidia owner lol and yeah I can boot to X to configure my keyboard but I’d really like to make it work

Alright I managed to get it to work. So, apparently uhk-agent doesn’t pass --ozone-platform-hint parameter to underlying electron backend but setting this up:
export ELECTRON_OZONE_PLATFORM_HINT=auto

is apparently the same as specifying the parameter and passing it to electron, because after I did that - UHK agent has started (without any arguments, just uhk-agent command).

Note to devs: maybe it’s a good idea to add this to docs? If we ever have a section for Wayland there. And I’m probably gonna be creating a wiki page on Arch wiki about it :slight_smile:

This is a great find for me not just for UHK cause all the software that requires electron (discord included) needs that parameter being passed to it, and now (apparently? needs testing) I can just set this environment variable and it would all automagically work!

Probably Pop_OS & Ubuntu have this environment variable set when running Wayland.

3 Likes

That’s awesome you got it working! I will make a note of this env var as well for my Ubuntu 24.10 setup!

I have an update on this for anyone who sets this env var on Ubuntu 24.10 with the Wayland session.

  • It messes up VSCode which uses Electron (so it might not start, or show any window transparency).
  • So this is probably not the best default to set in ~/.profile :slight_smile: .

No.

$ set | grep -i ELECTRON
$ 

No environment variables for electron.

Still, Agent just works when I run it:

$ ~/AppImages/UHK.Agent-5.0.2-linux-x86_64_ee864eea394dd09f8e746c5bb8828406.AppImage
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
22:12:52.405 › [Electron Main] command line arguments {}
22:12:52.410 › [Electron Main] init services.
22:12:52.410 › [Electron Main] packagesDir: /tmp/.mount_UHK.Ag0M3aJ1/resources
22:12:52.687 › [Electron Main] Create new window.
22:12:52.687 › [WindowState] load settings
22:12:52.688 › [WindowState] loaded settings { width: 1024, height: 768, isMaximized: true, isFullScreen: false }
22:12:52.688 › [WindowState] loaded settings is visible false
22:12:52.689 › [WindowState] return with default settings
22:12:52.689 › [SmartMacroService] starting...
22:12:52.690 › [SmartMacroCopy] start
22:12:52.780 › [SmartMacroCopy] copy {
  destination: '/home/max/.config/uhk-agent/smart-macro-docs/UltimateHackingKeyboard/firmware/v12.2.0',
  smartMacroDocFirmwarePath: '/tmp/.mount_UHK.Ag0M3aJ1/resources/packages/firmware/doc'
}
22:12:52.809 › [SmartMacroCopy] done
22:12:52.809 › [SmartMacroCopy] start copy loading.html
22:12:52.811 › [SmartMacroCopy] end copy loading.html
22:12:52.823 › [SmartMacroService] get free TCP port
22:12:52.827 › [SmartMacroService] acquired TCP port: 33651
22:12:52.845 › [SmartMacroService] started on 33651.
22:12:53.057 › [DeviceService] init success
22:12:53.058 › [AppUpdateService] init success
22:12:53.058 › [AppService] init success
22:12:53.058 › [SudoService] App root dir:  /tmp/.mount_UHK.Ag0M3aJ1/resources
22:12:53.101 › [DeviceService] Udev info: Ok
22:12:53.473 › [AppService] get-config: application-settings
22:12:53.475 › [AppService] get-config of "application-settings": {"errorPanelHeight":32.69230769230769,"checkForUpdateOnStartUp":false,"everAttemptedSavingToKeyboard":true,"animationEnabled":false,"appTheme":"system","backlightingColorPalette":[{"r":255,"g":0,"b":0},{"r":0,"g":255,"b":0},{"r":0,"g":0,"b":255},{"r":0,"g":0,"b":0,"a":1}],"keyboardHalvesAlwaysJoined":false,"smartMacroPanelWidth":41}
22:12:53.731 › [DeviceRendererService] init success 
22:12:53.735 › [AppRendererService] init success 
22:12:53.739 › [MonacoEditorCompletionItemProvider] initialized.
22:12:53.740 › [SmartMacroDocRendererService] init success
22:12:53.742 › Renderer appStart effect start
22:12:53.742 › [AppRendererService] getAppStartInfo
22:12:53.743 › [SmartMacroService] getAppStartInfo
22:12:53.743 › [AppService] getAppStartInfo
22:12:53.742 › Renderer appStart effect end
22:12:53.743 › [AppService] get-config: application-settings
22:12:53.744 › [AppUpdateService] check for update at startup: { checkForUpdateOnStartUp: false }
22:12:53.745 › [AppService] getAppStartInfo response: {
  commandLineArgs: { 'disable-agent-update-protection': false },
  platform: 'linux',
  osVersion: '6.9.3-76060903-generic',
  udevFileContent: '# Ultimate Hacking Keyboard rules\n' +
    '# These are the udev rules for accessing the USB interfaces of the UHK as non-root users.\n' +
    '# Copy this file to /etc/udev/rules.d and physically reconnect the UHK afterwards.\n' +
    'SUBSYSTEM=="input", ATTRS{idVendor}=="1d50", ATTRS{idProduct}=="612[0-7]", GROUP="input", MODE="0660"\n' +
    'SUBSYSTEMS=="usb", ATTRS{idVendor}=="1d50", ATTRS{idProduct}=="612[0-7]", TAG+="uaccess"\n' +
    'KERNEL=="hidraw*", ATTRS{idVendor}=="1d50", ATTRS{idProduct}=="612[0-7]", TAG+="uaccess"\n' +
    '\n' +
    'SUBSYSTEM=="input", ATTRS{idVendor}=="37a8", ATTRS{idProduct}=="*", GROUP="input", MODE="0660"\n' +
    'SUBSYSTEMS=="usb", ATTRS{idVendor}=="37a8", ATTRS{idProduct}=="*", TAG+="uaccess"\n' +
    'KERNEL=="hidraw*", ATTRS{idVendor}=="37a8", ATTRS{idProduct}=="*", TAG+="uaccess"\n'
}
22:12:53.745 › [AppService] get-config of "application-settings": {"errorPanelHeight":32.69230769230769,"checkForUpdateOnStartUp":false,"everAttemptedSavingToKeyboard":true,"animationEnabled":false,"appTheme":"system","backlightingColorPalette":[{"r":255,"g":0,"b":0},{"r":0,"g":255,"b":0},{"r":0,"g":0,"b":255},{"r":0,"g":0,"b":0,"a":1}],"keyboardHalvesAlwaysJoined":false,"smartMacroPanelWidth":41}
22:12:53.841 › [SmartMacroDocRendererService] dispatch action: [smart-macro-doc] service listening
22:12:53.842 › [AppRendererService] dispatch action: [app] process start info
22:12:53.842 › [AppEffect][processStartInfo] payload: {
  commandLineArgs: { 'disable-agent-update-protection': false },
  platform: 'linux',
  osVersion: '6.9.3-76060903-generic',
  udevFileContent: '# Ultimate Hacking Keyboard rules\n' +
    '# These are the udev rules for accessing the USB interfaces of the UHK as non-root users.\n' +
    '# Copy this file to /etc/udev/rules.d and physically reconnect the UHK afterwards.\n' +
    'SUBSYSTEM=="input", ATTRS{idVendor}=="1d50", ATTRS{idProduct}=="612[0-7]", GROUP="input", MODE="0660"\n' +
    'SUBSYSTEMS=="usb", ATTRS{idVendor}=="1d50", ATTRS{idProduct}=="612[0-7]", TAG+="uaccess"\n' +
    'KERNEL=="hidraw*", ATTRS{idVendor}=="1d50", ATTRS{idProduct}=="612[0-7]", TAG+="uaccess"\n' +
    '\n' +
    'SUBSYSTEM=="input", ATTRS{idVendor}=="37a8", ATTRS{idProduct}=="*", GROUP="input", MODE="0660"\n' +
    'SUBSYSTEMS=="usb", ATTRS{idVendor}=="37a8", ATTRS{idProduct}=="*", TAG+="uaccess"\n' +
    'KERNEL=="hidraw*", ATTRS{idVendor}=="37a8", ATTRS{idProduct}=="*", TAG+="uaccess"\n'
}
22:12:53.844 › [DeviceService] start poll UHK Device
22:12:54.067 › [UhkHidDevice] Devices before checking permission:
22:12:54.068 › [UhkHidDevice] Available devices unchanged
22:12:54.130 › [DeviceService] Device connection state changed to: {
  "bootloaderActive": false,
  "bleDeviceConnected": false,
  "communicationInterfaceAvailable": false,
  "dongle": {
    "bootloaderActive": false,
    "multiDevice": false,
    "serialNumber": ""
  },
  "leftHalfBootloaderActive": false,
  "hasPermission": true,
  "halvesInfo": {
    "areHalvesMerged": true,
    "leftModuleSlot": 0,
    "isLeftHalfConnected": true,
    "rightModuleSlot": 0
  },
  "hardwareModules": {
    "moduleInfos": [],
    "rightModuleInfo": {
      "modules": {}
    }
  },
  "isMacroStatusDirty": false,
  "leftHalfDetected": false,
  "multiDevice": false,
  "udevRulesInfo": "Ok"
}
22:12:54.130 › [DeviceRendererService] dispatch action [device] connection state changed
22:12:54.134 › [SmartMacroDocRendererService] downloadDocumentation
22:12:54.135 › [SmartMacroService] skip download firmware documentation because git repo or tag missing { firmwareGitRepo: '', firmwareGitTag: '' }
22:12:54.383 › [UhkHidDevice] Devices before checking permission:
22:12:54.386 › [UhkHidDevice] Available devices unchanged
22:12:56.276 › [UhkHidDevice] Devices before checking permission:
22:12:56.280 › [UhkHidDevice] Available devices unchanged
22:12:56.298 › [WindowState] load settings
22:12:56.298 › [WindowState] loaded settings { width: 1024, height: 768, isMaximized: true, isFullScreen: false }
22:12:56.299 › [WindowState] loaded settings is visible false
22:12:56.299 › [WindowState] return with default settings
22:12:56.299 › [WindowState] save settings: { width: 1024, height: 768, isMaximized: true, isFullScreen: false }
22:12:56.307 › [WindowState] save settings success
22:12:56.314 › [Electron Main] win closed
22:12:56.314 › [DeviceService] stop poll UHK Device

(This was started without any UHK connected. The main window opened anyway and displayed the message “Cannot find your UHK. Please plug it in!”.)

Do you have Xwayland running on your system?

$ ps -ef | grep Xwayland
max         1713    1390  0 Jän09 ?       01:34:35 /usr/bin/Xwayland :0 -rootless -noreset -accessx -core -auth /run/user/1000/.mutter-Xwaylandauth.T1BRZ2 -listen 4 -listen 5 -displayfd 6 -initfd 7
1 Like

yeah I didn’t even have it installed, so I guess you need that env variable if you want the UHK to run in native wayland. I suppose if you have xwayland installed then it defaults to xserver and runs in xwayland

p.s. also vscode runs perfectly fine for me in native wayland & with this environment variable set, it wasn’t even starting as well as uhk agent without that environment variable. I suppose it might be using xwayland too without it?

I really don’t know the details; I just use a pretty standard Pop_OS! 22.04 install, and I turned on the Wayland session on the login screen. It seems snappier than X11 and very reliable. I know it keeps an Xwayland server running for X11 apps, so maybe that’s used for Agent and perhaps even VSCode. I use both; I just ran them and they work.

I guess my point is: it is possible to set up Wayland systems, and run Agent as well as VSCode and other apps without having to jump through hoops. Not sure why that doesn’t work on some people’s set-ups. Maybe I was just lucky to choose a Linux distro that is perhaps less “pure” but offers better legacy compatibility. But yeah, I wanted something that works pretty much out of the box, and Pop_OS delivered.

Arch distro is pretty much live cd, you go from there and install whatever you need. so naturally when I tried installing a Wayland environment I did not have xwayland installed cause it’s not a dependency for anything, this is why my apps that tried to use X did not start at all.

So does it work now with Xwayland installed?

I didn’t really test cause I’m using that environment variable to run it natively in wayland, to test that I would need to remove the variable and start uhk. But I suppose it should, because some other applications that weren’t running without xwayland are running fine now.

It works without xwayland with the environment variable mentioned above, it lets electron know that the environment is wayland.