From 90d950013385be8230ac68514fdcd5b516c88956 Mon Sep 17 00:00:00 2001 From: Eric Kolve Date: Thu, 9 Oct 2025 12:29:28 -0700 Subject: [PATCH] chore: adding no-keyboard, no-pointer options for run (#1091) --- Sources/tart/Commands/Run.swift | 17 ++++++++++++++++- Sources/tart/VM.swift | 24 +++++++++++++++++++----- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/Sources/tart/Commands/Run.swift b/Sources/tart/Commands/Run.swift index 2d334c2..2af1783 100644 --- a/Sources/tart/Commands/Run.swift +++ b/Sources/tart/Commands/Run.swift @@ -266,6 +266,12 @@ struct Run: AsyncParsableCommand { #endif var noTrackpad: Bool = false + @Flag(help: ArgumentHelp("Disable the pointer")) + var noPointer: Bool = false + + @Flag(help: ArgumentHelp("Disable the keyboard")) + var noKeyboard: Bool = false + mutating func validate() throws { if vnc && vncExperimental { throw ValidationError("--vnc and --vnc-experimental are mutually exclusive") @@ -317,8 +323,15 @@ struct Run: AsyncParsableCommand { if noTrackpad { throw ValidationError("--no-trackpad cannot be used with --suspendable") } + if noKeyboard { + throw ValidationError("--no-keyboard cannot be used with --suspendable") + } + if noPointer { + throw ValidationError("--no-pointer cannot be used with --suspendable") + } } + if noTrackpad { let config = try VMConfig.init(fromURL: vmDir.configURL) if config.os != .darwin { @@ -394,7 +407,9 @@ struct Run: AsyncParsableCommand { clipboard: !noClipboard, sync: VZDiskImageSynchronizationMode(diskOptions.syncModeRaw), caching: VZDiskImageCachingMode(diskOptions.cachingModeRaw), - noTrackpad: noTrackpad + noTrackpad: noTrackpad, + noPointer: noPointer, + noKeyboard: noKeyboard ) let vncImpl: VNC? = try { diff --git a/Sources/tart/VM.swift b/Sources/tart/VM.swift index 15b3cc9..fc8fc7a 100644 --- a/Sources/tart/VM.swift +++ b/Sources/tart/VM.swift @@ -51,7 +51,9 @@ class VM: NSObject, VZVirtualMachineDelegate, ObservableObject { clipboard: Bool = true, sync: VZDiskImageSynchronizationMode = .full, caching: VZDiskImageCachingMode? = nil, - noTrackpad: Bool = false + noTrackpad: Bool = false, + noPointer: Bool = false, + noKeyboard: Bool = false ) throws { name = vmDir.name config = try VMConfig.init(fromURL: vmDir.configURL) @@ -73,7 +75,9 @@ class VM: NSObject, VZVirtualMachineDelegate, ObservableObject { clipboard: clipboard, sync: sync, caching: caching, - noTrackpad: noTrackpad + noTrackpad: noTrackpad, + noPointer: noPointer, + noKeyboard: noKeyboard ) virtualMachine = VZVirtualMachine(configuration: configuration) @@ -316,7 +320,9 @@ class VM: NSObject, VZVirtualMachineDelegate, ObservableObject { clipboard: Bool = true, sync: VZDiskImageSynchronizationMode = .full, caching: VZDiskImageCachingMode? = nil, - noTrackpad: Bool = false + noTrackpad: Bool = false, + noPointer: Bool = false, + noKeyboard: Bool = false ) throws -> VZVirtualMachineConfiguration { let configuration = VZVirtualMachineConfiguration() @@ -356,8 +362,16 @@ class VM: NSObject, VZVirtualMachineDelegate, ObservableObject { configuration.keyboards = platformSuspendable.keyboardsSuspendable() configuration.pointingDevices = platformSuspendable.pointingDevicesSuspendable() } else { - configuration.keyboards = vmConfig.platform.keyboards() - if noTrackpad { + + if noKeyboard { + configuration.keyboards = [] + } else { + configuration.keyboards = vmConfig.platform.keyboards() + } + + if noPointer { + configuration.pointingDevices = [] + } else if noTrackpad { configuration.pointingDevices = vmConfig.platform.pointingDevicesSimplified() } else { configuration.pointingDevices = vmConfig.platform.pointingDevices()