-
Notifications
You must be signed in to change notification settings - Fork 1
/
start.ts
84 lines (69 loc) · 1.97 KB
/
start.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import { sleep } from "bun"
import type { ChunkWithId, Coordinates, Dimensions } from "./types"
import { createCtlAnimationString } from "./helper"
import { createFrameAnimationCommands } from "./process"
const numberOfTiles = 64
const screenSize: Dimensions = Bun.spawnSync(["xdpyinfo"])
.stdout.toString()
.match(/dimensions:(.*) pixels/)
?.at(1)
?.trim()
.split("x")
.map(Number) as Dimensions
const terminal = "alacritty"
await Promise.all(
Array.from({ length: numberOfTiles }).map(
() =>
Bun.spawn([terminal], {
stdout: "ignore",
stderr: "ignore",
stdin: "ignore",
}).pid
)
)
await sleep(7850)
const terminals: ChunkWithId[] = (
JSON.parse(
Bun.spawnSync(["hyprctl", "clients", "-j"]).stdout.toString()
) as Record<string, any>[]
)
.filter(
({ initialClass }) => initialClass.toLowerCase() === terminal.toLowerCase()
)
.map(({ at, size, pid }) => ({
id: pid,
chunk: [size, at],
}))
await sleep(500)
const startCommands = terminals.flatMap(({ id }, index, all) => {
const total = all.length
const columns = 4
const rows = Math.floor(total / columns)
const newSize: Dimensions = [
Math.floor(screenSize[0] / columns),
Math.floor(screenSize[1] / rows),
]
const newCoordinates: Coordinates = [
(index % columns) * newSize[0],
Math.floor(index / columns) * newSize[1],
]
return createCtlAnimationString(id, newCoordinates, newSize)
})
const keywords = [
"decoration:drop_shadow false",
"decoration:rounding 0",
"general:border_size 0",
]
.map((keyword) => "keyword " + keyword)
.join(";")
Bun.spawnSync(`hyprctl --batch "${keywords}"`.split(" "))
startCommands.map((string) => string.split(" ")).forEach(Bun.spawnSync)
Bun.spawnSync("hyprctl keyword animations:enabled false".split(" "))
const animationCommand = createFrameAnimationCommands(terminals, screenSize)
await sleep(500)
animationCommand
.slice(animationCommand.length - 2)
.map((string) => string.split(" "))
.forEach((command, index) => {
Bun.spawnSync(command)
})