diff --git a/Cargo.lock b/Cargo.lock index ca6e94f..04221fd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -124,6 +124,12 @@ dependencies = [ "target-lexicon", ] +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + [[package]] name = "concurrent-queue" version = "2.4.0" @@ -203,7 +209,7 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38e2275cc4e4fc009b0669731a1e5ab7ebf11f469eaede2bab9309a5b4d6057f" dependencies = [ - "memoffset", + "memoffset 0.9.0", "rustc_version", ] @@ -720,6 +726,15 @@ version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" +[[package]] +name = "memoffset" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + [[package]] name = "memoffset" version = "0.9.0" @@ -729,6 +744,19 @@ dependencies = [ "autocfg", ] +[[package]] +name = "nix" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f3790c00a0150112de0f4cd161e3d7fc4b2d8a5542ffc35f099a2562aecb35c" +dependencies = [ + "bitflags 1.3.2", + "cc", + "cfg-if", + "libc", + "memoffset 0.6.5", +] + [[package]] name = "normpath" version = "1.2.0" @@ -826,6 +854,7 @@ dependencies = [ "os_pipe", "regex", "rust-i18n", + "single-instance", "user", "users", ] @@ -1082,6 +1111,19 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "single-instance" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4637485391f8545c9d3dbf60f9d9aab27a90c789a700999677583bcb17c8795d" +dependencies = [ + "libc", + "nix", + "thiserror", + "widestring", + "winapi 0.3.9", +] + [[package]] name = "slab" version = "0.4.9" @@ -1288,6 +1330,12 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "widestring" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c168940144dd21fd8046987c16a46a33d5fc84eec29ef9dcddc2ac9e31526b7c" + [[package]] name = "winapi" version = "0.1.23" diff --git a/Cargo.toml b/Cargo.toml index daef257..4573f78 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,3 +16,4 @@ os_pipe = "1.1.5" user = "0.1.1" users = "0.11.0" rust-i18n = "3.0.1" +single-instance = "0.3.3" diff --git a/data/com.github.pikaos-linux.pikawelcome.desktop b/data/com.github.pikaos-linux.pikawelcome.desktop index 8adce08..fc5aea4 100644 --- a/data/com.github.pikaos-linux.pikawelcome.desktop +++ b/data/com.github.pikaos-linux.pikawelcome.desktop @@ -1,11 +1,8 @@ [Desktop Entry] Type=Application -Name=PikaOS Initial User Setup +Name=Welcome to PikaOS Exec=pika-welcome Hidden=false -NoDisplay=true Icon=com.github.pikaos-linux.pikawelcome -X-GNOME-Autostart-enabled=true -X-KDE-AutostartScript=true Categories=GNOME;GTK;Utility; Keywords=Gnome;GTK \ No newline at end of file diff --git a/data/pika-welcome-autostart.desktop b/data/pika-welcome-autostart.desktop new file mode 100644 index 0000000..03f0562 --- /dev/null +++ b/data/pika-welcome-autostart.desktop @@ -0,0 +1,12 @@ +[Desktop Entry] +Type=Application +Name=Welcome to PikaOS +Exec=pika-welcome-autostart +Hidden=true +Icon=com.github.pikaos-linux.pikawelcome +Categories=GNOME;GTK;Utility; +Keywords=Gnome;GTK +NoDisplay=true +X-GNOME-Autostart-enabled=true +X-KDE-AutostartScript=true +AutostartCondition=GSettings com.github.pikaos-linux.pikawelcome startup-show \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 3e5c176..b4ec14f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,6 +8,7 @@ use gdk::Display; /// Use all gtk4 libraries (gtk4 -> gtk because cargo) /// Use all libadwaita libraries (libadwaita -> adw because cargo) use gtk::*; +use single_instance::SingleInstance; use std::boxed::Box; use users::*; @@ -49,6 +50,9 @@ fn main() { app.connect_activate(build_ui); }); + let instance = SingleInstance::new(APP_ID).unwrap(); + assert!(instance.is_single()); + if get_current_username().unwrap() != "pikaos" { application.run(); } else {