phil294 / AHK_X11

AutoHotkey for Linux (X11-based systems)
GNU General Public License v2.0
815 stars 15 forks source link

create user service on ubuntu #57

Closed comsyspro closed 1 year ago

comsyspro commented 1 year ago

i want to create a system service where the my_ahk_script.ahk is executed. but ahk_x11 command blocks because it opens a terminal and waits there. is it possible to run my_ahk_script.ahk so it does not block with the ahk_x11 terminal? or is it possible to run a *.ahk script from commandline without entering the ahk_x11 terminal?

[Unit]
Description = start default service
After = network-online.target
Wants = network-online.target

[Service]
Type = oneshot
RemainAfterExit = no
ExecStart = /home/username/ahk_x11 /home/username/my_ahk_script.ahk
ExecStart = /usr/bin/python3 /home/username/my_python_script.py

[Install]
WantedBy = multi-user.target
phil294 commented 1 year ago

As far as I'm aware, this is not stdin blocking but your script simply being "persistent". This logic is 1:1 as it behaves on Windows: Guis, #persistent, hotkeys and hotstrings make a script run forever (also cli option --repl). In this case, you can just put an ExitApp at the appropriate location. See also: The Auto-execute Section. Non-persistent scripts also never go into interactive REPL-mode.

You should be able to verify that by putting only a simple non-persistent command into your script, such as MsgBox, then this will work as expected.

comsyspro commented 1 year ago

i solved it now by creating 2 sepearte services for each ExecStart entry as ExecStart = /home/username/ahk_x11 /home/username/my_ahk_script.ahk blocks the execution of the second ExecStart = /usr/bin/python3 /home/username/my_python_script.py