mirror of
https://github.com/house-of-vanity/swkb.git
synced 2025-07-07 19:24:07 +00:00
only allow one instance
This commit is contained in:
44
Cargo.lock
generated
44
Cargo.lock
generated
@ -157,6 +157,18 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "single-instance"
|
||||||
|
version = "0.1.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e5cf81b17aaa439345566aff22f4e0c11a50c265f6d5589ab693e40913326385"
|
||||||
|
dependencies = [
|
||||||
|
"failure",
|
||||||
|
"libc",
|
||||||
|
"widestring",
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "swayipc"
|
name = "swayipc"
|
||||||
version = "2.7.0"
|
version = "2.7.0"
|
||||||
@ -173,9 +185,7 @@ dependencies = [
|
|||||||
name = "swkb"
|
name = "swkb"
|
||||||
version = "0.2.4"
|
version = "0.2.4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"failure",
|
"single-instance",
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
"swayipc",
|
"swayipc",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -207,3 +217,31 @@ name = "unicode-xid"
|
|||||||
version = "0.2.1"
|
version = "0.2.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
|
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "widestring"
|
||||||
|
version = "0.2.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7157704c2e12e3d2189c507b7482c52820a16dfa4465ba91add92f266667cadb"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi"
|
||||||
|
version = "0.3.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||||
|
dependencies = [
|
||||||
|
"winapi-i686-pc-windows-gnu",
|
||||||
|
"winapi-x86_64-pc-windows-gnu",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi-i686-pc-windows-gnu"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "winapi-x86_64-pc-windows-gnu"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||||
|
@ -7,13 +7,8 @@ edition = "2018"
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
|
||||||
serde_json = "1.0"
|
|
||||||
failure = "0.1"
|
|
||||||
swayipc = {version = "2.7.0", features = [ "event_stream"]}
|
swayipc = {version = "2.7.0", features = [ "event_stream"]}
|
||||||
|
single-instance = "0.1.2"
|
||||||
#[dependencies.swayipc]
|
|
||||||
#features = ["async", "event_stream"]
|
|
||||||
|
|
||||||
[packaging]
|
[packaging]
|
||||||
depends = ["sway"]
|
depends = ["sway"]
|
||||||
|
@ -16,6 +16,11 @@ fn get_input_id(c: &mut Connection) -> Vec<String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> Fallible<()> {
|
fn main() -> Fallible<()> {
|
||||||
|
let instance_a = single_instance::SingleInstance::new("whatever").unwrap();
|
||||||
|
if !instance_a.is_single() {
|
||||||
|
println!("only one instance of swkb at a time is allowed");
|
||||||
|
std::process::exit(1);
|
||||||
|
}
|
||||||
let mut connection = Connection::new()?;
|
let mut connection = Connection::new()?;
|
||||||
let inputs = get_input_id(&mut connection);
|
let inputs = get_input_id(&mut connection);
|
||||||
let mut layouts: HashMap<i64, i64> = HashMap::new();
|
let mut layouts: HashMap<i64, i64> = HashMap::new();
|
||||||
|
Reference in New Issue
Block a user