Skip to content

Commit

Permalink
fix: ensure single_instance works
Browse files Browse the repository at this point in the history
  • Loading branch information
donovanglover committed Feb 1, 2025
1 parent f5f3f34 commit 5cc480b
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/ui/single_instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@ use single_instance::SingleInstance;
use std::process;

pub fn single_instance() {
let instance = SingleInstance::new("hyprdim").unwrap();
let instance = Box::new(SingleInstance::new("hyprdim").unwrap());

// Don't allow more than one hyprdim instance to run
if !instance.is_single() {
println!(
"hyprdim is already running. Use `killall hyprdim` to stop any existing processes."
);
if instance.is_single() {
Box::leak(instance);

process::exit(1);
};
log("hyprdim is now running.");

log("hyprdim is now running.");
return;
}

println!(
"hyprdim is already running. Use `killall hyprdim` to stop any existing processes."
);

process::exit(1);
}

0 comments on commit 5cc480b

Please sign in to comment.