diff --git a/config-examples/default-config.toml b/config-examples/default-config.toml index fdd1e0d4..efbe9e21 100644 --- a/config-examples/default-config.toml +++ b/config-examples/default-config.toml @@ -1,4 +1,4 @@ -# Place a copy of this config to ~/.aerospace.toml. After that you can edit ~/.aerospace.toml to your liking +# Place a copy of this config to ~/.aerospace.toml. After that, you can edit ~/.aerospace.toml to your liking # You can use it to add commands that run after login to macOS user session. # 'start-at-login' needs to be 'true' for 'after-login-command' to work @@ -47,8 +47,8 @@ default-root-container-orientation = 'auto' # alt-enter = 'exec-and-forget open -n /System/Applications/Utilities/Terminal.app' # See: https://github.com/nikitabobko/AeroSpace/blob/main/docs/commands.md#layout -alt-slash = 'layout h_list v_list' -alt-comma = 'layout h_accordion v_accordion' +alt-slash = 'layout list horizontal vertical' +alt-comma = 'layout accordion horizontal vertical' # See: https://github.com/nikitabobko/AeroSpace/blob/main/docs/commands.md#focus alt-h = 'focus left' @@ -147,9 +147,9 @@ alt-shift-slash = 'mode move-in' [mode.service.binding] r = ['flatten-workspace-tree', 'mode main'] o = ['reload-config', 'mode main'] -#s = ['layout sticky tiling', 'mode main'] # todo sticky is not yet supported +#s = ['layout sticky tiling', 'mode main'] # sticky is not yet supported https://github.com/nikitabobko/AeroSpace/issues/2 f = ['layout floating tiling', 'mode main'] # Toggle between floating and tiling layout -backslash = ['close-all-windows-but-current', 'mode main'] +backspace = ['close-all-windows-but-current', 'mode main'] esc = 'mode main' enter = 'mode main' diff --git a/config-examples/i3-like-config-example.toml b/config-examples/i3-like-config-example.toml index 0422b3d5..31c4e8d4 100644 --- a/config-examples/i3-like-config-example.toml +++ b/config-examples/i3-like-config-example.toml @@ -1,7 +1,5 @@ # Reference: https://github.com/i3/i3/blob/next/etc/config -# todo finish - enable-normalization-flatten-containers = false enable-normalization-opposite-orientation-for-nested-containers = false @@ -21,11 +19,11 @@ 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-f = 'fullscreen' # todo support fullscreen command? https://github.com/nikitabobko/AeroSpace/issues/7 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-e = 'layout list horizontal vertical' # 'layout toggle split' in i3 alt-shift-space = 'layout floating tiling' # 'floating toggle' in i3 @@ -34,6 +32,7 @@ alt-shift-space = 'layout floating tiling' # 'floating toggle' in i3 #alt-space = 'focus toggle_tiling_floating' # `focus parent`/`focus child` are not yet supported, and it's not clear whether they should be supported at all +# https://github.com/nikitabobko/AeroSpace/issues/5 # alt-a = 'focus parent' alt-1 = 'workspace 1' diff --git a/docs/commands.md b/docs/commands.md index 111afe03..c7ee9cfc 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -1,17 +1,123 @@ # Commands +**Table of contents** +- [close-all-windows-but-current](#close-all-windows-but-current) +- [exec-and-forget](#exec-and-forget) +- [exec-and-wait](#exec-and-wait) +- [flatten-workspace-tree](#flatten-workspace-tree) +- [focus](#focus) +- [layout](#layout) +- [mode](#mode) +- [move-container-to-workspace](#move-container-to-workspace) +- [move-in](#move-in) +- [move-through](#move-through) +- [move-workspace-to-display](#move-workspace-to-display) +- [reload-config](#reload-config) +- [resize](#resize) +- [workspace-back-and-forth](#workspace-back-and-forth) +- [workspace](#workspace) + +## close-all-windows-but-current + +``` +close-all-windows-but-current +``` + +On the focused workspace, closes all windows but current. This command doesn't have any arguments. + ## exec-and-forget +``` +exec-and-forget bash_command +``` + +Runs `/bin/bash -c '$bash_command'`. Stdout, stderr and exit code are ignored. + +For example, you can use this command to launch applications: `exec-and-forget open -n /System/Applications/Utilities/Terminal.app` + ## exec-and-wait +``` +exec-and-wait bash_command +``` + +Runs `/bin/bash -c '$bash_command'`, and waits until the command is terminated. Stdout, stderr and exit code are ignored. + +Please prefer `exec-and-forget`, unless you need to wait for the termination. + +You might want to wait for the termination if you have a list of commands, and you want `bash_command` to exit until you run the +next command. + +Suppose that you have this binding in your config: +```toml +alt-enter = ['exec-and-wait open -n /System/Applications/Utilities/Terminal.app && sleep 1', 'layout floating'] +``` + +It will open up Terminal.app and make it float. `sleep 1` is still required because `open` returns before the window appears. + +## flatten-workspace-tree + +``` +flatten-workspace-tree +``` + +Flattens [the tree](./guide.md#tree) of currently focused workspace. This command doesn't have any arguments. + +The command is useful when you messed up with your layout, and it's easier to "reset" it and start again. + +## focus + +``` +focus (left|down|up|right) +``` + +Sets focus to the nearest window in [the tree](./guide.md#tree) in the given direction. + +[Contrary to i3](https://i3wm.org/docs/userguide.html#_focusing_moving_containers), `focus` command doesn't have a separate +argument to focus floating windows. From `focus` command perspective, floating windows are part of [the tree](./guide.md#tree). +The floating window parent is determined as the smallest tiling container that contains the center of the floating window. + +This technique eliminates the need for an additional binding for floating windows. + +`focus child|parent` [isn't yet supported](https://github.com/nikitabobko/AeroSpace/issues/5) because of a low priority. + ## layout -> `layout (h_list|v_list|h_accordion|v_accordion|tiling|floating|sticky...)` +``` +layout (h_list|v_list|h_accordion|v_accordion|list|accordion|horizontal|vertical|tiling|floating)... +``` -## move-through +Changes layout of the focused window to the given layout. + +If several arguments are supplied then the first layout that describes the currently active is found. The layout specified after +the found one will be applied. If the currently active layout is not in the list, the first layout in the list will be activated. + +`layout tiling` is the only command that makes the focused floating window tiled. ## mode -> SYNO +``` +mode name_of_the_target_mode +``` + +## move-container-to-workspace + +## move-in + +## move-through + +``` +move-through (left|down|up|right) +``` + +This command is an analog of [i3's move command](https://i3wm.org/docs/userguide.html#move_direction) + +## move-workspace-to-display ## reload-config + +## resize + +## workspace-back-and-forth + +## workspace diff --git a/docs/guide.md b/docs/guide.md index a15c00bb..393999cd 100644 --- a/docs/guide.md +++ b/docs/guide.md @@ -23,8 +23,8 @@ TODO DOCUMENTATION ### Floating windows TODO DOCUMENTATION -Normally, floating windows are not part of the tiling tree except for the 'focus' command. From 'focus' command perspective, -floating windows are part of the tree. +Normally, floating windows are not part of the tiling tree. But it's not the case with `focus` command. From `focus` command +perspective, floating windows are part of the tree. ## Default keybindings TODO DOCUMENTATION the idea behind default keybindings diff --git a/src/command/FocusCommand.swift b/src/command/FocusCommand.swift index f3ecb40f..229748b4 100644 --- a/src/command/FocusCommand.swift +++ b/src/command/FocusCommand.swift @@ -5,6 +5,7 @@ struct FocusCommand: Command { check(Thread.current.isMainThread) guard let currentWindow = focusedWindowOrEffectivelyFocused else { return } let workspace = currentWindow.workspace + // todo floating windows break mru let floatingWindows = makeFloatingWindowsSeenAsTiling(workspace: workspace) defer { restoreFloatingWindows(floatingWindows: floatingWindows, workspace: workspace)