mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-03-21 17:09:20 +01:00
committed by
LGUG2Z
parent
58d3086615
commit
7276dc2309
@@ -775,6 +775,9 @@ struct Stop {
|
||||
/// Stop whkd if it is running as a background process
|
||||
#[clap(long)]
|
||||
whkd: bool,
|
||||
/// Stop ahk if it is running as a background process
|
||||
#[clap(long)]
|
||||
ahk: bool,
|
||||
/// Stop komorebi-bar if it is running as a background process
|
||||
#[clap(long)]
|
||||
bar: bool,
|
||||
@@ -2152,6 +2155,35 @@ Stop-Process -Name:komorebi-bar -ErrorAction SilentlyContinue
|
||||
}
|
||||
}
|
||||
|
||||
if arg.ahk {
|
||||
let script = r#"
|
||||
if (Get-Command Get-CimInstance -ErrorAction SilentlyContinue) {
|
||||
(Get-CimInstance Win32_Process | Where-Object {
|
||||
($_.CommandLine -like '*komorebi.ahk"') -and
|
||||
($_.Name -in @('AutoHotkey.exe', 'AutoHotkey64.exe', 'AutoHotkey32.exe'))
|
||||
} | Select-Object -First 1) | ForEach-Object {
|
||||
Stop-Process -Id $_.ProcessId -ErrorAction SilentlyContinue
|
||||
}
|
||||
} else {
|
||||
(Get-WmiObject Win32_Process | Where-Object {
|
||||
($_.CommandLine -like '*komorebi.ahk"') -and
|
||||
($_.Name -in @('AutoHotkey.exe', 'AutoHotkey64.exe', 'AutoHotkey32.exe'))
|
||||
} | Select-Object -First 1) | ForEach-Object {
|
||||
Stop-Process -Id $_.ProcessId -ErrorAction SilentlyContinue
|
||||
}
|
||||
}
|
||||
"#;
|
||||
|
||||
match powershell_script::run(script) {
|
||||
Ok(_) => {
|
||||
println!("{script}");
|
||||
}
|
||||
Err(error) => {
|
||||
println!("Error: {error}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
send_message(&SocketMessage::Stop)?;
|
||||
let mut system = sysinfo::System::new_all();
|
||||
system.refresh_processes(ProcessesToUpdate::All);
|
||||
|
||||
Reference in New Issue
Block a user