forked from wtfutil/wtf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WTF-730 Fix missing color key config error (wtfutil#738)
* WTF-730 Fix missing color key config error Signed-off-by: Chris Cummer <[email protected]> * WTF-730 Add Subheading color formatting to modules Users can now set a `subheading` color in their config to change the color of subheadings in widget display. Defaults to `red`. Signed-off-by: Chris Cummer <[email protected]> * WTF-730 Fix oustanding color issues Clean up missing color config changes not addressed in earlier commits. Signed-off-by: Chris Cummer <[email protected]> * Remove unused dependency Signed-off-by: Chris Cummer <[email protected]> * WTF-730 Base cleanup Signed-off-by: Chris Cummer <[email protected]> * WTF-730 Fix a few bugs related to color config changes Signed-off-by: Chris Cummer <[email protected]> * WTF-730 Fix issues with PagerDuty subheading display Signed-off-by: Chris Cummer <[email protected]> * WTF-730 Fix bug with Todo list colour rendering Signed-off-by: Chris Cummer <[email protected]>
- Loading branch information
1 parent
1bfca29
commit 200dbcc
Showing
33 changed files
with
366 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
wtf: | ||
mods: | ||
battery: | ||
type: power | ||
title: "⚡️" | ||
enabled: true | ||
position: | ||
top: 0 | ||
left: 0 | ||
height: 1 | ||
width: 1 | ||
refreshInterval: 15 | ||
security_info: | ||
type: security | ||
enabled: true | ||
position: | ||
top: 0 | ||
left: 1 | ||
height: 1 | ||
width: 1 | ||
refreshInterval: 3600 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
package cfg | ||
|
||
import ( | ||
"github.com/olebedev/config" | ||
"gopkg.in/yaml.v2" | ||
) | ||
|
||
// BorderTheme defines the default color scheme for drawing widget borders | ||
type BorderTheme struct { | ||
Focusable string | ||
Focused string | ||
Unfocusable string | ||
} | ||
|
||
// CheckboxTheme defines the default color scheme for drawing checkable rows in widgets | ||
type CheckboxTheme struct { | ||
Checked string | ||
} | ||
|
||
// RowTheme defines the default color scheme for row text | ||
type RowTheme struct { | ||
EvenBackground string | ||
EvenForeground string | ||
|
||
OddBackground string | ||
OddForeground string | ||
|
||
HighlightedBackground string | ||
HighlightedForeground string | ||
} | ||
|
||
// TextTheme defines the default color scheme for text rendering | ||
type TextTheme struct { | ||
Subheading string | ||
Text string | ||
Title string | ||
} | ||
|
||
type WidgetTheme struct { | ||
Background string | ||
} | ||
|
||
// ColorTheme is an alamgam of all the default color settings | ||
type ColorTheme struct { | ||
BorderTheme | ||
CheckboxTheme | ||
RowTheme | ||
TextTheme | ||
WidgetTheme | ||
} | ||
|
||
// NewDefaultColorTheme creates and returns an instance of DefaultColorTheme | ||
func NewDefaultColorTheme() ColorTheme { | ||
defaultTheme := ColorTheme{ | ||
BorderTheme: BorderTheme{ | ||
Focusable: "blue", | ||
Focused: "orange", | ||
Unfocusable: "gray", | ||
}, | ||
|
||
CheckboxTheme: CheckboxTheme{ | ||
Checked: "gray", | ||
}, | ||
|
||
RowTheme: RowTheme{ | ||
EvenBackground: "transparent", | ||
EvenForeground: "white", | ||
|
||
OddBackground: "transparent", | ||
OddForeground: "lightblue", | ||
|
||
HighlightedForeground: "black", | ||
HighlightedBackground: "green", | ||
}, | ||
|
||
TextTheme: TextTheme{ | ||
Subheading: "red", | ||
Text: "white", | ||
Title: "green", | ||
}, | ||
|
||
WidgetTheme: WidgetTheme{ | ||
Background: "transparent", | ||
}, | ||
} | ||
|
||
return defaultTheme | ||
} | ||
|
||
// NewDefaultColorConfig creates and returns a config.Config-compatible configuration struct | ||
// using a DefaultColorTheme to pre-populate all the relevant values | ||
func NewDefaultColorConfig() (*config.Config, error) { | ||
colorTheme := NewDefaultColorTheme() | ||
|
||
yamlBytes, err := yaml.Marshal(colorTheme) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
cfg, err := config.ParseYamlBytes(yamlBytes) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return cfg, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package cfg | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func Test_NewDefaultColorTheme(t *testing.T) { | ||
theme := NewDefaultColorTheme() | ||
|
||
assert.Equal(t, "orange", theme.BorderTheme.Focused) | ||
assert.Equal(t, "red", theme.TextTheme.Subheading) | ||
assert.Equal(t, "transparent", theme.WidgetTheme.Background) | ||
} | ||
|
||
func Test_NewDefaultColorConfig(t *testing.T) { | ||
cfg, err := NewDefaultColorConfig() | ||
|
||
assert.Nil(t, err) | ||
|
||
assert.Equal(t, "orange", cfg.UString("bordertheme.focused")) | ||
assert.Equal(t, "red", cfg.UString("texttheme.subheading")) | ||
assert.Equal(t, "transparent", cfg.UString("widgettheme.background")) | ||
assert.Equal(t, "", cfg.UString("widgettheme.missing")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.