Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for steam:// and .lnk #34

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Loxtir
Copy link
Contributor

@Loxtir Loxtir commented Sep 7, 2024

Aims to implement #21, I totally get it if you reject it tho haha.
The whole process is a pain in the ass.

First, the only way I found to get the PID of the process started with cmd is through executing tasklist and filtering for its name. Problem? When you launch a .lnk or use the steam protocol, the name that appears on tasklist is the .exe name. So I had to add "exe_name" as a new field in the config file.

Second, what if you have another instance of that process running before? So I had to check before creating the new process, store the previous PIDs and compare after.

Third, launching with steam:// takes a while, sometimes up to 15s in my computer. This means the new process isn't created until that, so I had to delay the PID search, that's why there's retries in on_timer_timeout().
Last, there's no way I found to get the exit code of a process spawned this way, so relaunching on crash is impossible unless we only allow closing the app through the launcher.

I tested it with a steam game, a .lnk and a regular game and everything seems to work OK.

PD: in theory, execute_with_pipe() gives you access to the stdio of the cmd it opens, but I wasn't able to read or write anything from/to it. Since it's non blocking, my idea was to wait the process by passing /wait, and then echo the %ERRORLEVEL% since it that gives the exit code of the previous process spawned by a cmd. Ideas/contributions are welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant