2 Commits
v1.8 ... v1.9

Author SHA1 Message Date
eleksir
d9ce425981 Finally fix parsing of app buttons, now settings and fallback values should work as expected 2025-07-15 14:29:27 +03:00
eleksir
069b09e5ec Update default config example 2025-07-12 14:00:55 +03:00
3 changed files with 52 additions and 27 deletions

View File

@@ -2,7 +2,7 @@
// Default text and *block* border colors. If not set #3e78fd is used.
"color" : "#3e78fd",
// Default backbround color. If not set value of #edeceb is used.
// Default background color. If not set value of #edeceb is used.
"background" : "#000000",
// Can be omitted, then Liberation Mono will be used.
@@ -12,7 +12,7 @@
// ‘smaller’ or ‘larger’
"font_size": "medium",
"separator" : {
"separator": {
"left": {
// Set to false if omitted.
"enabled": true,
@@ -778,6 +778,19 @@
"app_buttons": {
"enabled": true,
// If omitted set to default color defined up here.
"color": "#3e78fd",
// If omitted set to default background color defined up here.
"background": "#000000",
// If omitted set to default font defined up here.
"font": "Noto Sans",
// ‘xx-small’, ‘x-small’, ‘small’, ‘medium’, ‘large’, ‘x-large’, ‘xx-large’, or one of relative sizes
// ‘smaller’ or ‘larger’. If omitted set to default font size defined up here.
"font_size": "medium",
// Re-define separator parameters for net-if block here.
"separator": {
"left": {
@@ -821,31 +834,36 @@
// ‘smaller’ or ‘larger’. If omitted set to default font size defined for separator up here.
"font_size": "medium"
}
},
}
},
// Buttons - application launch "buttons"
"apps": [
{
// Text dispalyed on button
// Text displayed on button, pango markup supported.
"full_text" : "📂",
// Internal name, can be any string, but unique for each app button
// Internal name, can be any string, but unique for each app button.
"name" : "thunar",
// Command itself
// Command itself.
"cmd" : "thunar",
// Array of command args, optional
// Array of command args, optional.
"args": [ "." ],
// Regexp that match with Instance component of WM_CLASS(STRING) of xprop output
// Regexp that match with Instance component of WM_CLASS(STRING) of xprop output.
"instance": "^thunar$",
// Regexp that match with Class component of WM_CLASS(STRING) of xprop output
// Regexp that match with Class component of WM_CLASS(STRING) of xprop output.
"class": "^Thunar$",
// text color in html notation
// Text color in html notation.
"color": "#ffa500",
// background color in html notation
// background color in html notation.
"background" : "#000000",
// border color in html notation
// If omitted set to default font defined for app_buttons up here.
"font": "Noto Sans",
// ‘xx-small’, ‘x-small’, ‘small’, ‘medium’, ‘large’, ‘x-large’, ‘xx-large’, or one of relative sizes
// ‘smaller’ or ‘larger’. If omitted set to default font size defined for app_buttons up here.
"font_size": "medium",
// Border color in html notation.
"border": "#666666",
// border color if there is at least one window with given Instance and/or Class exist
// Border color if there is at least one window with given Instance and/or Class exist.
"border_active": "#3e78fd",
// Vertical line between objects on bar - if omitted true value is assumed by i3bar, but we set it to false
// in that case. It is limitation of golang json parser.

View File

@@ -192,7 +192,14 @@ func main() {
)
}
b.FullText = app.FullText
b.FullText = fmt.Sprintf(
"<span color='%s' background='%s' font='%s' size='%s'>%s</span>",
app.Color,
app.Background,
app.Font,
app.FontSize,
app.FullText,
)
if num == len(Conf.Apps) {
b.FullText = fmt.Sprintf(
@@ -205,8 +212,6 @@ func main() {
)
}
b.Background = app.Background
b.Color = app.Color
b.Instance = app.Instance
b.Markup = `pango`
b.Separator = app.Separator

View File

@@ -21,6 +21,8 @@ type I3BarOutBlock struct {
ShortText string `json:"short_text,omitempty"`
Color string `json:"color,omitempty"`
Background string `json:"background,omitempty"`
Font string `json:"font,omitempty"`
FontSize string `json:"font_size,omitempty"`
Border string `json:"border,omitempty"`
BorderTop int `json:"border_top"`
BorderRight int `json:"border_right"`
@@ -1963,29 +1965,29 @@ func ReadConf(defaultConfig []byte) (*MyConfig, error) {
// app.Instance can be missing.
// app.Class can be missing.
if app.Name == "" {
app.Name = fmt.Sprintf("app%d", num)
sampleConfig.Apps[num].Name = fmt.Sprintf("app%d", num)
}
// app.Args can be empty slice. In that case command will be run without aruments.
if app.Cmd == "" {
// If command omitted it will be just /usr/bin/true.
app.Cmd = "true"
sampleConfig.Apps[num].Cmd = "true"
}
if app.Color == "" {
app.Color = sampleConfig.AppButtons.Color
sampleConfig.Apps[num].Color = sampleConfig.AppButtons.Color
}
if app.Background == "" {
app.Background = sampleConfig.AppButtons.Background
sampleConfig.Apps[num].Background = sampleConfig.AppButtons.Background
}
if app.Font == "" {
app.Font = sampleConfig.AppButtons.Font
sampleConfig.Apps[num].Font = sampleConfig.AppButtons.Font
}
if app.FontSize == "" {
app.FontSize = sampleConfig.AppButtons.FontSize
sampleConfig.Apps[num].FontSize = sampleConfig.AppButtons.FontSize
} else {
matched, err := regexp.MatchString(
`^(xx-small|x-small|small|medium|large|x-large|xx-large|smaller|larger)$`,
@@ -2000,7 +2002,7 @@ func ReadConf(defaultConfig []byte) (*MyConfig, error) {
sampleConfig.AppButtons.FontSize,
)
app.FontSize = sampleConfig.AppButtons.FontSize
sampleConfig.Apps[num].FontSize = sampleConfig.AppButtons.FontSize
}
if !matched {
@@ -2009,22 +2011,22 @@ func ReadConf(defaultConfig []byte) (*MyConfig, error) {
sampleConfig.AppButtons.FontSize,
)
app.FontSize = sampleConfig.AppButtons.FontSize
sampleConfig.Apps[num].FontSize = sampleConfig.AppButtons.FontSize
}
}
if app.Border == "" {
app.Border = sampleConfig.AppButtons.Color
sampleConfig.Apps[num].Border = sampleConfig.AppButtons.Color
}
if app.BorderActive == "" {
app.BorderActive = sampleConfig.AppButtons.Color
sampleConfig.Apps[num].BorderActive = sampleConfig.AppButtons.Color
}
// app.Separator can be omitted, in that case it is false
// app.SeparatorBlockWidth can be missing
if app.FullText == "" {
app.FullText = fmt.Sprintf(" %d ", num)
sampleConfig.Apps[num].FullText = fmt.Sprintf(" %d ", num)
}
}
}