Skip to content

Commit

Permalink
limit planif build to windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Misieq01 committed Dec 11, 2024
1 parent feff64f commit 106d0a8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ xz2 = { version = "0.1.7", features = ["static"] } # static bind lzma
zip = "2.2.0"
dirs = "5.0.1"
tauri-plugin-process = "2"
planif = "1.0.0"
whoami = "1.5.2"

[target.'cfg(windows)'.dependencies]
planif = "1.0.0"
whoami = "1.5.2"
winreg = "0.52.0"

# needed for keymanager. TODO: Find a way of creating a keymanager without bundling sqlite
Expand Down
8 changes: 7 additions & 1 deletion src-tauri/src/auto_launcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@ use anyhow::anyhow;
use auto_launch::{AutoLaunch, AutoLaunchBuilder};
use dunce::canonicalize;
use log::{info, warn};
#[cfg(target_os = "windows")]
use planif::{
enums::TaskCreationFlags,
schedule::TaskScheduler,
schedule_builder::{Action, ScheduleBuilder},
settings::{LogonType, PrincipalSettings, RunLevel, Settings},
};
#[cfg(target_os = "windows")]
use whoami::username;
use tauri::utils::platform::current_exe;
use tokio::sync::RwLock;
use whoami::username;

use crate::utils::platform_utils::{CurrentOperatingSystem, PlatformUtils};

Expand Down Expand Up @@ -103,6 +105,7 @@ impl AutoLauncher {
CurrentOperatingSystem::Windows => {
auto_launcher.enable()?;
// To startup application as admin on windows, we need to create a task scheduler
#[cfg(target_os = "windows")]
self.toggle_windows_admin_auto_launcher(is_auto_launcher_enabled)
.await?;
}
Expand All @@ -117,6 +120,7 @@ impl AutoLauncher {
info!(target: LOG_TARGET, "Disabling auto-launcher");
match PlatformUtils::detect_current_os() {
CurrentOperatingSystem::Windows => {
#[cfg(target_os = "windows")]
self.toggle_windows_admin_auto_launcher(is_auto_launcher_enabled)
.await?;
auto_launcher.disable()?;
Expand All @@ -130,6 +134,7 @@ impl AutoLauncher {
Ok(())
}

#[cfg(target_os = "windows")]
async fn toggle_windows_admin_auto_launcher(
&self,
config_is_auto_launcher_enabled: bool,
Expand All @@ -151,6 +156,7 @@ impl AutoLauncher {
Ok(())
}

#[cfg(target_os = "windows")]
pub async fn create_task_scheduler_for_admin_startup(
&self,
is_triggered: bool,
Expand Down

0 comments on commit 106d0a8

Please sign in to comment.