-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: iosmanthus <[email protected]>
- Loading branch information
1 parent
db2af57
commit 4dcbdb3
Showing
41 changed files
with
766 additions
and
327 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
{ pkgs, ... }: | ||
let | ||
nextAppWin = pkgs.writers.writePython3 "nextAppWin" { | ||
libraries = [ ]; | ||
flakeIgnore = [ "E501" ]; | ||
} (builtins.readFile ./next_app_win.py); | ||
searchWin = pkgs.writers.writePython3 "searchWin" { | ||
libraries = [ ]; | ||
flakeIgnore = [ "E501" ]; | ||
} (builtins.readFile ./search_win.py); | ||
in | ||
{ | ||
services.aerospace = { | ||
enable = true; | ||
settings = { | ||
enable-normalization-flatten-containers = false; | ||
enable-normalization-opposite-orientation-for-nested-containers = false; | ||
default-root-container-layout = "accordion"; | ||
exec = { | ||
inherit-env-vars = true; | ||
}; | ||
on-window-detected = [ | ||
# Termainal | ||
{ | ||
"if".app-id = "net.kovidgoyal.kitty"; | ||
run = [ "move-node-to-workspace 1" ]; | ||
} | ||
# Browsers | ||
{ | ||
"if".app-id = "org.mozilla.firefox"; | ||
run = [ "move-node-to-workspace 1" ]; | ||
} | ||
{ | ||
"if".app-id = "com.apple.mail"; | ||
run = [ "move-node-to-workspace 3" ]; | ||
} | ||
# Music | ||
{ | ||
"if".app-id = "com.apple.Music"; | ||
run = [ "move-node-to-workspace 4" ]; | ||
} | ||
# IMs | ||
{ | ||
"if".app-id = "ru.keepcoder.Telegram"; | ||
run = [ "move-node-to-workspace 2" ]; | ||
} | ||
{ | ||
"if".app-id = "com.hnc.Discord"; | ||
run = [ "move-node-to-workspace 2" ]; | ||
} | ||
{ | ||
"if".app-id = "com.tencent.xinWeChat"; | ||
run = [ "move-node-to-workspace 2" ]; | ||
} | ||
{ | ||
"if".app-id = "com.electron.lark"; | ||
run = [ "move-node-to-workspace 2" ]; | ||
} | ||
# Notes | ||
{ | ||
"if".app-id = "com.electron.logseq"; | ||
run = [ "move-node-to-workspace 5" ]; | ||
} | ||
]; | ||
mode.main.binding = { | ||
alt-s = "layout v_accordion"; # "layout stacking" in i3 | ||
alt-w = "layout h_accordion"; # "layout tabbed" in i3 | ||
alt-e = "layout tiles horizontal vertical"; # "layout toggle split" in i3 | ||
alt-shift-space = "layout floating tiling"; # 'floating toggle' in i3 | ||
|
||
alt-v = "split vertical"; | ||
alt-shift-v = "split horizontal"; | ||
|
||
alt-f = "fullscreen"; | ||
alt-shift-f = "macos-native-fullscreen"; | ||
alt-q = "close --quit-if-last-window"; | ||
|
||
alt-h = "focus left"; | ||
alt-j = "focus down"; | ||
alt-k = "focus up"; | ||
alt-l = "focus right"; | ||
alt-shift-h = "move left"; | ||
alt-shift-j = "move down"; | ||
alt-shift-k = "move up"; | ||
alt-shift-l = "move right"; | ||
|
||
alt-leftSquareBracket = "exec-and-forget ${nextAppWin} prev"; | ||
alt-rightSquareBracket = "exec-and-forget ${nextAppWin} next"; | ||
alt-p = "exec-and-forget ${searchWin}"; | ||
|
||
alt-1 = "workspace 1"; | ||
alt-2 = "workspace 2"; | ||
alt-3 = "workspace 3"; | ||
alt-4 = "workspace 4"; | ||
alt-5 = "workspace 5"; | ||
alt-shift-1 = "move-node-to-workspace 1"; | ||
alt-shift-2 = "move-node-to-workspace 2"; | ||
alt-shift-3 = "move-node-to-workspace 3"; | ||
alt-shift-4 = "move-node-to-workspace 4"; | ||
alt-shift-5 = "move-node-to-workspace 5"; | ||
|
||
alt-tab = "workspace-back-and-forth"; | ||
|
||
alt-b = "exec-and-forget open /Applications/Firefox.app"; | ||
alt-c = "exec-and-forget open ${pkgs.vscode}/Applications/Visual\\ Studio\\ Code.app"; | ||
alt-enter = "exec-and-forget open ${pkgs.kitty}/Applications/kitty.app"; | ||
alt-m = "exec-and-forget open /System/Applications/Music.app"; | ||
}; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import subprocess | ||
import sys | ||
import json | ||
|
||
|
||
def get_focused_window(): | ||
return json.loads( | ||
subprocess.check_output( | ||
["aerospace", "list-windows", "--focused", "--json"] | ||
).decode("utf-8") | ||
)[0] | ||
|
||
|
||
def get_all_windows_in_workspace(): | ||
return json.loads( | ||
subprocess.check_output( | ||
["aerospace", "list-windows", "--workspace", "focused", "--json"] | ||
).decode("utf-8") | ||
) | ||
|
||
|
||
def move_to_window(window_id): | ||
subprocess.run(["aerospace", "focus", "--window-id", str(window_id)]) | ||
|
||
|
||
if __name__ == "__main__": | ||
direction = 1 | ||
if sys.argv[1] == "prev": | ||
direction = -1 | ||
current_win = get_focused_window() | ||
all_win = get_all_windows_in_workspace() | ||
app_wins = list(filter(lambda w: w["app-name"] == current_win["app-name"], all_win)) | ||
next_idx = 0 | ||
for idx, win in enumerate(app_wins): | ||
if win["window-id"] == current_win["window-id"]: | ||
next_idx = (idx + direction) % len(app_wins) | ||
break | ||
move_to_window(app_wins[next_idx]["window-id"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import subprocess | ||
import json | ||
|
||
if __name__ == "__main__": | ||
wins = json.loads( | ||
subprocess.check_output( | ||
["aerospace", "list-windows", "--all", "--json"] | ||
).decode("utf-8") | ||
) | ||
output = "" | ||
for idx, win in enumerate(wins): | ||
output += f'{idx} | {win["app-name"]} {win['window-title']}\n' | ||
|
||
choose = subprocess.Popen(["choose"], stdin=subprocess.PIPE, stdout=subprocess.PIPE) | ||
|
||
selected, _ = choose.communicate(bytes(output, "utf-8")) | ||
selected_idx = int(selected.decode("utf-8").split("|")[0].strip()) | ||
subprocess.run( | ||
["aerospace", "focus", "--window-id", str(wins[selected_idx]["window-id"])] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.