This document provides the steps you can take to build, test, and try out AutoKey in a virtual machine. Each section's steps are done in a fresh Ubuntu virtual machine and finish with a final step to destroy the virtual machine. This type of isolation keeps the state of the machine as a known constant. Note that for those who are new to virtual machines, there's a guide for installing VirtualBox and another for using VirtualBox.
Some of the steps install packages or edit existing AutoKey files. Some of those tweaks may need to become a permanent part of AutoKey, so they're marked with highlights for review. Maybe the whole thing should be self-contained so that there's no need to install or change anything in order to run tests or do builds...
Caution: All copies of AutoKey, whether installed from your operating system's repositories or cloned or downloaded, share the same configuration files on your system. As a result, it's not recommended to do these tests on a production machine! If you'd like to do so anyway, you should back up your AutoKey configuration directory first so you can restore it afterwards if needed.
The goal is to run AutoKey through its paces in the Ubuntu and Python environments currently supported by GitHub. The GitHub Runners page lists the supported Ubuntu releases in its Image column. Each image's Included software column opens its page that lists the supported Python versions in the Python section at the bottom. Note that the Ubuntu Slim runner can be disregarded since it's exclusively for GitHub's use. Also, similar testing done on Arch, Debian, Fedora, Gentoo, Ubuntu derivatives, etc., is always welcome.
This document will have achieved its goal only when each of these items has a check-mark next to it:
- A build of an AutoKey clone without errors or warnings:
- Ubuntu 22.04 under Wayland
- Ubuntu 22.04 under Xorg
- β Ubuntu 24.04 under Wayland
- Ubuntu 24.04 under Xorg
- An installation from that local build without errors:
- Ubuntu 22.04 under Wayland
- Ubuntu 22.04 under Xorg
- Ubuntu 24.04 under Wayland
- Ubuntu 24.04 under Xorg
- A trial-run of that installation with a (mostly) functioning interface:
- Ubuntu 22.04 under Wayland
- Ubuntu 22.04 under Xorg
- Ubuntu 24.04 under Wayland
- Ubuntu 24.04 under Xorg
- All pytest tests passing:
- Ubuntu 22.04 under Wayland
- Ubuntu 22.04 under Xorg
- Ubuntu 24.04 under Wayland
- Ubuntu 24.04 under Xorg
- All tox tests passing:
- Ubuntu 22.04 under Wayland
- Ubuntu 22.04 under Xorg
- Ubuntu 24.04 under Wayland
- Ubuntu 24.04 under Xorg
- A trial-run of an AutoKey clone without installing it with a (mostly) functional interface:
- Ubuntu 22.04 under Wayland
- Ubuntu 22.04 under Xorg
- Ubuntu 24.04 under Wayland
- Ubuntu 24.04 under Xorg
π΄π‘π’ TODO π’π‘π΄
With the following steps, you can clone AutoKey and use pytest to run unit-tests on the raw source code without installing AutoKey:
- Create a fresh Ubuntu virtual machine.
- Boot the virtual machine.
- Log in to a Xorg session.
- Update the operating system:
sudo apt update
- Install the core tools (pick one):
- If you're using Ubuntu 22.04 LTS:
sudo apt install -y git python3-pip python3-setuptools python3-tk python3-venv xvfb
- If you're using Ubuntu 24.04 LTS:
sudo apt install -y git python3-build python3-pip python3-pyasyncore python3-setuptools python3-tk python3-venv xvfb
- If you're using Ubuntu 22.04 LTS:
- Create the
~/clonesdirectory:mkdir -p ~/clones - Change to the clones directory:
cd clones - Clone AutoKey (pick one):
- Clone a pull request, replacing 123 with the pull request number:
PR=123; git clone https://github.com/autokey/autokey.git && (cd autokey && git fetch origin pull/$PR/head:pull_$PR && git checkout pull_$PR)
- Clone the current release:
git clone https://github.com/autokey/autokey.git
- Clone the develop branch:
git clone --branch develop --single-branch https://github.com/autokey/autokey.git
- Clone a pull request, replacing 123 with the pull request number:
- Change to the autokey sub-directory:
cd autokey - Edit the wayland_checks.py file to prevent the error about f-strings not being allowed to contain a backslashes (pick one):
- If you're using Ubuntu 22.04 LTS:
- Open the lib/autokey/wayland_checks.py file in a text editor.
- Replace this block at the bottom of the file:
with this block:
# Show popup using kdialog, if it's installed, or zenity, otherwise write the # message to autokey.log def __show_popup(title, message): try: subprocess.run(f"kdialog --error '{message}' --title '{title}'", shell=True, check=True) except Exception: try: subprocess.run(f"zenity --error --title='{title}' --text='{message.replace('<br />', '\n')}'", shell=True, check=True) except Exception: logger.critical(message) # For testing purposes if __name__ == '__main__': if not waylandChecks(): print('waylandChecks() returned False')
# Show popup using kdialog, if it's installed, or zenity, otherwise write the # message to autokey.log def __show_popup(title, message): try: subprocess.run(f"kdialog --error '{message}' --title '{title}'", shell=True, check=True) except Exception: try: # Fix: Move the replace call out of the f-string for Python 3.10 compatibility clean_message = message.replace('<br />', '\n') subprocess.run(f"zenity --error --title='{title}' --text='{clean_message}'", shell=True, check=True) except Exception: logger.critical(message) # For testing purposes if __name__ == '__main__': if not waylandChecks(): print('waylandChecks() returned False')
- If you're using Ubuntu 24.04 LTS:
- Skip this step since it's a Python 3.10 fix that's no longer needed and would break the unit tests in Ubuntu 24.04 LTS.
- If you're using Ubuntu 22.04 LTS:
- Install and activate a Python virtual environment to prevent modules needed by AutoKey from being installed to your system:
- Create a new virtual environment that has access to your global system packages:
python3 -m venv --system-site-packages .venv
- Activate the virtual environment (note that your prompt will change to let you know you're in a virtual environment):
source .venv/bin/activate
- Create a new virtual environment that has access to your global system packages:
- Install AutoKey's apt dependencies:
sudo apt install -y $(cat apt-requirements.txt) - Update some testing tools (pick one):
- If you're using Ubuntu 22.04 LTS:
python3 -m pip install --upgrade pip setuptools wheel
- If you're using Ubuntu 24.04 LTS:
- Skip this step.
- If you're using Ubuntu 22.04 LTS:
- Install AutoKey's pip dependencies (pick one):
- If you're using Ubuntu 22.04 LTS:
python3 -m pip install -r pip-requirements.txt
- If you're using Ubuntu 24.04 LTS:
python3 -m pip install -r pip-requirements.txt --break-system-packages
- If you're using Ubuntu 22.04 LTS:
- Install the necessary testing utilities in the virtual environment (pick one):
- If you're using Ubuntu 22.04 LTS:
python3 -m pip install build pyhamcrest pyasyncore pytest pytest-cov pytest-xdist
- If you're using Ubuntu 24.04 LTS:
python3 -m pip install pytest pytest-cov pytest-xdist --break-system-packages
- If you're using Ubuntu 22.04 LTS:
- Create the pytest.ini file for additional coverage configuration:
echo -e "[pytest]\\naddopts = --cov=lib/autokey\\npythonpath = lib" > pytest.ini
- Run the unit tests with the coverage option to see which parts of the code were executed for the tests:
Or run the same command and create a log-file:
xvfb-run -a .venv/bin/python -m pytest --cov=lib/autokey tests -k "not interface and not service"xvfb-run -a .venv/bin/python -m pytest --cov=lib/autokey tests -k "not interface and not service" 2>&1 | tee test_results.log
- If you made changes to these steps and took notes, copy your notes out of the virtual machine.
- If you created logs that you'd like to reference or share later, copy those logs out of the virtual machine.
- Destroy the virtual machine.
With the following steps, you can clone AutoKey and use tox to run compatibility tests against multiple Python versions if available without installing AutoKey:
π΄π‘π’ TODO π’π‘π΄
With the following steps, you can clone AutoKey and try it out from a temporary directory on your computer without installing it:
- Create a fresh Ubuntu virtual machine.
- Boot the virtual machine.
- Log in to a Xorg session.
- Update the operating system:
sudo apt update
- Install the core tools:
sudo apt install -y git python3-pip
- Clone AutoKey (pick one):
- Clone a pull request, replacing 123 with the pull request number:
PR=123; git clone https://github.com/autokey/autokey.git && (cd autokey && git fetch origin pull/$PR/head:pull_$PR && git checkout pull_$PR)
- Clone the current release:
git clone https://github.com/autokey/autokey.git
- Clone the develop branch:
git clone --branch develop --single-branch https://github.com/autokey/autokey.git
- Clone a pull request, replacing 123 with the pull request number:
- Change to the autokey sub-directory that you created in step 6:
cd autokey - Install AutoKey's apt dependencies:
sudo apt install -y $(cat apt-requirements.txt) - Install AutoKey's pip dependencies:
python3 -m pip install -r pip-requirements.txt
- Try out both AutoKey interfaces by repeating these steps with each interface:
- Change to the
/libdirectory:cd lib - Run AutoKey with its configuration open and in verbose mode (pick one):
- GTK:
- If you cloned the current release:
python3 -m autokey.gtkui -cl
- If you cloned the develop branch or a pull request:
python3 -m autokey.gtkui -cv
- If you cloned the current release:
- Qt:
- If you cloned the current release:
python3 -m autokey.qtui -cl
- If you cloned the develop branch or a pull request:
python3 -m autokey.qtui -cv
- If you cloned the current release:
- GTK:
- Try out AutoKey's features:
- If you're using Wayland in the Gnome desktop environment, Assistive Technologies must be enabled in the Gnome settings.
- Try out AutoKey's basic features:
- Check the terminal window for traceback errors.
- Use all of AutoKey's menu entries.
- Go into all of AutoKey's settings to make sure they're accessible and work and that the version is correctly listed.
- Run all of AutoKey's default phrases and scripts from the "play" button in the AutoKey interface.
- Run all of AutoKey's default phrases and scripts from a hotkey.
- Run all of AutoKey's default phrases and scripts from an abbreviation.
- Change each of the settings on a phrase and try each of them out.
- Create and try out a new phrase.
- Create and try out a new script.
- Change to the
- If you made changes to these steps and took notes, copy your notes out of the virtual machine.
- If you created logs that you'd like to reference or share later, copy those logs out of the virtual machine.
- Destroy the virtual machine.
With the following steps, you can clone AutoKey and build it without testing or installing it:
-
Create a fresh Ubuntu virtual machine.
-
Boot the virtual machine.
-
Log in to a Wayland session.
-
Update the operating system:
sudo apt update
-
Install the core tools (pick one):
- If you're using Ubuntu 22.04 LTS:
sudo apt install -y git python3-pip python3-setuptools python3-venv zip
- If you're using Ubuntu 24.04 LTS:
sudo apt install -y git python3-build python3-pip python3-setuptools python3-venv zip
- If you're using Ubuntu 22.04 LTS:
-
Create the clones directory:
mkdir -p ~/clones -
Change to the clones directory:
cd clones -
Clone AutoKey (pick one):
- Clone a pull request, replacing 123 with the pull request number:
PR=123; git clone https://github.com/autokey/autokey.git && (cd autokey && git fetch origin pull/$PR/head:pull_$PR && git checkout pull_$PR)
- Clone the current release:
git clone https://github.com/autokey/autokey.git
- Clone the develop branch:
git clone --branch develop --single-branch https://github.com/autokey/autokey.git
- Clone a pull request, replacing 123 with the pull request number:
-
Change to the autokey sub-directory:
cd autokey -
Download the PKG-INFO file from the master branch of AutoKey and put it into the
~/clones/autokeydirectory. -
Replace the
apt-requirements.txtfile's contents with these contents. -
Replace the
PKG-INFOfile's contents with these contents. -
Replace the
setup.pyfile's contents with these contents. -
Replace the
debian/autokey-common.installfile's contents with these contents. -
Replace the
debian/autokey-common.postinstfile's contents with these contents. -
Replace the
debian/autokey-common.prermfile's contents with these contents. -
Replace the
debian/build_requirements.txtfile's contents with these contents. -
Replace the
debian/controlfile's contents with these contents. -
Replace the
debian/rulesfile's contents with these contents. -
Create the
debian/autokey-common.manpagesfile:echo "doc/man/autokey-run.1" > debian/autokey-common.manpages -
Create the
debian/autokey-gtk.manpagesfile:echo "doc/man/autokey-gtk.1" > debian/autokey-gtk.manpages -
Create the
debian/autokey-qt.manpagesfile:echo "doc/man/autokey-qt.1" > debian/autokey-qt.manpages -
Create the
debian/not-installedfile:echo -e "usr/lib/python3*/dist-packages/autokey/__pycache__/\nusr/lib/python3*/dist-packages/autokey/*/__pycache__/" > debian/not-installed -
Create the missing autokey-headless and autokey-shell man pages and add them the same way as the others were added above:
- π΄π‘π’ TODO BEFORE RELEASE -- This doesn't need to be done for the build, but does need to be done before the release. Until it's done, the build will give you a no-manual-page warning for autokey-headless and autokey-shell that you can safely ignore since you're aware that those files are missing and will be added. π’π‘π΄
- Create the
doc/man/autokey-headless.1man page file. - Create the
doc/man/autokey-shell.1man page file. - Write the
doc/man/autokey-headless.1man page. - Write the
doc/man/autokey-shell.1man page. - Add the
doc/man/autokey-headless.1path to thedebian/autokey-common.manpagesfile. - Add the
doc/man/autokey-shell.1path to thedebian/autokey-common.manpagesfile.
- Create the
- π΄π‘π’ TODO BEFORE RELEASE -- This doesn't need to be done for the build, but does need to be done before the release. Until it's done, the build will give you a no-manual-page warning for autokey-headless and autokey-shell that you can safely ignore since you're aware that those files are missing and will be added. π’π‘π΄
-
Figure out what, exactly, to update in the lib/autokey/configmanager/version_upgrading.py file. π΄π‘π’ TODO: This is critical! π’π‘π΄
-
Install and activate a Python virtual environment to prevent modules needed by AutoKey from being installed to your system:
- Create a new virtual environment that has access to your global system packages:
python3 -m venv --system-site-packages .venv
- Activate the virtual environment (note that your prompt will change to let you know you're in a virtual environment):
source .venv/bin/activate
- Create a new virtual environment that has access to your global system packages:
-
Install AutoKey's apt dependencies:
sudo apt install -y $(cat apt-requirements.txt) -
Install AutoKey's build dependencies:
sudo apt install -y $(cat debian/build_requirements.txt) -
Install AutoKey's pip dependencies:
python3 -m pip install -r pip-requirements.txt
-
Install the AutoKey Gnome Extension:
- Change to the
autokey-gnome-extensionsubdirectory:cd ~/clones/autokey/autokey-gnome-extension
- Set up the extension:
make
- Install the extension:
gnome-extensions install autokey-gnome-extension@autokey.zip
- Configure your system to allow members of the input user group to use virtual keyboards and mice:
sudo cp ~/clones/autokey/config/10-autokey.rules /etc/udev/rules.d/ - Add your user account to the input group:
sudo usermod -a -G input $(id -un) - Apply the changes by rebooting:
sudo reboot
- Log back in to a Wayland session.
- Turn on the AutoKey Gnome extension:
gnome-extensions enable autokey-gnome-extension@autokey - Rename the AutoKey Gnome Extension that you just created so that it's accepted by the build process: π΄π‘π’ Figure out how to sort out this conflict so that this hack isn't necessary. π’π‘π΄
mv ~/clones/autokey/autokey-gnome-extension/autokey-gnome-extension@autokey.zip ~/clones/autokey/autokey-gnome-extension/autokey-gnome-extension@autokey.shell-extension.zip
- Change to the
-
Change to the autokey directory:
cd ~/clones/autokey
-
Make the
debian/*.prermscripts executable:chmod +x debian/rules debian/*.prerm -
Make the
debian/rulesscript executable:chmod +x debian/rules
-
Make the
debian/build.shscript executable:chmod +x debian/build.sh
-
Make the /dev/uinput file executable:
sudo chmod 0666 /dev/uinput
-
Build AutoKey (pick one):
- Run the build command to generate unsigned build files in the parent (clones) directory:
π΄π‘π’ You'll see a maintainer-script-ignores-errors warning that's a minor technicality in how the installer cleans up after itself. You'll also see two no-manual-page warnings that refer to the missing autokey-headless and autokey-shell man pages that are mentioned earlier in these steps as a TODO that will be taken care of before the next release. All three warnings can safely be ignored. π’π‘π΄
debuild -us -uc -b
- Run the build script to generate unsigned build files in the parent (clones) directory:
bash debian/build.sh
- Run the build command to generate unsigned build files in the parent (clones) directory:
-
Verify the generated packages:
- List the generated files (the version in the filename will match the version specified in the
lib/autokey/common.pyfile):ls -l ~/clones/*.deb
- Verify that there are Wayland files inside of one of the .deb files since the previous build was for Xorg:
If the output contains wayland_checks.py, the build succeeded.
dpkg-deb -c ~/clones/autokey-common_0.97.0_all.deb | grep wayland
- List the generated files (the version in the filename will match the version specified in the
-
Install the builds:
sudo apt install -y ~/clones/autokey-common_0.97.0_all.deb ~/clones/autokey-gtk_0.97.0_all.deb ~/clones/autokey-qt_0.97.0_all.deb
π΄π‘π’ You can ignore the warning about the download having been performed unsandboxed as root since the file couldn't be accessed by the _apt user. It's the apt command letting you know that since the
.debfiles it needs to read are in your private home directory and since it doesn't have permission to read your files as the _apt user, it has to fall back to reading them as root instead. π’π‘π΄ -
Verify that the installation succeeded (pick one or more):
- Display the AutoKey help:
autokey --help
- Display the first line of the
changelogfile to make sure the most recent entry corresponds to the build you wanted to create:zcat /usr/share/doc/autokey-common/changelog.gz | head -n 1
- Display the AutoKey help:
-
Optionally, run AutoKey to make sure the build and installation worked (pick one):
- If this is an Ubuntu 22.04 virtual machine:
...or...
autokey-gtk -cl
autokey-qt -cl
- If this is an Ubuntu 24.04 virtual machine:
...or...
autokey-gtk -cv
autokey-qt -cv
- If this is an Ubuntu 22.04 virtual machine:
-
If you made changes to these steps and took notes, copy your notes out of the virtual machine.
-
If you created logs that you'd like to reference or share later, copy those logs out of the virtual machine.
-
Destroy the virtual machine.
With the following steps, you can clone AutoKey and use pytest to run unit-tests on the raw source code without installing AutoKey:
- Create a fresh Ubuntu virtual machine.
- Boot the virtual machine.
- Log in to a Wayland session.
- Update the operating system:
sudo apt update
- Install the core tools (pick one):
- If you're using Ubuntu 22.04 LTS:
sudo apt install -y git python3-pip python3-pyasyncore python3-setuptools python3-tk python3-venv weston
- If you're using Ubuntu 24.04 LTS:
sudo apt install -y git python3-build python3-pip python3-pyasyncore python3-setuptools python3-tk python3-venv weston
- If you're using Ubuntu 22.04 LTS:
- Create the
${HOME}/clones/autokeydirectory on your system:mkdir -p ~/clones - Change to the new clones directory:
cd clones - Clone AutoKey (pick one):
- Clone a pull request, replacing 123 with the pull request number:
PR=123; git clone https://github.com/autokey/autokey.git && (cd autokey && git fetch origin pull/$PR/head:pull_$PR && git checkout pull_$PR)
- Clone the current release:
git clone https://github.com/autokey/autokey.git
- Clone the develop branch:
git clone --branch develop --single-branch https://github.com/autokey/autokey.git
- Clone a pull request, replacing 123 with the pull request number:
- Change to the autokey sub-directory that you created in step 6:
cd autokey - Edit the wayland_checks.py file to prevent the error about f-strings not being allowed to contain a backslashes (pick one):
- If you're using Ubuntu 22.04 LTS:
- Open the lib/autokey/wayland_checks.py file in a text editor.
- Replace this block at the bottom of the file:
with this block:
# Show popup using kdialog, if it's installed, or zenity, otherwise write the # message to autokey.log def __show_popup(title, message): try: subprocess.run(f"kdialog --error '{message}' --title '{title}'", shell=True, check=True) except Exception: try: subprocess.run(f"zenity --error --title='{title}' --text='{message.replace('<br />', '\n')}'", shell=True, check=True) except Exception: logger.critical(message) # For testing purposes if __name__ == '__main__': if not waylandChecks(): print('waylandChecks() returned False')
# Show popup using kdialog, if it's installed, or zenity, otherwise write the # message to autokey.log def __show_popup(title, message): try: subprocess.run(f"kdialog --error '{message}' --title '{title}'", shell=True, check=True) except Exception: try: # Fix: Move the replace call out of the f-string for Python 3.10 compatibility clean_message = message.replace('<br />', '\n') subprocess.run(f"zenity --error --title='{title}' --text='{clean_message}'", shell=True, check=True) except Exception: logger.critical(message) # For testing purposes if __name__ == '__main__': if not waylandChecks(): print('waylandChecks() returned False')
- If you're using Ubuntu 24.04 LTS:
- Skip this step since it's a Python 3.10 fix that's no longer needed and would break the unit tests in Ubuntu 24.04 LTS.
- If you're using Ubuntu 22.04 LTS:
- Install and activate a Python virtual environment to prevent modules needed by AutoKey from being installed to your system:
- Create a new virtual environment that has access to your global system packages:
python3 -m venv --system-site-packages .venv
- Activate the virtual environment (note that your prompt will change to let you know you're in a virtual environment):
source .venv/bin/activate
- Create a new virtual environment that has access to your global system packages:
- Install AutoKey's apt dependencies:
sudo apt install -y $(cat apt-requirements.txt) - Install AutoKey's pip dependencies:
python3 -m pip install -r pip-requirements.txt --break-system-packages
- Install the test suite and the coverage plug-in in the virtual environment (pick one):
- If you're using Ubuntu 22.04 LTS:
python3 -m pip install pytest pytest-cov pytest-xdist --break-system-packages
- If you're using Ubuntu 24.04 LTS:
python3 -m pip install build pytest pytest-cov pytest-xdist --break-system-packages
- If you're using Ubuntu 22.04 LTS:
- Create the
pytest.inifile for additional coverage configuration:echo -e "[pytest]\\naddopts = --cov=lib/autokey\\npythonpath = lib" > pytest.ini
- Configure your Wayland system to run AutoKey:
- Change to the
autokey-gnome-extensionsubdirectory:cd autokey-gnome-extension - Build the AutoKey extension for Gnome:
make
- Install the extension:
gnome-extensions install autokey-gnome-extension@autokey.shell-extension.zip
- Configure your system to allow members of the input user group to use virtual keyboards and mice:
sudo cp ~/clones/autokey/config/10-autokey.rules /etc/udev/rules.d/ - Add your user-account to the input group:
sudo usermod -a -G input $USER - Apply the changes by rebooting:
sudo reboot
- Log back in to a Wayland session.
- Turn on the AutoKey Gnome extension:
gnome-extensions enable autokey-gnome-extension@autokey
- Change to the
- Change to the AutoKey directory:
cd ~/clones/autokey
- Activate the virtual environment (note that your prompt will change to let you know you're in a virtual environment):
source .venv/bin/activate - Start the Weston reference compositor for Wayland in a background socket:
weston --backend=headless-backend.so --socket=wayland-1 & - Press the Enter key to get back to a prompt.
- Run the unit tests, pointing them to that socket, with the coverage option to see which parts of the code were executed for the tests:
Or run the same command and create a log-file:
WAYLAND_DISPLAY=wayland-1 XDG_SESSION_TYPE=wayland .venv/bin/python -m pytest --cov=lib/autokey tests
WAYLAND_DISPLAY=wayland-1 XDG_SESSION_TYPE=wayland .venv/bin/python -m pytest --cov=lib/autokey tests 2>&1 | tee test_results.log
- If you made changes to these steps and took notes, copy your notes out of the virtual machine.
- If you created logs that you'd like to reference or share later, copy those logs out of the virtual machine.
- Destroy the virtual machine.
With the following steps, you can clone AutoKey and use tox to run compatibility tests against multiple Python versions if available without installing AutoKey:
- Create a fresh Ubuntu virtual machine.
- Boot the virtual machine.
- Log in to a Wayland session.
- Update the operating system:
sudo apt update
- Install the core tools (pick one):
- If you're using Ubuntu 22.04 LTS:
sudo apt install -y build-essential libssl-dev zlib1g-dev \ libbz2-dev libreadline-dev libsqlite3-dev curl git \ libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev \ libffi-dev liblzma-dev libdbus-1-dev libglib2.0-dev \ libcairo2-dev python3-pyqt5 python3-dbus python3-gi \ gir1.2-gtk-3.0 xvfb xdg-utils python3-pip python3-setuptools \ python3-tk python3-venv
- If you're using Ubuntu 24.04 LTS:
sudo apt install -y build-essential curl gir1.2-gtk-3.0 \ gir1.2-gtksource-3.0 libcairo2-dev libdbus-1-dev \ libgirepository-2.0-dev libglib2.0-dev python3-build \ python3-dbus python3-gi python3-pip python3-pyasyncore \ python3-setuptools python3-tk python3-venv weston xvfb
- If you're using Ubuntu 24.04 LTS π΄π΄π΄MAYBE ALSO THIS, BUT TRY IT WITHOUT ITπ΄π΄π΄:
sudo apt install -y libayatana-appindicator3-dev
- If you're using Ubuntu 22.04 LTS:
- Download and set up pyenv:
if [ ! -d "$HOME/.pyenv" ]; then curl https://pyenv.run | bash export PYENV_ROOT="$HOME/.pyenv" export PATH="$PYENV_ROOT/bin:$PATH" eval "$(pyenv init - bash)" echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc echo '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc echo 'eval "$(pyenv init - bash)"' >> ~/.bashrc fi
- Install versions silently if missing
pyenv install -s 3.10.20 pyenv install -s 3.11.15 pyenv local system 3.10.20 3.11.15 - Create the
~/clonesdirectory:mkdir -p ~/clones - Change to the clones directory:
cd clones - Clone AutoKey (pick one):
- Clone a pull request, replacing 123 with the pull request number:
PR=123; git clone https://github.com/autokey/autokey.git && (cd autokey && git fetch origin pull/$PR/head:pull_$PR && git checkout pull_$PR)
- Clone the current release:
git clone https://github.com/autokey/autokey.git
- Clone the develop branch:
git clone --branch develop --single-branch https://github.com/autokey/autokey.git
- Clone a pull request, replacing 123 with the pull request number:
- Change to the autokey sub-directory:
cd autokey - Generate the tox.ini file:
cat <<EOF > tox.ini [tox] envlist = py310, py311, py312 skipsdist = True [testenv] sitepackages = True passenv = DISPLAY, XAUTHORITY, HOME, XDG_RUNTIME_DIR setenv = PYTHONPATH = {toxinidir}/lib deps = pytest pytest-cov PyHamcrest PyGObject dbus-python python-magic python-xlib pyinotify PyQt5 commands = pytest EOF
- Edit the wayland_checks.py file to prevent the error about f-strings not being allowed to contain a backslashes (pick one):
- If you're using Ubuntu 22.04 LTS:
- Open the lib/autokey/wayland_checks.py file in a text editor.
- Replace this block at the bottom of the file:
with this block:
# Show popup using kdialog, if it's installed, or zenity, otherwise write the # message to autokey.log def __show_popup(title, message): try: subprocess.run(f"kdialog --error '{message}' --title '{title}'", shell=True, check=True) except Exception: try: subprocess.run(f"zenity --error --title='{title}' --text='{message.replace('<br />', '\n')}'", shell=True, check=True) except Exception: logger.critical(message) # For testing purposes if __name__ == '__main__': if not waylandChecks(): print('waylandChecks() returned False')
# Show popup using kdialog, if it's installed, or zenity, otherwise write the # message to autokey.log def __show_popup(title, message): try: subprocess.run(f"kdialog --error '{message}' --title '{title}'", shell=True, check=True) except Exception: try: # Fix: Move the replace call out of the f-string for Python 3.10 compatibility clean_message = message.replace('<br />', '\n') subprocess.run(f"zenity --error --title='{title}' --text='{clean_message}'", shell=True, check=True) except Exception: logger.critical(message) # For testing purposes if __name__ == '__main__': if not waylandChecks(): print('waylandChecks() returned False')
- If you're using Ubuntu 24.04 LTS:
- Skip this step since it's a Python 3.10 fix that breaks the unit tests in Ubuntu 24.04 LTS and will no longer be needed at all once GitHub drops support for Ubuntu 22.04 LTS.
- If you're using Ubuntu 22.04 LTS:
- Install and activate a Python virtual environment to prevent modules needed by AutoKey from being installed to your system:
- Create a new virtual environment that has access to your global system packages:
...or maybe...
python3 -m venv --system-site-packages .venv
python3 -m venv .venv
- Activate the virtual environment (note that your prompt will change to let you know you're in a virtual environment):
source .venv/bin/activate
- Create a new virtual environment that has access to your global system packages:
- Update pip and tox:
python3 -m pip install --upgrade pip tox
- Run the compatibility tests with the coverage option to see which parts of the code were executed for the tests:
- Run the tests:
xvfb-run -a tox run -c setup.cfg -r -e clean,coverage,report
- Or run the tests in verbose mode:
xvfb-run -a tox run -c setup.cfg -r -e clean,coverage,report -- -v
- Or run the tests and output the report (including any errors) to the specified file:
xvfb-run -a tox run -c setup.cfg -r -e clean,coverage,report > tox_output.txt 2>&1
- Or run the tests and output the summary of the report to the specified file:
xvfb-run -a tox run -c setup.cfg -r -e clean,coverage,report && coverage report > tox_summary.txt
- Or run the tests and override the configuration to output the report to the specified JSON file:
xvfb-run -a tox run -c setup.cfg -r -e clean,coverage,report -- --cov-report=json:coverage.json
- Or run the tests and override the configuration to output the report to the specified XML file:
xvfb-run -a tox run -c setup.cfg -r -e clean,coverage,report -- --cov-report=xml:coverage.xml
- Or run the tests and override the configuration to output the report to the specified JSON and XML file:
xvfb-run -a tox run -c setup.cfg -r -e clean,coverage,report -- --cov-report=json:coverage.json --cov-report=xml:coverage.xml
- Or run the tests and output the table part of the summary to the specified file:
xvfb-run -a tox run -c setup.cfg -r -e clean,coverage,report | tee tox_summary.txt
- Run the tests:
- Open the report in the browser:
TARGET_DIR="test_coverage_report_html"; if [ -f "$TARGET_DIR/index.html" ]; then echo "Opening report..."; xdg-open "$TARGET_DIR/index.html"; echo "Press any key to delete the $TARGET_DIR folder..."; read -n 1 -s; rm -rf "$TARGET_DIR"; echo "Report folder deleted"; else echo "Report not found."; fi
- If you created logs that you'd like to reference or share later, copy those logs out of the virtual machine.
- Destroy the virtual machine.
- Create a fresh Ubuntu virtual machine.
- Boot the virtual machine.
- Log in to a Wayland session.
- Update the operating system:
sudo apt update
- Install the core tools:
sudo apt install -y git make build-essential libcairo2-dev python3-pip python3-venv gnome-shell-extension-manager
- Create the
${HOME}/clones/autokeydirectory on your system:mkdir -p ~/clones - Change to the clones directory:
cd ~/clones
- Clone AutoKey (pick one):
- Clone a pull request, replacing 123 with the pull request number:
PR=123; git clone https://github.com/autokey/autokey.git && (cd autokey && git fetch origin pull/$PR/head:pull_$PR && git checkout pull_$PR)
- Clone the current release:
git clone https://github.com/autokey/autokey.git
- Clone the develop branch:
git clone --branch develop --single-branch https://github.com/autokey/autokey.git
- Clone a pull request, replacing 123 with the pull request number:
- Change to the autokey directory:
cd ~/clones/autokey
- Install AutoKey's apt dependencies:
sudo apt install -y $(cat apt-requirements.txt) - Configure your Wayland system to run AutoKey (Xorg users can skip this step):
- Install the AutoKey extension for Gnome:
- Change to the autokey-gnome-extension subdirectory:
cd ~/clones/autokey/autokey-gnome-extension
- Set up the extension:
make
- Install the extension:
gnome-extensions install autokey-gnome-extension@autokey.zip
- Change to the autokey-gnome-extension subdirectory:
- Configure your system to allow members of the input user group to use virtual keyboards and mice:
sudo cp ~/clones/autokey/config/10-autokey.rules /etc/udev/rules.d/ - Add your user account to the input group:
sudo usermod -a -G input $(id -un) - Apply the changes by rebooting:
sudo reboot
- Log back in to a Wayland session.
- Turn on the AutoKey Gnome extension:
gnome-extensions enable autokey-gnome-extension@autokey.shell-extension
- Install the AutoKey extension for Gnome:
- Install the AutoKey icons:
- Make the system directory for icons if it doesn't already exist or let you know that it exists:
mkdir ~/.local/share/icons || echo "Folder already exists!"
- Change to the clones/autokey/config directory:
cd ~/clones/autokey/config
- Copy the icons into the system directory for icons:
cp -vr *.png *.svg Humanity ubuntu-mono-* ~/.local/share/icons/
- Make the system directory for icons if it doesn't already exist or let you know that it exists:
- Change to the clones/autokey directory:
cd ~/clones/autokey
- Install and activate a Python virtual environment to prevent modules needed by AutoKey from being installed to your system:
- Create a new virtual environment that has access to your global system packages:
python3 -m venv --system-site-packages .venv
- Activate the virtual environment (note that your prompt will change to let you know you're in a virtual environment):
source .venv/bin/activate
- Create a new virtual environment that has access to your global system packages:
- Install AutoKey's pip dependencies:
python3 -m pip install -r pip-requirements.txt
- Install Python modules for AutoKey in the virtual environment:
python3 -m pip install packaging pyasyncore evdev
- Run AutoKey from the virtual environment:
- If you're using Wayland in the Gnome desktop environment, enable Assistive Technologies in the Gnome settings.
- Change to the
/libdirectory:cd ~/clones/autokey/lib
- Pick an interface to run:
- Run the GTK interface in verbose mode and with its configuration window open (pick one):
- If you cloned the current release:
python3 -m autokey.gtkui -cl
- If you cloned the develop branch or a pull request:
python3 -m autokey.gtkui -cv
- If you cloned the current release:
- Run the Qt interface in verbose mode and with its configuration window open (pick one):
- If you cloned the current release:
python3 -m autokey.qtui -cl
- If you cloned the develop branch or a pull request:
python3 -m autokey.qtui -cv
- If you cloned the current release:
- Run the GTK interface in verbose mode and with its configuration window open (pick one):
- Try out AutoKey's basic features:
- Check the terminal window for traceback errors.
- Use all of AutoKey's menu entries.
- Go into all of AutoKey's settings to make sure they're accessible and work and that the version is correctly listed.
- Run all of AutoKey's default phrases and scripts from the "play" button in the AutoKey interface.
- Run all of AutoKey's default phrases and scripts from a hotkey.
- Run all of AutoKey's default phrases and scripts from an abbreviation.
- Change each of the settings on a phrase and try each of them out.
- Create and try out a new phrase.
- Create and try out a new script.
- When you're finished trying out AutoKey, close it normally.
- End the virtual environment session, returning your terminal window's prompt to normal:
deactivate
- Run AutoKey again to try the other AutoKey interface (pick one):
- GTK:
# Check if AutoKey is already running and exit if it is: if (pgrep -c autokey > /dev/null); then echo "AutoKey is already running." exit 1 fi source ~/clones/autokey/.venv/bin/activate cd ~/clones/autokey/lib python3 -m autokey.gtkui -c --verbose deactivate
- Qt:
# Check if AutoKey is already running and exit if it is: if (pgrep -c autokey > /dev/null); then echo "AutoKey is already running." exit 1 fi source ~/clones/autokey/.venv/bin/activate cd ~/clones/autokey/lib python3 -m autokey.qtui -c --verbose deactivate
- GTK:
- If you made changes to these steps and took notes, copy your notes out of the virtual machine.
- If you created logs that you'd like to reference or share later, copy those logs out of the virtual machine.
- Destroy the virtual machine.
π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘π‘
Some goodies I can't live without:
- Session type:
echo $XDG_SESSION_TYPE
- Keyboard speed:
- Xorg:
xset r rate 172 85
- Wayland:
gsettings set org.gnome.desktop.peripherals.keyboard delay 172; gsettings set org.gnome.desktop.peripherals.keyboard repeat-interval 11
- Xorg:
- Prevent clipboard staleness under Wayland (pick one):
- Set the primary paste configuration:
gsettings set org.gnome.desktop.interface gtk-enable-primary-paste true
- Force Firefox to use Wayland mode for this terminal window's session:
export MOZ_ENABLE_WAYLAND=1
- Set the primary paste configuration:
- Tidy up by removing all pycache folders and .pyc files recursively after a while of experimenting:
find . -name "__pycache__" -type d -exec rm -rf {} + -o -name "*.pyc" -delete 2>/dev/null
- or:
find . -type d -name "__pycache__" -exec rm -rf {} + -o -name "*.pyc" -del
- or:
- Tidy up between
toxruns:If it still hangs:tox run -c setup.cfg -e clean clear xvfb-run -a tox run -c setup.cfg -r -e clean,coverage,report
tox -r tox run -c setup.cfg -e clean clear xvfb-run -a tox run -c setup.cfg -r -e clean,coverage,report
- Prevent the pycache and .pyc files from being created to begin with by adding the
python3 -Bprefix to the execution command. For example:python3 -B autokey-gtk -cv
- If you have build issues and want to try the build again, tidy up first from within the main root autokey directory:
(cd ~/clones/autokey && fakeroot debian/rules clean) find ~/clones -type d -name "__pycache__" -exec rm -rf {} + rm ~/clones/autokey-* rm ~/clones/autokey_* rm -rf ~/clones/autokey/.pybuild/
- Or do all of that without multiple rm lines:
fakeroot debian/rules clean && rm -rf ../autokey[-_]* ../.pybuild/
- Or do all of that without multiple rm lines:
- Check which files you've changed or deleted (but not files you've added!) in this session:
git diff --name-only
- Kill AutoKey if it's stuck and make sure it's gone:
pkill autokey; sleep 0.5; [[ $(pgrep -c autokey) -eq 0 ]] && echo "β Success: The AutoKey process stopped." || echo "β Error: AutoKey is still running."
- Pip hack: Modern Ubuntu releases (23.04+) will give an "Externally Managed Environment" error when
pipcommands are run outside of a venv. If that happens and, for some reason, you want to run any of the above tests outside of a venv, you can add--break-system-packagesto the end of the pip command. Since you're in a disposable VM for these tests, itβs safe to break the system rules to get the dependencies installed.