Skip to content

Commit

Permalink
Minor
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitabobko committed Oct 5, 2024
1 parent d3015a4 commit bbb5c32
Show file tree
Hide file tree
Showing 20 changed files with 38 additions and 42 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ For the list of all the versions available for installation via brew see: https:
>
> I don't have anything against notarization as a concept.
> I specifically don't like the way Apple does notarization.
> I don't have time to fight Apple.
> I don't have time to deal with Apple.
>
> [Homebrew installation script](https://github.com/nikitabobko/homebrew-tap/blob/main/Casks/aerospace.rb) is configured to
> automatically delete `com.apple.quarantine` attribute, that's why the app should work out of the box, without any warnings that
Expand Down Expand Up @@ -94,8 +94,7 @@ A notes on how to setup the project, build it, how to run the tests, etc. can be
- If "dark magic" (aka "private APIs", "code injections", etc) can be avoided, it must be avoided
- Right now, AeroSpace uses only a single private API to get window ID of accessibility object `_AXUIElementGetWindow`.
Everything else is [macOS public accessibility API](https://developer.apple.com/documentation/applicationservices/axuielement_h).
- AeroSpace will never require you to disable SIP (System Integrity Protection). For example, yabai [requires you to disable SIP](https://github.com/koekeishiya/yabai/issues/1863) to use some of its features.
AeroSpace will either find another way (such as [emulation of workspaces](https://nikitabobko.github.io/AeroSpace/guide#emulation-of-virtual-workspaces)) or will not implement this feature at all (window transparency and window shadowing are not _practical_ features)
- AeroSpace will never require you to disable SIP (System Integrity Protection).

**Non Values**
- Play nicely with existing macOS features.
Expand Down
2 changes: 1 addition & 1 deletion Sources/AppBundle/initAppBundle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public func initAppBundle() {
}

checkAccessibilityPermissions()
startServer()
startUnixSocketServer()
GlobalObserver.initObserver()
refreshAndLayout(startup: true)
refreshSession {
Expand Down
2 changes: 1 addition & 1 deletion Sources/AppBundle/mouse/moveWithMouse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ func movedObs(_ obs: AXObserver, ax: AXUIElement, notif: CFString, data: UnsafeM
}

private func moveWithMouseIfTheCase(_ window: Window) { // todo cover with tests
if window.isHiddenViaEmulation || // Don't allow to move windows of hidden workspaces
if window.isHiddenInCorner || // Don't allow to move windows of hidden workspaces
!isLeftMouseButtonPressed ||
currentlyManipulatedWithMouseWindowId != nil && window.windowId != currentlyManipulatedWithMouseWindowId ||
getNativeFocusedWindow(startup: false) != window
Expand Down
2 changes: 1 addition & 1 deletion Sources/AppBundle/mouse/resizeWithMouse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func resetManipulatedWithMouseIfPossible() {
private let adaptiveWeightBeforeResizeWithMouseKey = TreeNodeUserDataKey<CGFloat>(key: "adaptiveWeightBeforeResizeWithMouseKey")

private func resizeWithMouseIfTheCase(_ window: Window) { // todo cover with tests
if window.isHiddenViaEmulation || // Don't allow to resize windows of hidden workspaces
if window.isHiddenInCorner || // Don't allow to resize windows of hidden workspaces
!isLeftMouseButtonPressed ||
currentlyManipulatedWithMouseWindowId != nil && window.windowId != currentlyManipulatedWithMouseWindowId ||
getNativeFocusedWindow(startup: false) != window
Expand Down
2 changes: 1 addition & 1 deletion Sources/AppBundle/server.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import AppKit
import Common
import Socket

func startServer() {
func startUnixSocketServer() {
let socket = Result { try Socket.create(family: .unix, type: .stream, proto: .unix) }
.getOrThrow("Can't create socket ")
let socketFile = "/tmp/\(aeroSpaceAppId)-\(unixUserName).sock"
Expand Down
8 changes: 3 additions & 5 deletions Sources/AppBundle/tree/MacWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ final class MacWindow: Window, CustomStringConvertible {
let macApp: MacApp
// todo take into account monitor proportions
private var prevUnhiddenEmulationPositionRelativeToWorkspaceAssignedRect: CGPoint?
fileprivate var previousSize: CGSize?
private var axObservers: [AxObserverWrapper] = [] // keep observers in memory

private init(_ id: CGWindowID, _ app: MacApp, _ axWindow: AXUIElement, parent: NonLeafTreeNodeObject, adaptiveWeight: CGFloat, index: Int) {
Expand Down Expand Up @@ -111,7 +110,7 @@ final class MacWindow: Window, CustomStringConvertible {
guard let nodeMonitor else { return }
// Don't accidentally override prevUnhiddenEmulationPosition in case of subsequent
// `hideEmulation` calls
if !isHiddenViaEmulation {
if !isHiddenInCorner {
guard let topLeftCorner = getTopLeftCorner() else { return }
guard let workspace else { return } // hiding only makes sense for workspace windows
prevUnhiddenEmulationPositionRelativeToWorkspaceAssignedRect =
Expand Down Expand Up @@ -150,14 +149,13 @@ final class MacWindow: Window, CustomStringConvertible {
self.prevUnhiddenEmulationPositionRelativeToWorkspaceAssignedRect = nil
}

override var isHiddenViaEmulation: Bool {
override var isHiddenInCorner: Bool {
prevUnhiddenEmulationPositionRelativeToWorkspaceAssignedRect != nil
}

override func setSize(_ size: CGSize) -> Bool {
disableAnimations {
previousSize = getSize()
return axWindow.set(Ax.sizeAttr, size)
axWindow.set(Ax.sizeAttr, size)
}
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/AppBundle/tree/Window.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Window: TreeNode, Hashable {
var title: String { error("Not implemented") }
var isMacosFullscreen: Bool { false }
var isMacosMinimized: Bool { false } // todo replace with enum MacOsWindowNativeState { normal, fullscreen, invisible }
var isHiddenViaEmulation: Bool { error("Not implemented") }
var isHiddenInCorner: Bool { error("Not implemented") }
func setSize(_ size: CGSize) -> Bool { error("Not implemented") }

func setTopLeftCorner(_ point: CGPoint) -> Bool { error("Not implemented") }
Expand Down
6 changes: 4 additions & 2 deletions Sources/Cli/subcommandDescriptionsGenerated.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// FILE IS GENERATED BY generate.sh
// FILE IS GENERATED FROM docs/aerospace-*.adoc files
// TO REGENERATE THE FILE RUN generate.sh

let subcommandDescriptions = [
[" balance-sizes", "Balance sizes of all windows in the current workspace"],
[" close-all-windows-but-current", "On the focused workspace, close all windows but current"],
Expand All @@ -9,7 +11,7 @@ let subcommandDescriptions = [
[" flatten-workspace-tree", "Flatten the tree of the focused workspace"],
[" focus-back-and-forth", "Switch between the current and previously focused elements back and forth"],
[" focus-monitor", "Focus monitor by relative direction, by order, or by pattern"],
[" focus", "Set focus to the nearest window in in the given direction."],
[" focus", "Set focus to the nearest window in the given direction."],
[" fullscreen", "Toggle the fullscreen mode for the focused window"],
[" join-with", "Put the focused window and the nearest node in the specified direction under a common parent container"],
[" layout", "Change layout of the focused window to the given layout"],
Expand Down
3 changes: 2 additions & 1 deletion Sources/Common/cmdHelpGenerated.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// FILE IS GENERATED BY generate.sh --all
// FILE IS GENERATED FROM docs/aerospace-*.adoc files
// TO REGENERATE THE FILE RUN generate.sh --all

let balance_sizes_help_generated = """
USAGE: balance-sizes [-h|--help] [--workspace <workspace>]
Expand Down
2 changes: 1 addition & 1 deletion build-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ build-site() {
cd - > /dev/null

git rev-parse HEAD > .site/version.html
if [ ! -z "$(git status --porcelain)" ]; then
if ! test -z "$(git status --porcelain)"; then
echo "git working directory is dirty" >> .site/version.html
fi
}
Expand Down
2 changes: 1 addition & 1 deletion build-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ expected_layout=$(cat <<EOF
EOF
)

if [ "$expected_layout" != "$(find .release/$aerospace_dot_app)" ]; then
if test "$expected_layout" != "$(find .release/$aerospace_dot_app)"; then
echo "!!! Expect/Actual layout don't match !!!"
find .release/$aerospace_dot_app
exit 1
Expand Down
6 changes: 3 additions & 3 deletions build-shell-completion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ rm -rf .shell-completion && mkdir -p \
.shell-completion/bash

./.deps/cargo-root/bin/complgen aot ./grammar/commands-bnf-grammar.txt \
--zsh-script .shell-completion/zsh/_aerospace 2>&1 \
--fish-script .shell-completion/fish/aerospace.fish 2>&1 \
--bash-script .shell-completion/bash/aerospace 2>&1
--zsh-script .shell-completion/zsh/_aerospace \
--fish-script .shell-completion/fish/aerospace.fish \
--bash-script .shell-completion/bash/aerospace

if ! (not-outdated-bash --version | grep -q 'version 5'); then
echo "bash version is too old. At least version 5 is required" > /dev/stderr
Expand Down
15 changes: 6 additions & 9 deletions docs/aerospace-config.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,12 @@ alt-2
----
$ aerospace config --get mode.main.binding --json
{
"alt-shift-5" : [
"move-node-to-workspace 5"
],
"alt-r" : [
"workspace R"
],
"alt-shift-6" : [
"move-node-to-workspace 6"
],
"alt-w" : "workspace W",
"alt-y" : "workspace Y",
"alt-n" : "workspace N",
"alt-shift-e" : "move-node-to-workspace E",
"alt-shift-m" : "move-node-to-workspace M",
"alt-shift-t" : "move-node-to-workspace T",
...
----

Expand Down
2 changes: 1 addition & 1 deletion docs/aerospace-focus.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
include::util/man-attributes.adoc[]
:manname: aerospace-focus
// tag::purpose[]
:manpurpose: Set focus to the nearest window in in the given direction.
:manpurpose: Set focus to the nearest window in the given direction.
// end::purpose[]

// =========================================================== Synopsis
Expand Down
2 changes: 1 addition & 1 deletion docs/commands.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ include::util/site-attributes.adoc[]

include::util/header.adoc[]

Commands documentation is also available in the form of manpages.
Commands documentation is also available as manpages.

== balance-sizes
----
Expand Down
4 changes: 3 additions & 1 deletion generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ entries() {
}

cat <<EOF > ./Sources/Cli/subcommandDescriptionsGenerated.swift
// FILE IS GENERATED BY generate.sh
// FILE IS GENERATED FROM docs/aerospace-*.adoc files
// TO REGENERATE THE FILE RUN generate.sh
let subcommandDescriptions = [
$(entries)
]
Expand Down
2 changes: 1 addition & 1 deletion script/build-brew-cask.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ sha=$(shasum -a 256 "$zip_file" | awk '{print $1}')

cask_version=''
zip_root_dir=''
if grep -q SNAPSHOT <<< $build_version; then
if grep -q SNAPSHOT <<< "$build_version"; then
# Prevent 'Not upgrading aerospace, the latest version is already installed'
cask_version=':latest'
zip_root_dir="AeroSpace-v$build_version"
Expand Down
2 changes: 1 addition & 1 deletion script/check-uncommitted-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
cd "$(dirname "$0")/.."
source ./script/setup.sh

if [ ! -z "$(git status --porcelain)" ]; then
if ! test -z "$(git status --porcelain)"; then
echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
echo !!! Uncommitted files detected !!!
echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Expand Down
3 changes: 2 additions & 1 deletion script/generate-cmd-help.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ sed_insert="i \\$nl"
sed_append="a \\$nl"

cat << EOF > $out_file
// FILE IS GENERATED BY generate.sh --all
// FILE IS GENERATED FROM docs/aerospace-*.adoc files
// TO REGENERATE THE FILE RUN generate.sh --all
EOF

Expand Down
8 changes: 2 additions & 6 deletions script/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ set -o pipefail # Any command failed in the pipe fails the whole pipe

add-to-bin() {
/usr/bin/which "$1" &> /dev/null && \
cat > ".deps/bin/${2:-$1}" <<EOF
/bin/cat > ".deps/bin/${2:-$1}" <<EOF
#!/bin/bash
exec '$(/usr/bin/which "$1")' "\$@"
EOF
}

nuke-path() {
if /bin/test -z "${NUKE_PATH:-}"; then
/bin/rm -rf .deps/bin
/bin/mkdir -p .deps/bin

Expand All @@ -28,11 +28,7 @@ nuke-path() {

export PATH="${PWD}/.deps/bin:/bin:/usr/bin"
chmod +x .deps/bin/*
}

if [ -z "${NUKE_PATH:-}" ]; then
export NUKE_PATH=1
nuke-path
fi

xcodebuild() {
Expand Down

0 comments on commit bbb5c32

Please sign in to comment.