diff --git a/LocalPackage/Sources/Common/cmdArgs/FullscreenCmdArgs.swift b/LocalPackage/Sources/Common/cmdArgs/FullscreenCmdArgs.swift new file mode 100644 index 00000000..ab32d461 --- /dev/null +++ b/LocalPackage/Sources/Common/cmdArgs/FullscreenCmdArgs.swift @@ -0,0 +1,20 @@ +public struct FullscreenCmdArgs: CmdArgs, RawCmdArgs { + public init() {} + public static let parser: CmdParser = cmdParser( + kind: .fullscreen, + allowInConfig: true, + help: """ + USAGE: fullscreen [-h|--help] [on|off] + + OPTIONS: + -h, --help Print help + + ARGUMENTS: + [on|off] 'on' means enter fullscreen mode. 'off' means exit fullscreen mode. + Toggle between the two if not specified + """, + options: [:], + arguments: [ArgParser(\.toggle, parseToggleEnum)] + ) + public var toggle: ToggleEnum = .toggle +} diff --git a/LocalPackage/Sources/Common/cmdArgs/noCmdArgs.swift b/LocalPackage/Sources/Common/cmdArgs/noCmdArgs.swift index bca12060..5d6e3763 100644 --- a/LocalPackage/Sources/Common/cmdArgs/noCmdArgs.swift +++ b/LocalPackage/Sources/Common/cmdArgs/noCmdArgs.swift @@ -2,10 +2,6 @@ public struct FlattenWorkspaceTreeCmdArgs: RawCmdArgs, CmdArgs { public init() {} public static let parser: CmdParser = noArgsParser(.flattenWorkspaceTree, allowInConfig: true) } -public struct FullscreenCmdArgs: RawCmdArgs, CmdArgs { - public init() {} - public static let parser: CmdParser = noArgsParser(.fullscreen, allowInConfig: true) -} public struct ReloadConfigCmdArgs: RawCmdArgs, CmdArgs { public init() {} public static let parser: CmdParser = noArgsParser(.reloadConfig, allowInConfig: true) diff --git a/docs/aerospace-fullscreen.adoc b/docs/aerospace-fullscreen.adoc index 60812caf..796417f9 100644 --- a/docs/aerospace-fullscreen.adoc +++ b/docs/aerospace-fullscreen.adoc @@ -7,7 +7,7 @@ include::util/man-attributes.adoc[] == Synopsis // tag::synopsis[] -aerospace fullscreen [-h|--help] +aerospace fullscreen [-h|--help] [on|off] // end::synopsis[] == Description @@ -16,10 +16,17 @@ aerospace fullscreen [-h|--help] {manpurpose} Switching to a different tiling window within the same workspace while the current focused window is in fullscreen mode results in the fullscreen window exiting fullscreen mode. -// end::body[] include::util/conditional-options-header.adoc[] -h, --help:: Print help +include::util/conditional-arguments-header.adoc[] + +[on|off]:: +'on' means enter fullscreen mode. 'off' means exit fullscreen mode. +Toggle between the two if not specified + +// end::body[] + include::util/man-footer.adoc[] diff --git a/src/command/FullscreenCommand.swift b/src/command/FullscreenCommand.swift index 03a17814..bc3831d6 100644 --- a/src/command/FullscreenCommand.swift +++ b/src/command/FullscreenCommand.swift @@ -1,7 +1,7 @@ import Common struct FullscreenCommand: Command { - let args = FullscreenCmdArgs() + let args: FullscreenCmdArgs func _run(_ state: CommandMutableState, stdin: String) -> Bool { check(Thread.current.isMainThread) @@ -9,7 +9,24 @@ struct FullscreenCommand: Command { state.stderr.append(noWindowIsFocused) return false } - window.isFullscreen = !window.isFullscreen + let newState: Bool + switch args.toggle { + case .on: + newState = true + case .off: + newState = false + case .toggle: + newState = !window.isFullscreen + } + if newState == window.isFullscreen { + if newState { + state.stderr.append("Already fullscreen") + } else { + state.stderr.append("Already not fullscreen") + } + return false + } + window.isFullscreen = newState // Focus on its own workspace window.markAsMostRecentChild() diff --git a/src/command/other/parseCommand.swift b/src/command/other/parseCommand.swift index 3681d86c..71a262ca 100644 --- a/src/command/other/parseCommand.swift +++ b/src/command/other/parseCommand.swift @@ -24,7 +24,7 @@ extension CmdArgs { case .focus: command = FocusCommand(args: self as! FocusCmdArgs) case .fullscreen: - command = FullscreenCommand() + command = FullscreenCommand(args: self as! FullscreenCmdArgs) case .joinWith: command = JoinWithCommand(args: self as! JoinWithCmdArgs) case .layout: