remove hard-coded layout names

This commit is contained in:
2026-07-14 00:36:43 +02:00
parent 4a74cf04c8
commit f70ea7f0f5
2 changed files with 17 additions and 3 deletions
+14
View File
@@ -8,4 +8,18 @@ struct PHConfig: Decodable {
case theme, window, layout case theme, window, layout
case monitors = "monitor" case monitors = "monitor"
} }
var layouts: Set<String> {
var layouts = Set<String>()
layouts.insert(layout)
guard let monitors else { return layouts }
for monitor in monitors.values {
if let layout = monitor.layout {
layouts.insert(layout)
}
}
return layouts
}
} }
@@ -4,7 +4,7 @@ import TOML
extension PHLayout { extension PHLayout {
/// Load the specified layouts from the resolved config directory (see `PHPaths`). /// Load the specified layouts from the resolved config directory (see `PHPaths`).
/// If any of theme doesn't exist or fails to parse, the execution is interrupted. /// If any of theme doesn't exist or fails to parse, the execution is interrupted.
static func load(_ layouts: [String]) throws -> [String: PHLayout] { static func load(_ layouts: Set<String>) throws -> [String: PHLayout] {
var dictionary = [String: PHLayout]() var dictionary = [String: PHLayout]()
for layout in layouts { for layout in layouts {
@@ -29,8 +29,8 @@ extension PHLayout {
Make sure to have a file named `\(layout)` inside the Make sure to have a file named `\(layout)` inside the
directory: `\(PHPaths.layoutsDirectory.relativePath)` directory: `\(PHPaths.layoutsDirectory.relativePath)`
Tip: If you've never used phbar before, run the `phbar install` command Tip: If you've never used phbar before, run `phbar generate config`
to automatically generate all the required configuration files. to automatically generate the required configuration files.
""" """
) )
} }