Skip to content

Instantly share code, notes, and snippets.

@harryjubb
Last active December 1, 2021 16:27
Show Gist options
  • Save harryjubb/d74a8c1cf5ea068346acb6c333f0bbec to your computer and use it in GitHub Desktop.
Save harryjubb/d74a8c1cf5ea068346acb6c333f0bbec to your computer and use it in GitHub Desktop.
Installing DuckyPad autoswitcher with Mac fixes

DuckyPad Mac autoswitcher fixes branch

Overview

The Duckypad autoswitcher seems to have some issues on OS X, where the autoswitcher will not switch profiles.

The issue seems to be that on Mac the autoswitcher keeps a long lived HID connection, and that OS X doesn’t get key presses from the pad while that connection is open. It could be that an OS X update changed how HID works, but is not clear.

There is a branch with some substantial changes to the autoswitcher that doesn’t do this on Mac, though it’s definitely imperfect. On that branch the autoswitcher occasionally crashes, or stops working if the pad is disconnected and reconnected: but easily fixed by restarting the autoswitcher. There also seems an issue that the first keypress is ignored when the pad wakes up from sleep. But on the whole, it does fix the issue!

The instructions and code below are provided without warranty, under the MIT license. Use at own risk!

OS X system permissions

Your terminal program will need to have the following permissions enabled under System Preferences -> Security & Privacy -> Privacy:

  • Input Monitoring (required to talk to Duckypad)
  • Screen Recording (required to get window titles)

If having any issues, it may also be worth trying enabling Accessibility as well.

Setting up

  1. Go to https://github.com/harryjubb/duckyPad-profile-autoswitcher/tree/os-x-open-close-hid
  2. Click on the green "Code" button
  3. Download ZIP
  4. Extract the zip file. The unzipped folder can be placed wherever you prefer
  5. Open a Terminal window and change into the unzipped folder
  6. Create a Python virtual environment to avoid installing dependencies into your system Python:
python3 -m venv venv
  1. Activate the virtual environment (has your terminal session use the virtual environment Python):
source venv/bin/activate
  1. Install requirements for the autoswitcher:
pip3 install -r requirements.txt
  1. Run the autoswitcher. Has to be run as root to work, so requires a password:
sudo python3 src/duckypad_autoprofile.py
  1. When finished, the virtual environment can be deactivated with deactivate (only necessary if you needed to use a different Python install in the same terminal window)

OS X Monterey tkinter issues

2021-12-01

With thanks to Daedalus#3131

On OS X Monterey (12.x.x) there's an issue with Tk in Python where the GUI window ends up completely black and unusable.

If anyone else runs into this problem with Tk/python being finicky, it can be fixed by using the latest official Python 3.10 distribution, which includes a patch for the issue:

  1. Uninstall python3 from homebrew and any version of python3 from python.org
  2. Install pyenv and download Python 3.10.0 from python.org
  3. Create a virtualenv using pyenv-virtualenv plugin specific to the autoswitcher directory
  4. Install the requirements, and run the script as above
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment