panel: add output selection

parent ddbe4520
......@@ -57,6 +57,16 @@ Supported panel types:
panel, floating, islands
```
Optional monitor filter:
```json
{
"output": ["DP-1", "HDMI-A-1"]
}
```
An empty or missing `output` list leaves Waybar on its default outputs.
## Module Resolution
The config stores logical module names. At generation time, the panel merges
......
{
"position": "top",
"type": "panel",
"output": [],
"modules_left": [
"image#menu",
"tray"
......@@ -17,4 +18,4 @@
"bluetooth",
"custom/notification"
]
}
\ No newline at end of file
}
......@@ -20,6 +20,7 @@ const (
type Config struct {
Position string `json:"position"`
Type string `json:"type"`
Output []string `json:"output"`
ModulesLeft []string `json:"modules_left"`
ModulesCenter []string `json:"modules_center"`
ModulesRight []string `json:"modules_right"`
......@@ -76,6 +77,12 @@ func (c Config) Validate() error {
return fmt.Errorf("unsupported panel type %q", c.Type)
}
for _, output := range c.Output {
if strings.TrimSpace(output) == "" {
return errors.New("output name cannot be empty")
}
}
for _, name := range append(append([]string{}, c.ModulesLeft...), append(c.ModulesCenter, c.ModulesRight...)...) {
if strings.TrimSpace(name) == "" {
return errors.New("module name cannot be empty")
......
......@@ -30,6 +30,10 @@ func GenerateConfig(cfg Config, registry Registry) ([]byte, error) {
out["name"] = cfg.Type
}
if len(cfg.Output) > 0 {
out["output"] = cfg.Output
}
if cfg.Type == "floating" || cfg.Type == "islands" {
applyFloatingMargins(out, cfg.Position)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment