### Build WinBoat Linux App and Guest Server (NodeJS, Go) Source: https://github.com/tibixdev/winboat/blob/main/README.md This snippet outlines the commands to build the WinBoat application and its guest server for Linux. It requires NodeJS and Go to be installed. The process involves cloning the repository, installing Node.js dependencies, and then running a build script. The output includes an AppImage and an unpacked variant. ```bash git clone https://github.com/TibixDev/WinBoat npm i npm run build:linux-gs ``` -------------------------------- ### Automate Windows Installation with InstallManager Source: https://context7.com/tibixdev/winboat/llms.txt This snippet utilizes the InstallManager class to automate the Windows installation process. It defines installation configurations, listens for installation state changes and messages via an event emitter, and handles potential errors. It also includes a check for whether Windows is already installed. Requires InstallManager, InstallStates, and InstallConfiguration types. ```typescript import { InstallManager, InstallStates } from './renderer/lib/install'; import type { InstallConfiguration } from './types'; // Define installation configuration const config: InstallConfiguration = { windowsVersion: "11", windowsLanguage: "English", cpuCores: 4, ramGB: 8, installFolder: "/home/user/.winboat/storage", diskSpaceGB: 64, username: "WinBoatUser", password: "SecurePassword123", shareHomeFolder: true }; // Create installer and listen to state changes const installer = new InstallManager(config); installer.emitter.on('stateChanged', (state) => { console.log(`Installation state: ${state}`); }); installer.emitter.on('preinstallMsg', (msg) => { console.log(`Preinstall: ${msg}`); }); installer.emitter.on('error', (error) => { console.error(`Installation error: ${error.message}`); }); // Run installation try { await installer.install(); console.log("Windows installation completed successfully!"); } catch (error) { console.error("Installation failed:", error); } // Check if Windows is already installed const installed = await isInstalled(); console.log(`Windows installed: ${installed}`); ``` -------------------------------- ### Control Winboat Application Lifecycle and Interaction Source: https://context7.com/tibixdev/winboat/llms.txt This snippet demonstrates the core functionalities of the Winboat class, including starting and stopping the Windows container, checking guest server status, retrieving system metrics, fetching available applications, and launching a specific application like Windows Explorer. It assumes the Winboat class and its dependencies are available. ```typescript import { Winboat } from './renderer/lib/winboat'; // Initialize the Winboat singleton const winboat = new Winboat(); // Start the Windows container await winboat.startContainer(); // Wait for the guest to come online while (!winboat.isOnline.value) { await new Promise(resolve => setTimeout(resolve, 1000)); } // Get system metrics const metrics = await winboat.getMetrics(); console.log(`CPU Usage: ${metrics.cpu.usage}%`); console.log(`RAM Used: ${metrics.ram.used}MB / ${metrics.ram.total}MB`); console.log(`Disk Used: ${metrics.disk.used}MB / ${metrics.disk.total}MB`); // Get available applications const apps = await winboat.appMgr.getApps(`http://127.0.0.1:${winboat.getHostPort(7148)}`); // Launch Windows Explorer const explorerApp = apps.find(app => app.Name === "⚙️ Windows Explorer"); if (explorerApp) { await winboat.launchApp(explorerApp); } // Stop the container await winboat.stopContainer(); ``` -------------------------------- ### Launch and Manage Applications Source: https://context7.com/tibixdev/winboat/llms.txt This snippet shows how to interact with the application manager in Winboat. It covers fetching applications, sorting them by usage, adding custom applications, updating the app cache, launching applications, removing custom apps, and accessing internal applications like the Windows desktop. It depends on the './renderer/lib/winboat' and './renderer/data/internalapps' modules. ```typescript import { Winboat } from './renderer/lib/winboat'; const winboat = new Winboat(); const apiUrl = `http://127.0.0.1:${winboat.getHostPort(7148)}`; // Get all available applications const apps = await winboat.appMgr.getApps(apiUrl); console.log(`Found ${apps.length} applications`); // Display apps sorted by usage const sortedApps = [...apps].sort((a, b) => (b.Usage || 0) - (a.Usage || 0)); console.log("Most used apps:"); sortedApps.slice(0, 5).forEach(app => { console.log(` ${app.Name}: ${app.Usage} launches`); }); // Add a custom application await winboat.appMgr.addCustomApp( "Visual Studio Code", "C:\\Program Files\\Microsoft VS Code\\Code.exe", "data:image/png;base64,iVBORw0KGgoAAAA..." ); // Update app cache from guest server await winboat.appMgr.updateAppCache(apiUrl, { forceRead: true }); // Launch an application const vsCodeApp = apps.find(app => app.Name === "Visual Studio Code"); if (vsCodeApp) { await winboat.launchApp(vsCodeApp); console.log(`Launched ${vsCodeApp.Name}`); } // Remove a custom app const customApp = apps.find(app => app.Source === "custom" && app.Name === "Visual Studio Code"); if (customApp) { await winboat.appMgr.removeCustomApp(customApp); console.log("Custom app removed"); } // Access internal apps import { InternalApps } from './renderer/data/internalapps'; const desktopApp = apps.find(app => app.Path === InternalApps.WINDOWS_DESKTOP); if (desktopApp) { await winboat.launchApp(desktopApp); // Launches full Windows desktop } ``` -------------------------------- ### Manage Winboat Configuration Source: https://context7.com/tibixdev/winboat/llms.txt This snippet demonstrates how to initialize, read, modify, and replace the persistent configuration for Winboat. It utilizes the WinboatConfig class for automatic disk synchronization. Dependencies include the './renderer/lib/config' module. ```typescript import { WinboatConfig } from './renderer/lib/config'; import type { WinboatConfigObj } from './renderer/lib/config'; // Initialize config (singleton) const config = new WinboatConfig(); // Read current configuration console.log("Current config:", config.config); // Modify configuration (auto-saves to disk) config.config.scale = 140; config.config.scaleDesktop = 100; config.config.smartcardEnabled = true; config.config.rdpMonitoringEnabled = true; config.config.experimentalFeatures = true; config.config.multiMonitor = 1; // 0=disabled, 1=multimon, 2=span // Add custom app config.config.customApps.push({ Name: "My Custom App", Path: "C:\\Program Files\\MyApp\\app.exe", Icon: "data:image/png;base64,...", Source: "custom", Usage: 0 }); // Replace entire config const newConfig: WinboatConfigObj = { scale: 100, scaleDesktop: 100, smartcardEnabled: false, rdpMonitoringEnabled: false, passedThroughDevices: [], customApps: [], experimentalFeatures: false, multiMonitor: 0 }; config.config = newConfig; ``` -------------------------------- ### Control QEMU VM Features with QMPManager Source: https://context7.com/tibixdev/winboat/llms.txt The QMPManager provides a low-level interface for communication with QEMU virtual machines using the QEMU Machine Protocol (QMP). It enables connecting to a QMP socket, executing various QMP commands to query VM status, capabilities, and available commands. It also supports executing monitor commands, adding/removing devices (like USB hosts), and checking the connection status. ```typescript import { QMPManager } from './renderer/lib/qmp'; // Connect to QMP socket const qmpMgr = await QMPManager.createConnection("127.0.0.1", 8149); // Initialize QMP capabilities const capsResponse = await qmpMgr.executeCommand("qmp_capabilities"); if ("return" in capsResponse) { console.log("QMP capabilities initialized"); } // Query VM status const statusResponse = await qmpMgr.executeCommand("query-status"); if ("return" in statusResponse) { console.log(`VM running: ${statusResponse.return.running}`); console.log(`VM status: ${statusResponse.return.status}`); } // Query available QMP commands const commandsResponse = await qmpMgr.executeCommand("query-commands"); if ("return" in commandsResponse) { console.log("Available commands:"); commandsResponse.return.forEach(cmd => console.log(` - ${cmd.name}`)); } // Execute human-readable monitor command const treeResponse = await qmpMgr.executeCommand("human-monitor-command", { "command-line": "info qtree" }); if ("return" in treeResponse) { console.log("QEMU device tree:", treeResponse.return); } // Add USB device to VM const addDeviceResponse = await qmpMgr.executeCommand("device_add", { driver: "usb-host", id: "1234:5678", vendorid: 0x1234, productid: 0x5678, hostdevice: "/dev/bus/usb/001/002" }); // Remove USB device from VM const delDeviceResponse = await qmpMgr.executeCommand("device_del", { id: "1234:5678" }); // Check if QMP connection is alive const isAlive = await qmpMgr.isAlive(); console.log(`QMP connection alive: ${isAlive}`); ``` -------------------------------- ### Manage Docker Compose Configuration Source: https://context7.com/tibixdev/winboat/llms.txt This snippet illustrates how to manage Docker Compose configurations within Winboat. It covers parsing the current configuration, retrieving RDP credentials, modifying service environments (like RAM size and CPU cores), redeploying the container, and resetting Winboat entirely. Dependencies include the './renderer/lib/winboat' and './types' modules. ```typescript import { Winboat } from './renderer/lib/winboat'; import type { ComposeConfig } from './types'; const winboat = new Winboat(); // Parse current compose configuration const compose = winboat.parseCompose(); console.log("Current Windows version:", compose.services.windows.environment.VERSION); console.log("Current RAM allocation:", compose.services.windows.environment.RAM_SIZE); // Get RDP credentials const credentials = winboat.getCredentials(); console.log(`Username: ${credentials.username}`); console.log(`Password: ${credentials.password}`); // Modify configuration const newCompose: ComposeConfig = { ...compose }; newCompose.services.windows.environment.RAM_SIZE = "16G"; newCompose.services.windows.environment.CPU_CORES = "8"; newCompose.services.windows.environment.DISK_SIZE = "128G"; // Scale application resources try { await winboat.replaceCompose(newCompose); console.log("Configuration updated and container redeployed"); } catch (error) { console.error("Failed to update configuration:", error); } // Reset WinBoat (removes everything) const confirmReset = confirm("This will delete all Windows data. Continue?"); if (confirmReset) { await winboat.resetWinboat(); console.log("WinBoat has been reset"); } ``` -------------------------------- ### Manage Host-to-Guest Port Mappings with PortManager Source: https://context7.com/tibixdev/winboat/llms.txt The PortManager class handles dynamic host-to-guest port mappings for Docker compose configurations. It includes functionality for parsing compose files, automatically resolving port conflicts by finding open ports, and retrieving the mapped host port for a given guest port. It also provides methods to check port availability and format port mappings for docker-compose. ```typescript import { PortManager, ComposePortEntry } from './renderer/utils/port'; import type { ComposeConfig } from './types'; // Parse compose configuration and handle port conflicts const compose: ComposeConfig = { name: "winboat", volumes: { data: null }, services: { windows: { image: "ghcr.io/dockur/windows:5.07", container_name: "WinBoat", ports: ["8006:8006", "7148:7148", "3389:3389/tcp", "3389:3389/udp"], // ... other config } } }; // Create port manager from compose config const portMgr = await PortManager.parseCompose(compose, { findOpenPorts: true }); // Get mapped host port for guest port const apiPort = portMgr.getHostPort(7148); const rdpPort = portMgr.getHostPort(3389); console.log(`Guest API accessible at: http://127.0.0.1:${apiPort}`); console.log(`RDP accessible at: 127.0.0.1:${rdpPort}`); // Check if a port is open const port8006Open = await PortManager.isPortOpen(8006); if (!port8006Open) { const alternativePort = await PortManager.getOpenPortInRange(8007, 8106); console.log(`Port 8006 in use, using alternative: ${alternativePort}`); } // Get compose-formatted port strings const portStrings = portMgr.composeFormat; console.log("Port mappings for docker-compose:", portStrings); ``` -------------------------------- ### Manage USB Device Passthrough with USBManager Source: https://context7.com/tibixdev/winboat/llms.txt The USBManager class facilitates the detection and passthrough of USB devices to a Windows VM via QMP. It allows listing connected USB devices, adding them to a passthrough list, checking their connection status within the VM, and removing them from the list. It also supports watching for changes in connected USB devices. ```typescript import { USBManager } from './renderer/lib/usbmanager'; import { Winboat } from './renderer/lib/winboat'; import { watch } from 'vue'; const usbMgr = new USBManager(); const winboat = new Winboat(); // List all connected USB devices console.log("Connected USB devices:"); usbMgr.devices.value.forEach(device => { const deviceStr = usbMgr.stringifyDevice(device); const isMTP = usbMgr.isMTPDevice(device); console.log(`${deviceStr} ${isMTP ? '(MTP Device)' : ''}`); }); // Add a device to passthrough list const device = usbMgr.devices.value[0]; try { await usbMgr.addDeviceToPassthroughList(device); console.log("Device added to passthrough list"); } catch (error) { console.error("Failed to add device:", error); } // Watch for device connection changes watch(usbMgr.devices, (newDevices) => { console.log(`Device count changed: ${newDevices.length} devices connected`); }); // Check passthrough status usbMgr.ptDevices.value.forEach(ptDevice => { const connected = usbMgr.isPTDeviceConnected(ptDevice); const deviceStr = usbMgr.stringifyPTSerializableDevice(ptDevice); console.log(`${deviceStr} - ${connected ? 'Connected' : 'Disconnected'}`); }); // Remove device from passthrough const firstPTDevice = usbMgr.ptDevices.value[0]; if (firstPTDevice) { await usbMgr.removeDeviceFromPassthroughList(firstPTDevice); console.log("Device removed from passthrough"); } ``` -------------------------------- ### Monitor and Manage Winboat Container Status Source: https://context7.com/tibixdev/winboat/llms.txt This TypeScript code shows how to monitor real-time changes in the Winboat container's status using Vue's reactivity system. It includes logic to handle different states like Running, Exited, and Paused, and demonstrates how to pause and unpause the container. It requires the Winboat class and ContainerStatus enum. ```typescript import { Winboat, ContainerStatus } from './renderer/lib/winboat'; import { watch } from 'vue'; const winboat = new Winboat(); // Watch container status changes watch(winboat.containerStatus, (newStatus) => { switch (newStatus) { case ContainerStatus.Running: console.log("Container is running"); break; case ContainerStatus.Exited: console.log("Container has exited"); break; case ContainerStatus.Paused: console.log("Container is paused"); break; } }); // Get current container status const status = await winboat.getContainerStatus(); console.log(`Current status: ${status}`); // Pause and unpause if (winboat.containerStatus.value === ContainerStatus.Running) { await winboat.pauseContainer(); await new Promise(resolve => setTimeout(resolve, 2000)); await winboat.unpauseContainer(); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.