-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkomorebi-tray.ahk
104 lines (91 loc) · 2.84 KB
/
komorebi-tray.ahk
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
; komorebi-tray.ahk:
; A tray app for komorebi tiling window manager.
; Author: Andrea Brandi <git@andreabrandi.com>
;@Ahk2Exe-Let version=0.1.1
;@Ahk2Exe-SetVersion %U_version%
;@Ahk2Exe-SetProductVersion %U_version%
;@Ahk2Exe-SetName Komorebi Tray
;@Ahk2Exe-SetDescription Komorebi Tray
;@Ahk2Exe-SetCopyright Copyright (c) 2024`, Andrea Brandi
;@Ahk2Exe-SetLanguage 0x0409
;@Ahk2Exe-SetMainIcon ./images/ico/app.ico
#Requires AutoHotkey v2.0
#SingleInstance Force
Persistent
#Include %A_ScriptDir%\lib\Komorebi.ahk
#Include %A_ScriptDir%\lib\KomorebiEvents.ahk
#Include %A_ScriptDir%\lib\KomorebiProfile.ahk
#Include %A_ScriptDir%\lib\KomorebiTray.ahk
#Include %A_ScriptDir%\lib\Settings.ahk
Startup() {
if ( not Komorebi.CONFIG_HOME) {
userChoice := MsgBox(
Format("══ {:U} {:T} ══`n`n", "KOMOREBI_CONFIG_HOME", "is required")
"Press [Continue] to read the documentation.`n", ,
"CancelTryAgainContinue"
)
Switch userChoice {
Case "Continue":
Run("https://github.com/starise/komorebi-tray")
ExitApp()
Case "TryAgain":
Reload()
Default:
ExitApp()
}
}
if ( not FileExist(Komorebi.configJson)) {
DirCreate(Komorebi.CONFIG_HOME)
if (FileExist(Komorebi.userProfileJson)) {
MsgBox(
"Detected: " Komorebi.userProfileJson "`n`n" .
"Moving to: " Komorebi.configJson
)
FileMove(Komorebi.userProfileJson, Komorebi.configJson)
} else {
MsgBox(
"komorebi.json and applications.json not detected.`n`n" .
"Downloading defaults to: " Komorebi.CONFIG_HOME
)
Komorebi.newConfigFiles()
}
}
; Add default profiles if they don't exist
if ( not DirExist(KomorebiProfile.folder)) {
MsgBox(
Format("══ {:T} ══`n`n", "Profile folder not detected")
"Creating new defaults to: " KomorebiProfile.folder
)
DirCopy(A_ScriptDir "\profiles", KomorebiProfile.folder)
}
; Load all profiles from the folder
profiles := KomorebiProfile.getAll()
if (FileExist(Settings.configFile)) {
KomorebiProfile.active := Settings.load("active", "profiles")
} else {
MsgBox(
Format("══ {:T} ══`n`n", "Configuration file not detected")
"Creating new defaults to: " Settings.configFile
)
KomorebiProfile.active := profiles[1]
Settings.save(profiles[1], "active", "profiles")
}
KomorebiTray.create(profiles)
KomorebiProfile.enable(KomorebiProfile.active)
if ( not Komorebi.isRunning) {
try {
RunWait(("komorebic.exe"), , "Hide")
}
catch {
MsgBox(
"Komorebi not found.`n" .
"Install it and try again."
)
ExitApp()
}
Komorebi.start()
}
KomorebiEvents.start()
}
TraySetIcon("images/ico/app.ico")
Startup()