On macOS I currently use hammerspoon to script all kinds of automations. It offers APIs to the clipboard buffer, window placement, and many more (c.f. the API doc).
Most importantly, it offers the possibility to handle keyboard input, which I use to create systemwide modal layers for the keyboard (c.f. example config).
As I consider switching to Ubuntu, I wonder if there is an easy way to hook into the input devices, in order to create my own system-wide modal keyboard layout.
An added bonus would be a set of APIs resembling the ones of hammerspoon for Linux and Gnome.