diff --git a/apps/desktop/src-tauri/icons/icon.ico b/apps/desktop/src-tauri/icons/icon.ico new file mode 100644 index 0000000..f9c68a9 Binary files /dev/null and b/apps/desktop/src-tauri/icons/icon.ico differ diff --git a/apps/desktop/src-tauri/src/main.rs b/apps/desktop/src-tauri/src/main.rs index a3fbc15..fa12430 100644 --- a/apps/desktop/src-tauri/src/main.rs +++ b/apps/desktop/src-tauri/src/main.rs @@ -272,7 +272,9 @@ fn main() { let host = tauri::async_runtime::block_on(Host::new(Config { version: env!("CARGO_PKG_VERSION").into(), - viewer_dir: std::env::var_os("RUSTSCREEN_VIEWER").map(PathBuf::from), + viewer_dir: std::env::var_os("RUSTSCREEN_VIEWER") + .map(PathBuf::from) + .or_else(rs_session::installed_viewer), tls: false, store: rs_store::Store::user_default(), overrides: Overrides::default(), diff --git a/apps/desktop/src-tauri/tauri.conf.json b/apps/desktop/src-tauri/tauri.conf.json index 3c35ec0..5789f64 100644 --- a/apps/desktop/src-tauri/tauri.conf.json +++ b/apps/desktop/src-tauri/tauri.conf.json @@ -25,6 +25,6 @@ }, "bundle": { "active": false, - "icon": ["icons/icon.png"] + "icon": ["icons/icon.png", "icons/icon.ico"] } } diff --git a/crates/rs-session/src/bin/rustscreen-cli.rs b/crates/rs-session/src/bin/rustscreen-cli.rs index f00ab08..b0b7e3a 100644 --- a/crates/rs-session/src/bin/rustscreen-cli.rs +++ b/crates/rs-session/src/bin/rustscreen-cli.rs @@ -60,7 +60,8 @@ environment: RUSTSCREEN_CAPTURE forced capture backend (like --source) RUSTSCREEN_CONFIG settings file RUSTSCREEN_LOG_DIR log directory (~/.local/state/rustscreen/logs) - RUSTSCREEN_VIEWER directory of the built viewer (overridden by --viewer) + RUSTSCREEN_VIEWER directory of the built viewer (overridden by --viewer; + otherwise viewer/ next to the executable) exit code 3: the share was stopped from the desktop. "; @@ -244,7 +245,8 @@ async fn main() -> Result<(), Error> { viewer_dir: options .viewer .clone() - .or_else(|| std::env::var_os("RUSTSCREEN_VIEWER").map(PathBuf::from)), + .or_else(|| std::env::var_os("RUSTSCREEN_VIEWER").map(PathBuf::from)) + .or_else(rs_session::installed_viewer), tls: options.tls, store: rs_store::Store::user_default(), overrides: Overrides { diff --git a/crates/rs-session/src/host.rs b/crates/rs-session/src/host.rs index e50bb97..4608ab6 100644 --- a/crates/rs-session/src/host.rs +++ b/crates/rs-session/src/host.rs @@ -41,6 +41,13 @@ const SERVER_STOP_TIMEOUT: Duration = Duration::from_secs(3); /// the interface comes back. const INTERFACE_DOWN: &str = "interface_down"; +/// The viewer installed next to the executable (`viewer/index.html`), as the +/// Windows installer lays it out (#96). `None` when there is none. +pub fn installed_viewer() -> Option { + let dir = std::env::current_exe().ok()?.parent()?.join("viewer"); + dir.join("index.html").is_file().then_some(dir) +} + /// What the caller sets once and for all. pub struct Config { pub version: String, diff --git a/crates/rs-session/src/lib.rs b/crates/rs-session/src/lib.rs index 4e926f5..af603ea 100644 --- a/crates/rs-session/src/lib.rs +++ b/crates/rs-session/src/lib.rs @@ -19,7 +19,7 @@ pub mod media; pub mod sources; pub mod state; -pub use host::{Config, Host, Overrides}; +pub use host::{Config, Host, Overrides, installed_viewer}; /// The codec of a launch (`Overrides::codec`), so the shell does not have to /// depend on `rs-codec`. pub use rs_codec::VideoCodec; diff --git a/docs/guide/README.md b/docs/guide/README.md index 2685e62..c0d81db 100644 --- a/docs/guide/README.md +++ b/docs/guide/README.md @@ -4,10 +4,11 @@ Pour qui veut partager son écran vers une tablette, un téléphone ou un autre installer de l'autre côté. - [Démarrer sous Linux](demarrer-linux.md): installer, partager, rejoindre depuis la tablette. +- [Démarrer sous Windows](demarrer-windows.md), en cours de validation. - [Questions fréquentes](faq.md): pare-feu, Wi-Fi qui isole, VPN, second écran, page « non chiffrée ». - [Dépannage](depannage.md): exporter les diagnostics et les lire. -Windows n'est pas encore pris en charge: la capture d'écran y demande son propre travail (voir -`docs/ROADMAP.md`). macOS ne le sera pas comme ordinateur qui partage. Le spectateur, lui, peut être n'importe quel appareil +Windows est en cours de validation (jalon « Windows » de `docs/ROADMAP.md`). macOS ne sera pas +pris en charge comme ordinateur qui partage. Le spectateur, lui, peut être n'importe quel appareil avec un navigateur récent. diff --git a/docs/guide/demarrer-windows.md b/docs/guide/demarrer-windows.md new file mode 100644 index 0000000..7bfcebb --- /dev/null +++ b/docs/guide/demarrer-windows.md @@ -0,0 +1,35 @@ +# Démarrer sous Windows (aperçu) + +La version Windows est **en cours de validation**: elle est construite et vérifiée sous Wine, pas +encore sur une vraie machine Windows. Ce qui suit est ce qu'elle doit faire; si quelque chose ne +se passe pas ainsi, l'archive de diagnostics (Réglages, section Débogage) dit pourquoi. + +## Installer + +1. Lancer `rustscreen--setup.exe`. L'installateur n'est **pas signé** (usage personnel): + Windows SmartScreen affiche « Windows a protégé votre ordinateur ». Cliquer sur + **Informations complémentaires**, puis **Exécuter quand même**. +2. L'installation se fait pour votre compte seul, sans droits d'administrateur, dans + `%LOCALAPPDATA%\Programs\rustscreen`, avec un raccourci dans le menu Démarrer. + +L'application de bureau utilise WebView2, présent sur Windows 11 et sur Windows 10 à jour. + +## Premier partage + +1. Choisir un écran, « Tous les écrans » ou une fenêtre, puis **Partager**. +2. Au premier partage, le pare-feu Windows demande s'il faut autoriser rustscreen sur les réseaux + **privés**: accepter. Sans cela, la tablette ne joint pas l'ordinateur. +3. Scanner le QR code avec la tablette, comme sous Linux. + +## Ce qui diffère de Linux + +- Pas d'écran virtuel: Windows demande un pilote pour cela, hors périmètre pour l'instant. + Un adaptateur HDMI « factice » crée un vrai second écran à partager. +- Une fenêtre se partage même couverte par une autre. Certaines applications dessinées par la + carte graphique ne se laissent lire que lorsqu'elles sont visibles. +- Réglages dans `%APPDATA%\rustscreen`, journal dans `%LOCALAPPDATA%\rustscreen\logs`. + +## Désinstaller + +Paramètres de Windows, **Applications installées**, rustscreen, **Désinstaller**. Le démarrage +automatique est retiré avec; les réglages et le journal restent, ils sont à vous. diff --git a/packaging/windows/rustscreen.nsi b/packaging/windows/rustscreen.nsi new file mode 100644 index 0000000..7621220 --- /dev/null +++ b/packaging/windows/rustscreen.nsi @@ -0,0 +1,92 @@ +; rustscreen installer for Windows (#96). +; +; Per user, without administrator rights: the files go to +; %LOCALAPPDATA%\Programs\rustscreen, the shortcuts to the user's Start menu, +; the uninstall entry under HKCU. Not signed (personal use, #90): SmartScreen +; warns on the first launch. +; +; Built by scripts/build-windows-installer.sh, which passes: +; /DVERSION=0.5.0 /DSTAGE= /DOUTFILE= + +Unicode true +!include "MUI2.nsh" + +!ifndef VERSION + !error "VERSION is required" +!endif +!ifndef STAGE + !error "STAGE is required" +!endif +!ifndef OUTFILE + !define OUTFILE "rustscreen-${VERSION}-setup.exe" +!endif + +!define APP "rustscreen" +!define UNINSTALL_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APP}" +!define RUN_KEY "Software\Microsoft\Windows\CurrentVersion\Run" + +Name "${APP}" +OutFile "${OUTFILE}" +InstallDir "$LOCALAPPDATA\Programs\${APP}" +InstallDirRegKey HKCU "${UNINSTALL_KEY}" "InstallLocation" +RequestExecutionLevel user +SetCompressor /SOLID lzma + +VIProductVersion "${VERSION}.0" +VIAddVersionKey "ProductName" "${APP}" +VIAddVersionKey "ProductVersion" "${VERSION}" +VIAddVersionKey "FileVersion" "${VERSION}" +VIAddVersionKey "FileDescription" "${APP}" +VIAddVersionKey "LegalCopyright" "Apache-2.0" + +!define MUI_ICON "${STAGE}\rustscreen.ico" +!define MUI_UNICON "${STAGE}\rustscreen.ico" +!define MUI_FINISHPAGE_RUN "$INSTDIR\rustscreen.exe" + +!insertmacro MUI_PAGE_DIRECTORY +!insertmacro MUI_PAGE_INSTFILES +!insertmacro MUI_PAGE_FINISH +!insertmacro MUI_UNPAGE_CONFIRM +!insertmacro MUI_UNPAGE_INSTFILES + +; The first language is the default; Windows picks the user's when it is here. +!insertmacro MUI_LANGUAGE "English" +!insertmacro MUI_LANGUAGE "French" + +Section "rustscreen" + SetOutPath "$INSTDIR" + ; A running copy would keep its files locked. + nsExec::Exec 'taskkill /IM rustscreen.exe /F' + File "${STAGE}\rustscreen.exe" + File "${STAGE}\rustscreen-cli.exe" + File "${STAGE}\WebView2Loader.dll" + File "${STAGE}\rustscreen.ico" + File /r "${STAGE}\viewer" + + WriteUninstaller "$INSTDIR\uninstall.exe" + CreateShortCut "$SMPROGRAMS\${APP}.lnk" "$INSTDIR\rustscreen.exe" "" "$INSTDIR\rustscreen.ico" + + WriteRegStr HKCU "${UNINSTALL_KEY}" "DisplayName" "${APP}" + WriteRegStr HKCU "${UNINSTALL_KEY}" "DisplayVersion" "${VERSION}" + WriteRegStr HKCU "${UNINSTALL_KEY}" "DisplayIcon" "$INSTDIR\rustscreen.ico" + WriteRegStr HKCU "${UNINSTALL_KEY}" "InstallLocation" "$INSTDIR" + WriteRegStr HKCU "${UNINSTALL_KEY}" "UninstallString" '"$INSTDIR\uninstall.exe"' + WriteRegDWORD HKCU "${UNINSTALL_KEY}" "NoModify" 1 + WriteRegDWORD HKCU "${UNINSTALL_KEY}" "NoRepair" 1 +SectionEnd + +Section "Uninstall" + nsExec::Exec 'taskkill /IM rustscreen.exe /F' + Delete "$INSTDIR\rustscreen.exe" + Delete "$INSTDIR\rustscreen-cli.exe" + Delete "$INSTDIR\WebView2Loader.dll" + Delete "$INSTDIR\rustscreen.ico" + RMDir /r "$INSTDIR\viewer" + Delete "$INSTDIR\uninstall.exe" + RMDir "$INSTDIR" + Delete "$SMPROGRAMS\${APP}.lnk" + ; Autostart (#32) would launch a file that no longer exists. + DeleteRegValue HKCU "${RUN_KEY}" "${APP}" + DeleteRegKey HKCU "${UNINSTALL_KEY}" + ; The settings (%APPDATA%\rustscreen) and the logs stay: they are the user's. +SectionEnd diff --git a/scripts/build-windows-installer.sh b/scripts/build-windows-installer.sh new file mode 100755 index 0000000..c1b1b32 --- /dev/null +++ b/scripts/build-windows-installer.sh @@ -0,0 +1,44 @@ +#!/bin/sh +# Builds the Windows installer from Linux (#96): viewer, desktop interface, +# the two executables cross-compiled with mingw-w64, then NSIS. +# +# ./scripts/build-windows-installer.sh # into dist/windows +# ./scripts/build-windows-installer.sh +# +# Needs Nix: every step runs in a shell of the flake, so nothing has to be +# installed on the machine. The installer is not signed (personal use, #90). +set -eu + +ROOT="$(cd "$(dirname "$0")/.." && pwd)" +OUT="${1:-$ROOT/dist/windows}" +VERSION="$(sed -n 's/^version = "\(.*\)"/\1/p' "$ROOT/Cargo.toml" | head -1)" +STAGE="$OUT/stage" +cd "$ROOT" + +echo "viewer and desktop interface" +nix develop .#default -c npm --prefix apps/viewer ci +nix develop .#default -c npm --prefix apps/viewer run build +nix develop .#desktop -c pnpm --dir apps/desktop install --frozen-lockfile +nix develop .#desktop -c pnpm --dir apps/desktop build + +echo "Windows executables" +nix develop .#windows -c cargo build --release -p rs-session --bin rustscreen-cli +nix develop .#windows -c sh -c 'cd apps/desktop/src-tauri && cargo build --release' +TARGET="$(nix develop .#windows -c sh -c 'echo $CARGO_TARGET_DIR')/x86_64-pc-windows-gnu/release" + +rm -rf "$STAGE" +mkdir -p "$STAGE" +cp "$TARGET/rustscreen.exe" "$TARGET/rustscreen-cli.exe" "$TARGET/WebView2Loader.dll" "$STAGE/" +cp apps/desktop/src-tauri/icons/icon.ico "$STAGE/rustscreen.ico" +cp -r apps/viewer/dist "$STAGE/viewer" +# The debug information doubles the size of the executables. +nix shell nixpkgs#pkgsCross.mingwW64.buildPackages.binutils -c \ + x86_64-w64-mingw32-strip "$STAGE/rustscreen.exe" "$STAGE/rustscreen-cli.exe" + +echo "installer" +INSTALLER="$OUT/rustscreen-$VERSION-setup.exe" +nix shell nixpkgs#nsis -c makensis -V2 \ + -DVERSION="$VERSION" -DSTAGE="$STAGE" -DOUTFILE="$INSTALLER" \ + packaging/windows/rustscreen.nsi + +ls -l "$INSTALLER"