UP | HOME

Dumang DK6 Keyboard
Issues and Solutions on Mac

Table of Contents

Dumang DK6 is a modular keyboard compatible with Cherry-MX switch (not with low profile). To see what the keyboard looks like, see photos and my experience at Xahlee's Dumang DK6 keyboard page. If you know Chinese, you can visit the official product page here for a lot more information.

As of 2020-11-14, the Dumang app that's used to configure the keyboard only supports Windows. You will need a Windows system, either in a real machine or a virtual machine, to do the configuration, such as key mapping, macro, and firmware update.

The Dumang DK6 keyboard is a single piece USB keyboard. However, because of its small size (L:20cm, W:14cm), it's not possible to put on it all keys of a standard 104-key keyboard. Therefore, you need two of them to mount all the keys you normally see on a laptop. That means you need to connect two USB devices to one computer. The problem is different operating systems handle multiple keyboards differently. On Windows, everything works perfectly out of the box. On Mac, three problems must be solved before you could make full use of two DK6 keyboards. This page describes how to make two Dumang DK6 keyboards to work on Mac.

Issues and Solutions on Mac

[Issue-1] Common key combos not working

Issue

Common key combos don't work if the keys of the combo are not on the same keyboard. For example, with dvorak layout, the following key combos will not work: Left Cmd+c, Left Ctrl+d, or Left Option+r, because c d r are all on the right.

Solution

Install Karabiner-elements (here is the installation instruction). Once the installation and setup is done, open the app and the issue will be gone. No further configuration is required. Add the app to login item list so that you don't need to open it every time you log in the system.

[Issue-2] Layer switching key combos not working

Issue

This issue is similar to Issue-1, but instead happens to the layer switching key (aka the Fn key). Fn key combos don't work if the keys of the combo are not on the same keyboard. For example, with Fn configured to switching to layer 1 and with dvorak layout, Fn+c will not do what you have configured it to do. When you press a Fn key combo, the layer indicating LED is red on the Fn side and cyan on the c side which should've been red, too. (layer to LED color mapping: 0(default layer): cyan, 1: red, 2: green, 3: blue)

Solution

Install and setup Dumang-ctrl (github repo). Dumang-ctrl is a runnable script written in Python 3. It syncs the events between two Dumang DK6 keyboards. For example, when you press Fn on one board to switch to layer 1, the other board will also be switched to layer 1.

  1. Install Homebrew
  2. Setup Python3
    1. Install Python3 (homebrew python formula)

      brew install python # this installs python3 by default
      
    2. Add python lib to $PATH

      # Setting PATH for homebrew Python
      export PATH="/usr/local/opt/python/libexec/bin:$PATH"
      
  3. Install dumang-ctrl and its dependencies

    brew install libusb
    pip install dumang-ctrl libusb1 libusb
    
  4. Run dumang-sync in terminal
  5. Press Fn on one keyboard, and the light on other board should now be red (layer 1).

[Issue-3] dumang-sync failed to resync on system wake up and keyboard reconnecting

Issue

When you do a fresh run of dumang-sync, it will run without any problem and the two keyboards will be synced. However, whenever MacOS wakes up from sleep, or you logout and login, or if you plug out and plug in the keyboards, it will fail to sync. From the log, I found that the script seemed to be trying to auto-detect the hot plugging, yet it just failed to do so, for whatever reason.

Solution

Killing and restarting the daemon will solve the problem. Since sleeping and waking up from sleep happens very often, there must be a way to quickly bring the daemon back to life. But to do it manually and frequently in terminal is counter-efficient, and keeping a terminal window open all the time running the daemon is cluttered. The best way is to just press one key or key combo and the daemon would get restarted. I came up with a solution by integrating Shell script, Automator, and QuickSilver.

  1. Create an Automator application to run the following shell scipt to do auto killing and restarting. Save the application as dumang-sync.

    pgrep -f dumang-sync | xargs kill
    /usr/local/bin/dumang-sync > /dev/null 2>&1 &
    
  2. Install QuickSilver. Add a trigger to open the app created above, and assign a shortcut to the trigger, for example, Cmd+Home. The key combo must not be a Fn combo as the daemon had already stopped working at the time. Now, you can just press Cmd+Home to bring the daemon back to life.
  3. Auto launch dumang-sync on system startup. Add the dumang-sync app to login item list so that you don't need to open it every time you log in the system, though it's just one key combo away.

[Update 2021-10-15] Recover dumang-sync on system wakeup

Using a command line tool (daemon) called SleepWatcher, you can eleminate the need to press the above key combo (Cmd+Home) to bring the dumang-sync back to life every time your computer wakes up from sleep.

  1. Install SleepWatcher(homebrew SleepWatcher formula)

    brew install sleepwatcher
    
  2. Create a file called .wakeup in your home folder, and make it executable.

    touch ~/.wakeup
    chmod +x ~/.wakeup
    
  3. Add the following to .wakeup file (in fact it's a bash script). Sleepwatcher will execute the file when your computer wakes up from sleep.

    #!/bin/sh
    pgrep -f dumang-sync | xargs kill
    /usr/local/bin/dumang-sync > /dev/null 2>&1 &
    
  4. Start sleepwatcher service

    brew services start sleepwatcher
    

Now, dumang-sync should be recovered automatically when your computer wakes up from sleep.

By James Ni | Date: 2020-11-10 | Last Updated: 2021-10-15 Fri 23:20

© 2021 James Ni