mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-04-24 17:48:34 +02:00
fix(cli): use force-quit if stop signal fails
This commit ensures that the komorebic stop command will force-quit komorebi if the Stop SocketMessage handler fails.
This commit is contained in:
@@ -17,6 +17,7 @@ dunce = "1"
|
|||||||
dirs = "5"
|
dirs = "5"
|
||||||
color-eyre = "0.6"
|
color-eyre = "0.6"
|
||||||
serde_json = { package = "serde_json_lenient", version = "0.1" }
|
serde_json = { package = "serde_json_lenient", version = "0.1" }
|
||||||
|
sysinfo = "0.30"
|
||||||
|
|
||||||
[workspace.dependencies.windows]
|
[workspace.dependencies.windows]
|
||||||
version = "0.54"
|
version = "0.54"
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ schemars = "0.8"
|
|||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
serde_json = { workspace = true }
|
serde_json = { workspace = true }
|
||||||
strum = { version = "0.26", features = ["derive"] }
|
strum = { version = "0.26", features = ["derive"] }
|
||||||
sysinfo = "0.30"
|
sysinfo = { workspace = true }
|
||||||
tracing = "0.1"
|
tracing = "0.1"
|
||||||
tracing-appender = "0.2"
|
tracing-appender = "0.2"
|
||||||
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
||||||
|
|||||||
@@ -727,7 +727,7 @@ impl StaticConfig {
|
|||||||
|
|
||||||
value.apply_globals()?;
|
value.apply_globals()?;
|
||||||
|
|
||||||
let stackbar_mode = STACKBAR_MODE.lock().clone();
|
let stackbar_mode = *STACKBAR_MODE.lock();
|
||||||
|
|
||||||
for m in wm.monitors_mut() {
|
for m in wm.monitors_mut() {
|
||||||
for w in m.workspaces_mut() {
|
for w in m.workspaces_mut() {
|
||||||
|
|||||||
@@ -327,10 +327,13 @@ impl Workspace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Some(stackbar) = container_topbar {
|
if let Some(stackbar) = container_topbar {
|
||||||
if let Ok(_) = stackbar.set_position(
|
if stackbar
|
||||||
&stackbar.get_position_from_container_layout(layout),
|
.set_position(
|
||||||
false,
|
&stackbar.get_position_from_container_layout(layout),
|
||||||
) {
|
false,
|
||||||
|
)
|
||||||
|
.is_ok()
|
||||||
|
{
|
||||||
stackbar.update(&container_windows, focused_hwnd)?;
|
stackbar.update(&container_windows, focused_hwnd)?;
|
||||||
let tab_height = STACKBAR_TAB_HEIGHT.load(Ordering::SeqCst);
|
let tab_height = STACKBAR_TAB_HEIGHT.load(Ordering::SeqCst);
|
||||||
let total_height = tab_height + container_padding;
|
let total_height = tab_height + container_padding;
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ reqwest = { version = "0.12", features = ["blocking"] }
|
|||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
serde_json = { workspace = true }
|
serde_json = { workspace = true }
|
||||||
serde_yaml = "0.9"
|
serde_yaml = "0.9"
|
||||||
sysinfo = "0.30"
|
sysinfo = { workspace = true }
|
||||||
thiserror = "1"
|
thiserror = "1"
|
||||||
uds_windows = "1"
|
uds_windows = "1"
|
||||||
which = "6"
|
which = "6"
|
||||||
|
|||||||
@@ -1897,6 +1897,34 @@ Stop-Process -Name:whkd -ErrorAction SilentlyContinue
|
|||||||
}
|
}
|
||||||
|
|
||||||
send_message(&SocketMessage::Stop.as_bytes()?)?;
|
send_message(&SocketMessage::Stop.as_bytes()?)?;
|
||||||
|
let mut system = sysinfo::System::new_all();
|
||||||
|
system.refresh_processes();
|
||||||
|
|
||||||
|
if system.processes_by_name("komorebi.exe").count() >= 1 {
|
||||||
|
println!("komorebi is still running, attempting to force-quit");
|
||||||
|
|
||||||
|
let script = r"
|
||||||
|
Stop-Process -Name:komorebi -ErrorAction SilentlyContinue
|
||||||
|
";
|
||||||
|
match powershell_script::run(script) {
|
||||||
|
Ok(_) => {
|
||||||
|
println!("{script}");
|
||||||
|
|
||||||
|
let hwnd_json = DATA_DIR.join("komorebi.hwnd.json");
|
||||||
|
|
||||||
|
let file = File::open(hwnd_json)?;
|
||||||
|
let reader = BufReader::new(file);
|
||||||
|
let hwnds: Vec<isize> = serde_json::from_reader(reader)?;
|
||||||
|
|
||||||
|
for hwnd in hwnds {
|
||||||
|
restore_window(HWND(hwnd));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(error) => {
|
||||||
|
println!("Error: {error}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
SubCommand::FloatRule(arg) => {
|
SubCommand::FloatRule(arg) => {
|
||||||
send_message(&SocketMessage::FloatRule(arg.identifier, arg.id).as_bytes()?)?;
|
send_message(&SocketMessage::FloatRule(arg.identifier, arg.id).as_bytes()?)?;
|
||||||
|
|||||||
Reference in New Issue
Block a user