From f70ea7f0f556a9da410a206edeb9e3233bd94a2a Mon Sep 17 00:00:00 2001 From: Tommaso Negri Date: Tue, 14 Jul 2026 00:36:43 +0200 Subject: [PATCH] remove hard-coded layout names --- Sources/phbar/Models/PHConfig.swift | 14 ++++++++++++++ .../phbar/Models/PHLayout/PHLayout+Loading.swift | 6 +++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/Sources/phbar/Models/PHConfig.swift b/Sources/phbar/Models/PHConfig.swift index 48ac90f..31d747b 100644 --- a/Sources/phbar/Models/PHConfig.swift +++ b/Sources/phbar/Models/PHConfig.swift @@ -8,4 +8,18 @@ struct PHConfig: Decodable { case theme, window, layout case monitors = "monitor" } + + var layouts: Set { + var layouts = Set() + layouts.insert(layout) + + guard let monitors else { return layouts } + for monitor in monitors.values { + if let layout = monitor.layout { + layouts.insert(layout) + } + } + + return layouts + } } diff --git a/Sources/phbar/Models/PHLayout/PHLayout+Loading.swift b/Sources/phbar/Models/PHLayout/PHLayout+Loading.swift index 5dbf4c5..4a5a74e 100644 --- a/Sources/phbar/Models/PHLayout/PHLayout+Loading.swift +++ b/Sources/phbar/Models/PHLayout/PHLayout+Loading.swift @@ -4,7 +4,7 @@ import TOML extension PHLayout { /// 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. - static func load(_ layouts: [String]) throws -> [String: PHLayout] { + static func load(_ layouts: Set) throws -> [String: PHLayout] { var dictionary = [String: PHLayout]() for layout in layouts { @@ -29,8 +29,8 @@ extension PHLayout { Make sure to have a file named `\(layout)` inside the directory: `\(PHPaths.layoutsDirectory.relativePath)` - Tip: If you've never used phbar before, run the `phbar install` command - to automatically generate all the required configuration files. + Tip: If you've never used phbar before, run `phbar generate config` + to automatically generate the required configuration files. """ ) }