Browse Source

remove windows launcher project which has moved to its own repo

pull/2758/head
Jason Dove 7 months ago
parent
commit
bafca7c916
No known key found for this signature in database
  1. 2
      ErsatzTV-Windows/.gitignore
  2. 1035
      ErsatzTV-Windows/Cargo.lock
  3. 20
      ErsatzTV-Windows/Cargo.toml
  4. BIN
      ErsatzTV-Windows/Ersatztv.ico
  5. 6
      ErsatzTV-Windows/build.rs
  6. 2
      ErsatzTV-Windows/ersatztv_windows.rc
  7. 115
      ErsatzTV-Windows/src/main.rs

2
ErsatzTV-Windows/.gitignore vendored

@ -1,2 +0,0 @@ @@ -1,2 +0,0 @@
target/

1035
ErsatzTV-Windows/Cargo.lock generated

File diff suppressed because it is too large Load Diff

20
ErsatzTV-Windows/Cargo.toml

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

BIN
ErsatzTV-Windows/Ersatztv.ico

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

6
ErsatzTV-Windows/build.rs

@ -1,6 +0,0 @@ @@ -1,6 +0,0 @@
use windres::Build;
fn main() {
static_vcruntime::metabuild();
Build::new().compile("ersatztv_windows.rc").unwrap();
}

2
ErsatzTV-Windows/ersatztv_windows.rc

@ -1,2 +0,0 @@ @@ -1,2 +0,0 @@
id ICON "ersatztv.ico"
ersatztv-icon ICON "ersatztv.ico"

115
ErsatzTV-Windows/src/main.rs

@ -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…
Cancel
Save