Conversation
komorebic start/stop/kill matched komorebi.exe (and whkd, komorebi-bar, masir, AutoHotkey) by name alone, system-wide. On a machine with more than one Windows session (RDP, Fast User Switching, a session-0 service instance), an instance running in a different session was indistinguishable from one in the caller's own session: - `start` would report an existing instance in another session as already running and skip launching a new one in the current session. - `stop`/`kill` would count/target processes across all sessions, producing false "still running" force-quit attempts and PowerShell scripts that filtered by name only. Resolve the caller's session id natively (GetCurrentProcessId + ProcessIdToSessionId, mirroring what komorebi's core already does via WindowsApi::process_id_to_session_id) instead of shelling out to PowerShell and parsing its output, and filter every process lookup and generated PowerShell script by that session id. The komorebi.exe startup guard in komorebi/src/main.rs gets the same session filter so a duplicate-instance check only considers processes in the same session. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Support running komorebi in multiple Windows sessions at the same time (e.g, Fast User Switching) without conflicts.
At the moment it is not possible to run Komorebi in two different Windows accounts if both are signed in.
I spotted this because i was trying to setup a new local account, and wasn't able to run the WM when the other user was already running it, but the CLI didn't give me any incling of what was happening. It just saw a process called "komorebi.exe" and assumed it was already running, so it skipped the
startcommand entirely.komorebic start/stop/killmatchedkomorebi.exe(andwhkd,komorebi-bar,masir, AutoHotkey) by process name alone, system-wide. On a machine with more than one Windows session (RDP, Fast User Switching, a session-0 service instance), an instance running in a different session was indistinguishable from one in the caller's own session:startcould report an existing instance in another session as "already running" and skip launching a new one in the current session.stop/killcould count/target processes across all sessions, producing false "still running" force-quit attempts and PowerShell scripts that filtered by name only.GetCurrentProcessId+ProcessIdToSessionId, mirroring what komorebi's core already does viaWindowsApi::process_id_to_session_id) and use thatsession_idin every PS script to filter processes.komorebi.exestartup guard inkomorebi/src/main.rsgets the same session filter so the duplicate-instance check only considers processes in the same session..replaceinstead of aformat!String because doing that would have needed some escaping (braces in particular) in the PowerShell scripts. I thought it might have been more valuable to avoid that, keeping the scripts as close as possible to native PS for readability and debuggability, at the cost of being a bit less idiomatic. It is surely possible to do better there.Test plan
cargo checkandcargo clippypass for bothkomorebiandkomorebickomorebic start/stop/killin a single-session setupI used Devin to find the problems and write up the initial summary of this PR, but most of the code I wrote myself, and of course, I executed the manual tests.