panel: add spacing option

parent d748843c
...@@ -67,6 +67,14 @@ Optional monitor filter: ...@@ -67,6 +67,14 @@ Optional monitor filter:
An empty or missing `output` list leaves Waybar on its default outputs. An empty or missing `output` list leaves Waybar on its default outputs.
Module spacing:
```json
{
"spacing": 10
}
```
## 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
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
"position": "top", "position": "top",
"type": "panel", "type": "panel",
"output": [], "output": [],
"spacing": 10,
"modules_left": [ "modules_left": [
"image#menu", "image#menu",
"tray" "tray"
......
...@@ -21,6 +21,7 @@ type Config struct { ...@@ -21,6 +21,7 @@ type Config struct {
Position string `json:"position"` Position string `json:"position"`
Type string `json:"type"` Type string `json:"type"`
Output []string `json:"output"` Output []string `json:"output"`
Spacing int `json:"spacing"`
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"`
...@@ -83,6 +84,10 @@ func (c Config) Validate() error { ...@@ -83,6 +84,10 @@ func (c Config) Validate() error {
} }
} }
if c.Spacing < 0 {
return errors.New("spacing cannot be negative")
}
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")
......
...@@ -14,7 +14,7 @@ func GenerateConfig(cfg Config, registry Registry) ([]byte, error) { ...@@ -14,7 +14,7 @@ func GenerateConfig(cfg Config, registry Registry) ([]byte, error) {
"margin-top": 0, "margin-top": 0,
"margin-right": 0, "margin-right": 0,
"margin-bottom": 0, "margin-bottom": 0,
"spacing": 10, "spacing": cfg.Spacing,
"exclusive": true, "exclusive": true,
"fixed-center": true, "fixed-center": true,
"reload_style_on_change": true, "reload_style_on_change": true,
......
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