panel: add output selection

parent ddbe4520
...@@ -57,6 +57,16 @@ Supported panel types: ...@@ -57,6 +57,16 @@ Supported panel types:
panel, floating, islands 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 ## Module Resolution
The config stores logical module names. At generation time, the panel merges The config stores logical module names. At generation time, the panel merges
......
{ {
"position": "top", "position": "top",
"type": "panel", "type": "panel",
"output": [],
"modules_left": [ "modules_left": [
"image#menu", "image#menu",
"tray" "tray"
...@@ -17,4 +18,4 @@ ...@@ -17,4 +18,4 @@
"bluetooth", "bluetooth",
"custom/notification" "custom/notification"
] ]
} }
\ No newline at end of file
...@@ -20,6 +20,7 @@ const ( ...@@ -20,6 +20,7 @@ const (
type Config struct { type Config struct {
Position string `json:"position"` Position string `json:"position"`
Type string `json:"type"` Type string `json:"type"`
Output []string `json:"output"`
ModulesLeft []string `json:"modules_left"` ModulesLeft []string `json:"modules_left"`
ModulesCenter []string `json:"modules_center"` ModulesCenter []string `json:"modules_center"`
ModulesRight []string `json:"modules_right"` ModulesRight []string `json:"modules_right"`
...@@ -76,6 +77,12 @@ func (c Config) Validate() error { ...@@ -76,6 +77,12 @@ func (c Config) Validate() error {
return fmt.Errorf("unsupported panel type %q", c.Type) 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...)...) { for _, name := range append(append([]string{}, c.ModulesLeft...), append(c.ModulesCenter, c.ModulesRight...)...) {
if strings.TrimSpace(name) == "" { if strings.TrimSpace(name) == "" {
return errors.New("module name cannot be empty") return errors.New("module name cannot be empty")
......
...@@ -30,6 +30,10 @@ func GenerateConfig(cfg Config, registry Registry) ([]byte, error) { ...@@ -30,6 +30,10 @@ func GenerateConfig(cfg Config, registry Registry) ([]byte, error) {
out["name"] = cfg.Type out["name"] = cfg.Type
} }
if len(cfg.Output) > 0 {
out["output"] = cfg.Output
}
if cfg.Type == "floating" || cfg.Type == "islands" { if cfg.Type == "floating" || cfg.Type == "islands" {
applyFloatingMargins(out, cfg.Position) 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