Skip to content

Commit

Permalink
WIP: config #2
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitabobko committed Sep 13, 2023
1 parent 38c74a0 commit dff8dc4
Show file tree
Hide file tree
Showing 10 changed files with 449 additions and 105 deletions.
20 changes: 14 additions & 6 deletions AeroSpace.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
1CB4082BE5C95CA8CD52BED9 /* Maybe.swift in Sources */ = {isa = PBXBuildFile; fileRef = 345148B22F8A8F85109229AE /* Maybe.swift */; };
2F8DC074DAB97DC87E07A559 /* Bundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = F9CAC977020A08D0227FAFB2 /* Bundle.swift */; };
4005ECE237BD9230F74CA917 /* TreeNodeEx.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8C39B0C4E4888832129C4C7 /* TreeNodeEx.swift */; };
45EA2D1C90430C432E123B51 /* keysMap.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C0D40CBD65704BA9595C2FA /* keysMap.swift */; };
518B9E5AC031C24C7C84CD70 /* MacWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 243F29F496F7463F3482DD10 /* MacWindow.swift */; };
6317AB471F4C4F5D66A25784 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = EEDBFFCA7A77D96B18FB0732 /* Assets.xcassets */; };
64A058E536F1EEF7F01043AF /* TOMLKit in Frameworks */ = {isa = PBXBuildFile; productRef = EC8E4F2CA4FF8884F9F59975 /* TOMLKit */; };
Expand All @@ -26,20 +27,22 @@
852F88894A3B9FC385563665 /* HotKey in Frameworks */ = {isa = PBXBuildFile; productRef = 42BC1E757EF69233C2262FF4 /* HotKey */; };
920FDF8498DCCB62149D1719 /* Monitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = F6507EBAA795220FD0C05384 /* Monitor.swift */; };
96593DF93A69CA2E05189A3F /* axObservers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E6F3930E3BF5D8196A20E9B /* axObservers.swift */; };
A0765C31043BCFB0420BF1C9 /* parseConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67DBAF4ECF8A0B931FC34EAD /* parseConfig.swift */; };
A2CBF9674964F9083BB198D2 /* ArrayEx.swift in Sources */ = {isa = PBXBuildFile; fileRef = 883D7F7F87FBE7D0BDE4E87F /* ArrayEx.swift */; };
A4F66097ADF0FD58C6B715AE /* NSWorkspaceEx.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6935AF0A2DB3D186D1C6218F /* NSWorkspaceEx.swift */; };
AE76A183D0454E4C8ADCE380 /* SequenceEx.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAE5DCAEC5EE619CE33859E7 /* SequenceEx.swift */; };
B0D0C37BAE7E7F0D0FF1E9FC /* GlobalObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C2E5977331398421A4FC168 /* GlobalObserver.swift */; };
B1E2002BB8F70F2555AAA82D /* TreeNode.swift in Sources */ = {isa = PBXBuildFile; fileRef = D295CA45172ADBDB1E4DF708 /* TreeNode.swift */; };
B3702BB393A9B03CCAE4C60E /* refresh.swift in Sources */ = {isa = PBXBuildFile; fileRef = 526B113159987FA43EA41120 /* refresh.swift */; };
C0A88261ECF505FC5648FC0A /* OptionalEx.swift in Sources */ = {isa = PBXBuildFile; fileRef = A9EDFD4A9F45182CA6E0BD7B /* OptionalEx.swift */; };
C39C2054893A6506C35732D7 /* config.swift in Sources */ = {isa = PBXBuildFile; fileRef = 651C5EE18862C252795811B3 /* config.swift */; };
D4F68F33C6E354856C80E729 /* ConfigModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6C3C4DD77B74C92C8C01E39 /* ConfigModel.swift */; };
E2FD8E2B2D2BE6B88BF8E8AD /* accessibility.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE605CF46DE6377C69B9D49D /* accessibility.swift */; };
F2AFA702961A1D653EB7D269 /* command.swift in Sources */ = {isa = PBXBuildFile; fileRef = 776E3F4EE298A9C69C97EF7F /* command.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
09685297933511208058F7CF /* AeroSpace.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AeroSpace.app; sourceTree = BUILT_PRODUCTS_DIR; };
1C0D40CBD65704BA9595C2FA /* keysMap.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = keysMap.swift; sourceTree = "<group>"; };
1E81623E8954701269A22322 /* AeroSpaceApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AeroSpaceApp.swift; sourceTree = "<group>"; };
243F29F496F7463F3482DD10 /* MacWindow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MacWindow.swift; sourceTree = "<group>"; };
24F99E8C4FD17A1D939C41F1 /* ViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewModel.swift; sourceTree = "<group>"; };
Expand All @@ -50,7 +53,7 @@
3E05FB0C7158C8B6DECBD603 /* TilingContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TilingContainer.swift; sourceTree = "<group>"; };
51CE37C1B8D858C81A396F40 /* CollectionEx.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CollectionEx.swift; sourceTree = "<group>"; };
526B113159987FA43EA41120 /* refresh.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = refresh.swift; sourceTree = "<group>"; };
651C5EE18862C252795811B3 /* config.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = config.swift; sourceTree = "<group>"; };
67DBAF4ECF8A0B931FC34EAD /* parseConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = parseConfig.swift; sourceTree = "<group>"; };
6935AF0A2DB3D186D1C6218F /* NSWorkspaceEx.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSWorkspaceEx.swift; sourceTree = "<group>"; };
776E3F4EE298A9C69C97EF7F /* command.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = command.swift; sourceTree = "<group>"; };
7E6F3930E3BF5D8196A20E9B /* axObservers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = axObservers.swift; sourceTree = "<group>"; };
Expand All @@ -63,6 +66,7 @@
BEF353340822CD20E9DAB3EC /* AeroSpace.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = AeroSpace.entitlements; sourceTree = "<group>"; };
D295CA45172ADBDB1E4DF708 /* TreeNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TreeNode.swift; sourceTree = "<group>"; };
D6296D5F9AFE5F266EE4B1D0 /* MacApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MacApp.swift; sourceTree = "<group>"; };
D6C3C4DD77B74C92C8C01E39 /* ConfigModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConfigModel.swift; sourceTree = "<group>"; };
EC2F56249A233EC9806D0F08 /* Bridged-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Bridged-Header.h"; sourceTree = "<group>"; };
EE605CF46DE6377C69B9D49D /* accessibility.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = accessibility.swift; sourceTree = "<group>"; };
EEDBFFCA7A77D96B18FB0732 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
Expand Down Expand Up @@ -107,8 +111,10 @@
isa = PBXGroup;
children = (
776E3F4EE298A9C69C97EF7F /* command.swift */,
651C5EE18862C252795811B3 /* config.swift */,
D6C3C4DD77B74C92C8C01E39 /* ConfigModel.swift */,
BA7CD89E786588324DFB5575 /* defaultConfig.swift */,
1C0D40CBD65704BA9595C2FA /* keysMap.swift */,
67DBAF4ECF8A0B931FC34EAD /* parseConfig.swift */,
);
path = config;
sourceTree = "<group>";
Expand Down Expand Up @@ -247,6 +253,7 @@
A2CBF9674964F9083BB198D2 /* ArrayEx.swift in Sources */,
2F8DC074DAB97DC87E07A559 /* Bundle.swift in Sources */,
1C46EBB55D401C0D1AFD50F0 /* CollectionEx.swift in Sources */,
D4F68F33C6E354856C80E729 /* ConfigModel.swift in Sources */,
B0D0C37BAE7E7F0D0FF1E9FC /* GlobalObserver.swift in Sources */,
7FE92DDAC2F094C83A177914 /* MacApp.swift in Sources */,
518B9E5AC031C24C7C84CD70 /* MacWindow.swift in Sources */,
Expand All @@ -265,8 +272,9 @@
E2FD8E2B2D2BE6B88BF8E8AD /* accessibility.swift in Sources */,
96593DF93A69CA2E05189A3F /* axObservers.swift in Sources */,
F2AFA702961A1D653EB7D269 /* command.swift in Sources */,
C39C2054893A6506C35732D7 /* config.swift in Sources */,
082EECCB2607F31DCBBF3870 /* defaultConfig.swift in Sources */,
45EA2D1C90430C432E123B51 /* keysMap.swift in Sources */,
A0765C31043BCFB0420BF1C9 /* parseConfig.swift in Sources */,
B3702BB393A9B03CCAE4C60E /* refresh.swift in Sources */,
6820E6846AE51B6988B6F673 /* utils.swift in Sources */,
);
Expand Down Expand Up @@ -352,7 +360,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 0.0.1;
MARKETING_VERSION = "0.0.1-Alpha";
PRODUCT_BUNDLE_IDENTIFIER = bobko.debug.AeroSpace;
PRODUCT_NAME = "AeroSpace-Debug";
SDKROOT = macosx;
Expand Down Expand Up @@ -434,7 +442,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 13.0;
MARKETING_VERSION = 0.0.1;
MARKETING_VERSION = "0.0.1-Alpha";
PRODUCT_BUNDLE_IDENTIFIER = bobko.AeroSpace;
PRODUCT_NAME = AeroSpace;
SDKROOT = macosx;
Expand Down
23 changes: 15 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

