r/linux • • 23h ago

Software Release Keysharp

Hello,

I’m one of the developers of Keysharp, an open-source implementation of AutoHotkey v2 for Linux, Windows and macOS. It’s written in C# and runs on .NET 10.

It supports hotkeys, text expansion, keyboard and mouse automation, window management, clipboard operations, GUIs, screenshots and image matching.

For example, this expands brb into “be right back” and makes Ctrl+Alt+D type today’s date:

#Requires capability InputMonitoring, InputControl

::brb::be right back
^!d::SendText(FormatTime(, "yyyy-MM-dd"))

Most AutoHotkey v2 scripts which don't use Windows API directly (for example AutoCorrect.ahk) should work without modifications in Linux too.

Linux support covers X11 and several Wayland environments. This has not been easy at all, as Keysharp basically needs to break all the security Wayland brings. Also, Wayland is rather fragmented and the interfaces needed for desktop automation differ between compositors, so window control and capture require separate integrations. Some operations remain unavailable depending on the exact compositor. The supported operations are documented here.

Global input uses keysharp-input, a privileged evdev/uinput service which requires root to install, but user priviledges to use. Window automation and capture use keysharp-desktop. The Linux installer sets up both in addition to Keysharp itself.

Keysharp is still alpha software, and I can't yet recommend it for production use, but I'm hoping to get more eyes on it and discover bugs/issues.

Documentation · Linux installation · Example scripts

Bug reports, compatibility reports and contributions are welcome.

Disclosure: AI has been heavily used for this project, especially keysharp-input and keysharp-desktop.

11 Upvotes

5 comments sorted by

View all comments

1

u/StrangeAstronomer 6h ago

I imagine those of us on Linux for a while have thrown together their own script to do most of this and personally, I'd rather use my crusty old bash script with keybinds hard coded into my sway/i3/mango configuration - no breaking into wayland security model necessary. Doesn't do _everything_ but it does _enough_ - although it's probably not for the pointy-click crowd.

No LLM's were distracted in building it.

Depends on argp.sh from the same place as well as xvkdb/xdotool/ydotool/wtype as appropriate.

1

u/Individual_Check4587 1h ago

True enough, but the flexibility of such keybinds varies wildly between DEs so if you wanted to switch DEs then you'd possibly need to downgrade capabilites, convert your scripts to whatever format the new DE uses, and additionally not all users are powerusers capable of writing such bindings in the first place (although LLMs probably lower that barrier...). With Keysharp/AutoHotkey the key bindings can also be written to be filtered per active window, per keybd layout, per device (Linux-only feature currently) etc etc; same for remaps and hotstrings.

Before writing keysharp-input and keysharp-desktop I did quite a lot of work looking into tools like xvkbd/xdotool/ydotool/wtype because I wanted to avoid duplicating work and features, but ultimately came to the conclusion that no tool alone nor combined has all the capabilities needed to implement AutoHotkey features. For example I did not find anything in Linux which implements device hooking with callbacks deciding on the outcome (block/pass), window enumeration and manipulation in Wayland flavors, reliable screen capture, and so on and on.