mirror of https://github.com/ErsatzTV/ErsatzTV.git
Browse Source
* update license * download pre-compiled windows launcher instead of building it with each commit * remove windows launcher project which has moved to its own repopull/2759/head
9 changed files with 7 additions and 1205 deletions
File diff suppressed because it is too large
Load Diff
@ -1,20 +0,0 @@
@@ -1,20 +0,0 @@
|
||||
[package] |
||||
name = "ersatztv_windows" |
||||
version = "0.1.0" |
||||
edition = "2021" |
||||
|
||||
[dependencies] |
||||
tray-item = { git = "https://github.com/olback/tray-item-rs" } |
||||
special-folder = { git = "https://github.com/masinc/special-folder-rs" } |
||||
process_path = "0.1.4" |
||||
|
||||
[dependencies.windows] |
||||
version = "0.43.0" |
||||
features = [ |
||||
"Win32_System_Console", |
||||
"Win32_Foundation" |
||||
] |
||||
|
||||
[build-dependencies] |
||||
windres = "*" |
||||
static_vcruntime = "2.0" |
||||
|
Before Width: | Height: | Size: 15 KiB |
@ -1,6 +0,0 @@
@@ -1,6 +0,0 @@
|
||||
use windres::Build; |
||||
|
||||
fn main() { |
||||
static_vcruntime::metabuild(); |
||||
Build::new().compile("ersatztv_windows.rc").unwrap(); |
||||
} |
||||
@ -1,2 +0,0 @@
@@ -1,2 +0,0 @@
|
||||
id ICON "ersatztv.ico" |
||||
ersatztv-icon ICON "ersatztv.ico" |
||||
@ -1,115 +0,0 @@
@@ -1,115 +0,0 @@
|
||||
#![windows_subsystem = "windows"] |
||||
|
||||
use special_folder::SpecialFolder; |
||||
use std::env; |
||||
use std::fs; |
||||
use std::os::windows::process::CommandExt; |
||||
use std::process::Child; |
||||
use std::process::Command; |
||||
use std::process::Stdio; |
||||
use windows::Win32::System::Console; |
||||
use {std::sync::mpsc, tray_item::TrayItem}; |
||||
|
||||
const CREATE_NO_WINDOW: u32 = 0x08000000; |
||||
|
||||
enum Message { |
||||
Exit, |
||||
} |
||||
|
||||
fn main() { |
||||
let mut tray = TrayItem::new("ErsatzTV", "ersatztv-icon").unwrap(); |
||||
|
||||
let (tx, rx) = mpsc::channel(); |
||||
|
||||
tray.add_menu_item("Launch Web UI", || { |
||||
let ui_port = env::var("ETV_UI_PORT") |
||||
.ok() |
||||
.and_then(|val| val.parse::<u16>().ok()) |
||||
.unwrap_or(8409); |
||||
|
||||
let _ = Command::new("cmd") |
||||
.creation_flags(CREATE_NO_WINDOW) |
||||
.arg("/C") |
||||
.arg("start") |
||||
.arg(format!("http://localhost:{}", ui_port)) |
||||
.stdin(Stdio::null()) |
||||
.stdout(Stdio::null()) |
||||
.stderr(Stdio::null()) |
||||
.spawn(); |
||||
}) |
||||
.unwrap(); |
||||
|
||||
tray.add_menu_item("Show Logs", || { |
||||
let path = SpecialFolder::LocalApplicationData |
||||
.get() |
||||
.unwrap() |
||||
.join("ersatztv") |
||||
.join("logs"); |
||||
match path.to_str() { |
||||
None => {} |
||||
Some(folder) => { |
||||
fs::create_dir_all(folder).unwrap(); |
||||
let _ = Command::new("explorer.exe") |
||||
.arg(folder) |
||||
.stdin(Stdio::null()) |
||||
.stdout(Stdio::null()) |
||||
.stderr(Stdio::null()) |
||||
.spawn(); |
||||
} |
||||
} |
||||
}) |
||||
.unwrap(); |
||||
|
||||
tray.inner_mut().add_separator().unwrap(); |
||||
|
||||
tray.add_menu_item("Exit", move || { |
||||
tx.send(Message::Exit).unwrap(); |
||||
}) |
||||
.unwrap(); |
||||
|
||||
let path = process_path::get_executable_path(); |
||||
let mut child: Option<Child> = None; |
||||
match path { |
||||
None => {} |
||||
Some(path) => { |
||||
let etv = path.parent().unwrap().join("ErsatzTV.exe"); |
||||
if etv.exists() { |
||||
match etv.to_str() { |
||||
None => {} |
||||
Some(etv) => { |
||||
child = Some( |
||||
Command::new(etv) |
||||
.creation_flags(CREATE_NO_WINDOW) |
||||
.stdin(Stdio::null()) |
||||
.stdout(Stdio::null()) |
||||
.stderr(Stdio::null()) |
||||
.spawn() |
||||
.unwrap(), |
||||
); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
loop { |
||||
match rx.recv() { |
||||
Ok(Message::Exit) => { |
||||
match child { |
||||
None => {} |
||||
Some(mut child) => { |
||||
unsafe { |
||||
if Console::AttachConsole(child.id()) == true |
||||
{ |
||||
Console::GenerateConsoleCtrlEvent(Console::CTRL_C_EVENT, 0); |
||||
} |
||||
} |
||||
child.wait().unwrap(); |
||||
} |
||||
} |
||||
break; |
||||
} |
||||
_ => {} |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue