Instance control

This commit is contained in:
Ward from fusion-voyager-3 2024-02-24 00:46:01 +03:00
parent 5348a68802
commit cfee89e952
5 changed files with 67 additions and 5 deletions

50
Cargo.lock generated
View File

@ -124,6 +124,12 @@ dependencies = [
"target-lexicon", "target-lexicon",
] ]
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]] [[package]]
name = "concurrent-queue" name = "concurrent-queue"
version = "2.4.0" version = "2.4.0"
@ -203,7 +209,7 @@ version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38e2275cc4e4fc009b0669731a1e5ab7ebf11f469eaede2bab9309a5b4d6057f" checksum = "38e2275cc4e4fc009b0669731a1e5ab7ebf11f469eaede2bab9309a5b4d6057f"
dependencies = [ dependencies = [
"memoffset", "memoffset 0.9.0",
"rustc_version", "rustc_version",
] ]
@ -720,6 +726,15 @@ version = "2.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149"
[[package]]
name = "memoffset"
version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce"
dependencies = [
"autocfg",
]
[[package]] [[package]]
name = "memoffset" name = "memoffset"
version = "0.9.0" version = "0.9.0"
@ -729,6 +744,19 @@ dependencies = [
"autocfg", "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]] [[package]]
name = "normpath" name = "normpath"
version = "1.2.0" version = "1.2.0"
@ -826,6 +854,7 @@ dependencies = [
"os_pipe", "os_pipe",
"regex", "regex",
"rust-i18n", "rust-i18n",
"single-instance",
"user", "user",
"users", "users",
] ]
@ -1082,6 +1111,19 @@ dependencies = [
"winapi 0.3.9", "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]] [[package]]
name = "slab" name = "slab"
version = "0.4.9" version = "0.4.9"
@ -1288,6 +1330,12 @@ dependencies = [
"winapi-util", "winapi-util",
] ]
[[package]]
name = "widestring"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c168940144dd21fd8046987c16a46a33d5fc84eec29ef9dcddc2ac9e31526b7c"
[[package]] [[package]]
name = "winapi" name = "winapi"
version = "0.1.23" version = "0.1.23"

View File

@ -16,3 +16,4 @@ os_pipe = "1.1.5"
user = "0.1.1" user = "0.1.1"
users = "0.11.0" users = "0.11.0"
rust-i18n = "3.0.1" rust-i18n = "3.0.1"
single-instance = "0.3.3"

View File

@ -1,11 +1,8 @@
[Desktop Entry] [Desktop Entry]
Type=Application Type=Application
Name=PikaOS Initial User Setup Name=Welcome to PikaOS
Exec=pika-welcome Exec=pika-welcome
Hidden=false Hidden=false
NoDisplay=true
Icon=com.github.pikaos-linux.pikawelcome Icon=com.github.pikaos-linux.pikawelcome
X-GNOME-Autostart-enabled=true
X-KDE-AutostartScript=true
Categories=GNOME;GTK;Utility; Categories=GNOME;GTK;Utility;
Keywords=Gnome;GTK Keywords=Gnome;GTK

View File

@ -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

View File

@ -8,6 +8,7 @@ use gdk::Display;
/// Use all gtk4 libraries (gtk4 -> gtk because cargo) /// Use all gtk4 libraries (gtk4 -> gtk because cargo)
/// Use all libadwaita libraries (libadwaita -> adw because cargo) /// Use all libadwaita libraries (libadwaita -> adw because cargo)
use gtk::*; use gtk::*;
use single_instance::SingleInstance;
use std::boxed::Box; use std::boxed::Box;
use users::*; use users::*;
@ -49,6 +50,9 @@ fn main() {
app.connect_activate(build_ui); app.connect_activate(build_ui);
}); });
let instance = SingleInstance::new(APP_ID).unwrap();
assert!(instance.is_single());
if get_current_username().unwrap() != "pikaos" { if get_current_username().unwrap() != "pikaos" {
application.run(); application.run();
} else { } else {