···11+diff --git a/Makefile b/Makefile
22+index 8b54a8b..6522293 100644
33+--- a/Makefile
44++++ b/Makefile
55+@@ -60,7 +60,6 @@ xdotool/libxdo.a: xdotool/.git
66+ $(MAKE) -C xdotool libxdo.a
77+88+ lib/configured:
99+- shards install --frozen
1010+ ./bin/gi-crystal
1111+ # TODO: can be fixed in application code?
1212+ sed -i -E 's/private getter xdo_p/getter xdo_p/' lib/x_do/src/x_do.cr
1313+@@ -71,7 +70,7 @@ lib/configured:
1414+ test-appimage: ahk_x11.AppImage
1515+ ./ahk_x11.AppImage tests.ahk
1616+ test-dev: bin/ahk_x11
1717+- ./bin/ahk_x11 tests.ahk
1818++ XDG_CACHE_HOME=${TMPDIR} HOME=${TMPDIR} xvfb-run --auto-display openbox --startup "./bin/ahk_x11 tests.ahk"
1919+2020+ clean:
2121+ rm -rf ahk_x11.AppImage bin/ahk_x11 bin/ahk_x11.dev linuxdeploy-plugin-gtk.sh linuxdeploy-x86_64.AppImage lib
2222+diff --git a/src/ahk_x11.cr b/src/ahk_x11.cr
2323+index 16777d8..b4d96e1 100644
2424+--- a/src/ahk_x11.cr
2525++++ b/src/ahk_x11.cr
2626+@@ -67,14 +67,12 @@ version = {{ read_file("./shard.yml").split("\n")[1][9..] }}
2727+ lines = Compiler.new.extract.try &.split('\n')
2828+ is_compiled = !! lines
2929+ if ! lines
3030+- # Only needed for installer script, this can't (yet) really be part of ahk code. TODO: rm on exit
3131+- File.write("/tmp/tmp_ahk_x11_logo.png", logo_blob)
3232+ if ARGV[0]?
3333+ if ARGV[0] == "-v" || ARGV[0] == "--version"
3434+ puts "AHK_X11 version: #{version}\nTargets to partially implement Classic Windows AutoHotkey specification: v1.0.24 (2004). AutoHotkey is a scripting language."
3535+ ::exit
3636+ elsif ARGV[0] == "-h" || ARGV[0] == "--help"
3737+- puts "AHK_X11 is a Linux implementation for AutoHotkey classic version 1.0.24 (2004). Internal version: #{version}. Full up to date documentation can be found at https://phil294.github.io/AHK_X11/.\n\nPossible methods of invocation:\n\nahk_x11.AppImage \"path to script.ahk\"\nahk_x11.AppImage <<< $'MsgBox, 1\\nMsgBox, 2'\nahk_x11.AppImage --repl\nahk_x11.AppImage --windowspy\nahk_x11.AppImage --compile \"path to script.ahk\" \"optional: output executable file path\"\n\nAlternatively, just run the program without arguments to open the graphical installer. Once installed, you should be able to run and/or compile any .ahk file in your file manager by selecting it from the right click context menu."
3838++ puts "AHK_X11 is a Linux implementation for AutoHotkey classic version 1.0.24 (2004). Internal version: #{version}. Full up to date documentation can be found at https://phil294.github.io/AHK_X11/.\n\nPossible methods of invocation:\n\nahk_x11 \"path to script.ahk\"\nahk_x11 <<< $'MsgBox, 1\\nMsgBox, 2'\nahk_x11 --repl\nahk_x11 --windowspy\nahk_x11 --compile \"path to script.ahk\" \"optional: output executable file path\"\n\nAlternatively, you should be able to run and/or compile any .ahk file in your file manager by selecting it from the right click context menu."
3939+ ::exit
4040+ elsif ARGV[0] == "--repl"
4141+ lines = ["#Persistent"]
4242+@@ -101,7 +99,8 @@ if ! lines
4343+ if stdin
4444+ lines = stdin.split('\n')
4545+ else
4646+- lines = {{ read_file("./src/installer.ahk").split("\n") }}
4747++ puts "Use -h for help."
4848++ ::exit 1
4949+ end
5050+ end
5151+ end
5252+@@ -120,4 +119,4 @@ rescue e : Run::RuntimeException
5353+ build_error e
5454+ end
5555+5656+-sleep # exiting is completely handled in runner
5757+\ No newline at end of file
5858++sleep # exiting is completely handled in runner
+112
pkgs/by-name/ah/ahk_x11/package.nix
···11+{
22+ lib,
33+ stdenv,
44+ fetchFromGitHub,
55+ crystal,
66+ copyDesktopItems,
77+ linkFarm,
88+ fetchgit,
99+1010+ gtk3,
1111+ libxkbcommon,
1212+ xorg,
1313+ libnotify,
1414+ gobject-introspection, # needed to build gi-crystal
1515+ openbox,
1616+ xvfb-run,
1717+ xdotool,
1818+1919+ buildDevTarget ? false, # the dev version prints debug info
2020+}:
2121+2222+# NOTICE: AHK_X11 from this package does not support compiling scripts into portable executables.
2323+let
2424+ pname = "ahk_x11";
2525+ version = "1.0.4";
2626+2727+ inherit (xorg)
2828+ libXinerama
2929+ libXtst
3030+ libXext
3131+ libXi
3232+ ;
3333+3434+in
3535+crystal.buildCrystalPackage {
3636+ inherit pname version;
3737+3838+ src = fetchFromGitHub {
3939+ owner = "phil294";
4040+ repo = "AHK_X11";
4141+ rev = version;
4242+ hash = "sha256-Kxe0tLbER1XFnnfUUIiy9CgCgz2qK21AIk4DfHymKlI=";
4343+ fetchSubmodules = true;
4444+ };
4545+4646+ # Fix build problems and the following UX problem:
4747+ # Without this patch, the binary launches a graphical installer GUI that is useless with system-wide installation.
4848+ # With this patch, it prompts to use -h for help.
4949+ patches = [ ./adjust.patch ];
5050+5151+ shardsFile = ./shards.nix;
5252+ copyShardDeps = true;
5353+5454+ preBuild = ''
5555+ mkdir bin
5656+ cd lib/gi-crystal
5757+ shards build -Dpreview_mt --release --no-debug
5858+ cd ../..
5959+ cp lib/gi-crystal/bin/gi-crystal bin
6060+ '';
6161+6262+ postBuild = lib.optionalString buildDevTarget ''
6363+ mv bin/ahk_x11.dev bin/ahk_x11
6464+ '';
6565+6666+ preInstall = ''
6767+ mkdir -p $out/bin
6868+ '';
6969+7070+ postInstall = ''
7171+ install -Dm644 -t $out/share/licenses/ahk_x11/ LICENSE
7272+ install -Dm644 -t $out/share/pixmaps/ assets/ahk_x11.png
7373+ install -Dm644 -t $out/share/applications/ assets/*.desktop
7474+ install -Dm644 assets/ahk_x11-mime.xml $out/share/mime/packages/ahk_x11.xml
7575+ '';
7676+7777+ buildInputs = [
7878+ gtk3
7979+ libxkbcommon
8080+ libXinerama
8181+ libXtst
8282+ libXext
8383+ libXi
8484+ libnotify
8585+ ];
8686+ nativeBuildInputs = [
8787+ copyDesktopItems
8888+ gobject-introspection
8989+ ];
9090+ nativeCheckInputs = [
9191+ xvfb-run
9292+ openbox
9393+ xdotool
9494+ ];
9595+9696+ buildTargets = if buildDevTarget then "bin/ahk_x11.dev" else "bin/ahk_x11";
9797+ checkTarget = "test-dev";
9898+9999+ # The tests fail with AtSpi failure. This means it lacks assistive technologies:
100100+ # https://github.com/phil294/AHK_X11?tab=readme-ov-file#accessibility
101101+ # I don't know how to fix it for xvfb and openbox.
102102+ doCheck = false;
103103+104104+ meta = {
105105+ description = "AutoHotkey for X11";
106106+ homepage = "https://phil294.github.io/AHK_X11";
107107+ license = lib.licenses.gpl2Plus;
108108+ maintainers = with lib.maintainers; [ ulysseszhan ];
109109+ platforms = lib.platforms.linux;
110110+ mainProgram = "ahk_x11";
111111+ };
112112+}