AeroSpace is a tiling window manager for macOS.

## Status

🚧 **Work in progress.** Alpha quality. 🚧

- Please expect a lot of bugs
- Please expect that documentation isn't complete
- Please expect that something doesn't work as expected, or doesn't work at all
- Please expect breaking changes in config format in future releases

## Key features

- **Manual** tiling window manager
Expand All @@ -16,7 +25,9 @@ AeroSpace is a tiling window manager for macOS.

## How to build the project

You would need a mac. Run in terminal:
You would need a mac.

Firstly, install [xcodegen](https://github.com/yonaskolb/XcodeGen). Then run in terminal:
```bash
./build-debug.sh
```
Expand All @@ -28,20 +39,16 @@ You would need a mac. Run in terminal:
- select parent -> outline several windows?
- OR: outline with "SLSSetWindowOpacity"
- OR: "shake" windows
- settings
- CLI interface
- Check all todos in code
- move vs swap (swap requires position and size proportions decoupling from windows)
- move vs swap
- what is src/Assets.xcassets ?
- license
- unminimize apps automatically
- minimized apps handling
- macOS fullscreen apps handling
- unhide apps automatically

## Tests

- Test main monitor change
- Test monitor add/remove

## Challenges

- Window overlapping
Expand Down
113 changes: 113 additions & 0 deletions config-examples/default-config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
[config]
after-startup-command = 'bash if [ $hostname == "NVC00112" ]; then aerospace binding nvc; else aerospace binding bobko-macbook; fi'
use-padding-for-nested-containers-with-the-same-orientation = true
auto-flatten-containers = true
# auto-different-orientation-for-nested-containers = true
# start-at-login = true
floating-windows-on-top = true

[mode.main.binding]
alt-enter = 'bash open /System/Applications/Utilities/Terminal.app'

alt-shift-quote = 'focus child'
alt-quote = 'focus parent'
alt-slash = 'layout toggle h_list v_list'
alt-comma = 'layout toggle h_accordion v_accordion'

# todo focus floating binding

# Focus window
alt-k = ['focus tiling', 'focus up']
alt-h = ['focus tiling', 'focus left']
alt-j = ['focus tiling', 'focus down']
alt-l = ['focus tiling', 'focus right']

# Move window
alt-shift-k = 'move_through up'
alt-shift-h = 'move_through left'
alt-shift-j = 'move_through down'
alt-shift-l = 'move_through right'

# Resize window
alt-shift-minus = 'resize shrink height 2 px'
alt-shift-equal = 'resize grow height 2 px'
alt-shift-comma = 'resize shrink width 2 px'
alt-shift-period = 'resize grow width 2 px'

alt-0 = 'workspace 000'
alt-1 = 'workspace 111'
alt-2 = 'workspace 222'
alt-3 = 'workspace 333'
alt-4 = 'workspace 444'
alt-5 = 'workspace 555'
alt-6 = 'workspace 666'
alt-7 = 'workspace 777'
alt-8 = 'workspace 888'
alt-9 = 'workspace 999'
alt-a = 'workspace AAA'
alt-b = 'workspace BBB'
alt-c = 'workspace CCC'
alt-d = 'workspace DDD'
alt-e = 'workspace EEE'
alt-f = 'workspace FFF'
alt-g = 'workspace GGG'
alt-i = 'workspace III'
alt-m = 'workspace MMM'
alt-n = 'workspace NNN'
alt-o = 'workspace OOO'
alt-p = 'workspace PPP'
alt-q = 'workspace QQQ'
alt-r = 'workspace RRR'
alt-s = 'workspace SSS'
alt-t = 'workspace TTT'
alt-u = 'workspace UUU'
alt-v = 'workspace VVV'
alt-w = 'workspace WWW'
alt-x = 'workspace XXX'
alt-y = 'workspace YYY'
alt-z = 'workspace ZZZ'

alt-shift-0 = 'move container to workspace 000'
alt-shift-1 = 'move container to workspace 111'
alt-shift-2 = 'move container to workspace 222'
alt-shift-3 = 'move container to workspace 333'
alt-shift-4 = 'move container to workspace 444'
alt-shift-5 = 'move container to workspace 555'
alt-shift-6 = 'move container to workspace 666'
alt-shift-7 = 'move container to workspace 777'
alt-shift-8 = 'move container to workspace 888'
alt-shift-9 = 'move container to workspace 999'
alt-shift-a = 'move container to workspace AAA'
alt-shift-b = 'move container to workspace BBB'
alt-shift-c = 'move container to workspace CCC'
alt-shift-d = 'move container to workspace DDD'
alt-shift-e = 'move container to workspace EEE'
alt-shift-f = 'move container to workspace FFF'
alt-shift-g = 'move container to workspace GGG'
alt-shift-i = 'move container to workspace III'
alt-shift-m = 'move container to workspace MMM'
alt-shift-n = 'move container to workspace NNN'
alt-shift-o = 'move container to workspace OOO'
alt-shift-p = 'move container to workspace PPP'
alt-shift-q = 'move container to workspace QQQ'
alt-shift-r = 'move container to workspace RRR'
alt-shift-s = 'move container to workspace SSS'
alt-shift-t = 'move container to workspace TTT'
alt-shift-u = 'move container to workspace UUU'
alt-shift-v = 'move container to workspace VVV'
alt-shift-w = 'move container to workspace WWW'
alt-shift-x = 'move container to workspace XXX'
alt-shift-y = 'move container to workspace YYY'
alt-shift-z = 'move container to workspace ZZZ'

alt-tab = 'workspace back_and_forth'

alt-shift-slash.alt-shift-k = 'move_in up'
alt-shift-slash.alt-shift-h = 'move_in left'
alt-shift-slash.alt-shift-j = 'move_in down'
alt-shift-slash.alt-shift-l = 'move_in right'

# aerospace config set mode.main.binding.alt-l 'focus tiling' 'focus right'
# aerospace config set mode.main.binding.alt-enter 'basn alacritty'
# aerospace config set mode.main.binding.alt-shift-slash.alt-shift-l 'move_in right'
# aerospace config set config.start-at-login false
65 changes: 65 additions & 0 deletions config-examples/i3-like-config-example.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Reference: https://github.com/i3/i3/blob/next/etc/config

auto-flatten-containers = false

[mode.main.binding]
alt-enter = 'bash open /System/Applications/Utilities/Terminal.app'

alt-h = 'focus left'
alt-j = 'focus down'
alt-k = 'focus up'
alt-l = 'focus right'

alt-shift-h = 'move_through left'
alt-shift-j = 'move_through down'
alt-shift-k = 'move_through up'
alt-shift-l = 'move_through right'

# alt-h = 'split h' # todo support split command?
# alt-v = 'split v' # todo support split command?

# alt-f = 'fullscreen' # todo support fullscreen command?

alt-s = 'layout v_accordion' # 'layout stacking' in i3
alt-w = 'layout h_accordion' # 'layout tabbed' in i3
alt-e = 'layout h_list v_list' # 'layout toggle list' in i3

alt-shift-space = 'layout floating tiling' # 'floating toggle' in i3
alt-space = 'focus toggle_tiling_floating'

alt-a = 'focus parent'

alt-1 = 'workspace 1'
alt-2 = 'workspace 2'
alt-3 = 'workspace 3'
alt-4 = 'workspace 4'
alt-5 = 'workspace 5'
alt-6 = 'workspace 6'
alt-7 = 'workspace 7'
alt-8 = 'workspace 8'
alt-9 = 'workspace 9'
alt-0 = 'workspace 10'

alt-shift-1 = 'move container to workspace 1'
alt-shift-2 = 'move container to workspace 2'
alt-shift-3 = 'move container to workspace 3'
alt-shift-4 = 'move container to workspace 4'
alt-shift-5 = 'move container to workspace 5'
alt-shift-6 = 'move container to workspace 6'
alt-shift-7 = 'move container to workspace 7'
alt-shift-8 = 'move container to workspace 8'
alt-shift-9 = 'move container to workspace 9'
alt-shift-0 = 'move container to workspace 10'

alt-shift-c = 'reload_config'

alt-r = 'mode resize'

[mode.resize.binding]
# todo does it work?
h = 'resize shrink width 10'
j = 'resize grow height 10'
k = 'resize shrink height 10'
l = 'resize grow width 10'
enter = 'mode main'
esc = 'mode esc'
4 changes: 2 additions & 2 deletions project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ targets:
SWIFT_VERSION: 5.8
CODE_SIGN_STYLE: Automatic
GENERATE_INFOPLIST_FILE: YES
CURRENT_PROJECT_VERSION: 1 # Build number CFBundleVersion
MARKETING_VERSION: 0.0.1 # User visible version CFBundleShortVersionString
CURRENT_PROJECT_VERSION: 1 # Build number CFBundleVersion
MARKETING_VERSION: 0.0.1-Alpha # User visible version CFBundleShortVersionString
SWIFT_OBJC_BRIDGING_HEADER: "src/Bridged-Header.h"
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html#//apple_ref/doc/uid/20001431-108256
# Specifies whether the app runs as an agent app. If this key is set to YES, Launch Services runs the app as an agent app.
Expand Down
52 changes: 52 additions & 0 deletions src/config/ConfigModel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import HotKey

struct ConfigRoot {
let config: Config
let modes: [String: Mode]
}

struct Config {
let afterStartupCommand: Command
let usePaddingForNestedContainersWithTheSameOrientation: Bool
let autoFlattenContainers: Bool
let floatingWindowsOnTop: Bool
}

struct Mode {
/// User visible name. Optional. todo drop it?
let name: String?
let bindings: [HotkeyBinding]

func activate() {
for binding in bindings {
binding.activate()
}
}

func deactivate() {
for binding in bindings {
binding.deactivate()
}
}
}

class HotkeyBinding {
let modifiers: NSEvent.ModifierFlags
let key: Key
let command: Command
private var hotKey: HotKey? = nil

init(_ modifiers: NSEvent.ModifierFlags, _ key: Key, _ command: Command) {
self.modifiers = modifiers
self.key = key
self.command = command
}

func activate() {
hotKey = HotKey(key: key, modifiers: modifiers, keyUpHandler: command.run)
}

func deactivate() {
hotKey = nil
}
}
Loading

0 comments on commit dff8dc4

Please sign in to comment.