diff --git a/CHANGELOG.md b/CHANGELOG.md index 16260f07..54fb4bf0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ * Zendesk widget now has help text, by [@Seanstoppable](https://github.com/Seanstoppable) * Scrollable widget added to provide common keyboard-navigation list functionality, by [@Seanstoppable](https://github.com/Seanstoppable) * Logging functionality extracted out from Log module, by [@Seanstoppable](https://github.com/Seanstoppable) +* Improved sample configs with up-to-date attributes and examples, by [@retgits](https://github.com/Seanstoppableretgits) ## v0.9.2 diff --git a/_sample_configs/bargraph_config.png b/_sample_configs/bargraph_config.png new file mode 100644 index 00000000..93bdcbd5 Binary files /dev/null and b/_sample_configs/bargraph_config.png differ diff --git a/_sample_configs/bargraph_config.yml b/_sample_configs/bargraph_config.yml index c70bc2aa..7577049f 100644 --- a/_sample_configs/bargraph_config.yml +++ b/_sample_configs/bargraph_config.yml @@ -14,7 +14,7 @@ wtf: graphIcon: "💀" graphStars: 25 position: - top: 2 + top: 1 left: 0 height: 2 width: 2 diff --git a/_sample_configs/complex_config.yml b/_sample_configs/complex_config.yml deleted file mode 100644 index 10b586ab..00000000 --- a/_sample_configs/complex_config.yml +++ /dev/null @@ -1,236 +0,0 @@ -wtf: - colors: - background: gray - border: - focusable: darkslateblue - focused: orange - normal: gray - grid: - # How _wide_ the columns are, in terminal characters. In this case we have - # five columns, each of which are 37 characters wide - columns: [37, 37, 37, 37, 37] - - # How _high_ the rows are, in terminal lines. In this case we have five rows - # that support ten line of text, and one of four - rows: [10, 10, 10, 10, 10, 4] - refreshInterval: 1 - mods: - bamboohr: - enabled: true - position: - top: 0 - left: 0 - height: 2 - width: 1 - refreshInterval: 900 - clocks: - colors: - rows: - even: "lightblue" - odd: "white" - enabled: true - locations: - # From https://en.wikipedia.org/wiki/List_of_tz_database_time_zones - Avignon: "Europe/Paris" - Barcelona: "Europe/Madrid" - Dubai: "Asia/Dubai" - UTC: "Etc/UTC" - Vancouver: "America/Vancouver" - Toronto: "America/Toronto" - position: - top: 3 - left: 1 - height: 1 - width: 1 - refreshInterval: 15 - # Valid options are: alphabetical, chronological - sort: "alphabetical" - cmdrunner: - args: ["-g", "batt"] - cmd: "pmset" - enabled: true - position: - top: 6 - left: 2 - height: 1 - width: 2 - refreshInterval: 30 - gcal: - colors: - title: "red" - description: "lightblue" - highlights: - - ['1on1|1\/11', 'green'] - - ['apple|google|aws', 'blue'] - - ['interview|meet\ ', 'lightseagreen'] - - ['lunch', 'yellow'] - past: "gray" - conflictIcon: "🚨" - currentIcon: "💥" - displayResponseStatus: true - email: "your.email@example.com" - enabled: true - eventCount: 12 - position: - top: 0 - left: 0 - height: 4 - width: 1 - refreshInterval: 300 - secretFile: "~/.config/wtf/gcal/client_secret.json" - withLocation: true - gspreadsheets: - colors: - values: "green" - cells: - names: - - "Cell 1 name" - - "Cell 2 name" - addresses: - - "A1" - - "A2" - enabled: true - position: - top: 0 - left: 0 - width: 1 - height: 1 - refreshInterval: "300" - secretFile: "~/.config/wtf/gspreadsheets/client_secret.json" - sheetId: "id_of_google_spreadsheet" - git: - commitCount: 5 - enabled: true - position: - top: 0 - left: 2 - height: 2 - width: 3 - refreshInterval: 8 - repositories: - - "/Users/chris/go/src/github.com/wtfutil/wtf" - github: - enabled: true - position: - top: 2 - left: 2 - height: 2 - width: 3 - refreshInterval: 300 - repositories: - repo-name: "owner id" - wtf: "wtfutil" - username: "wtfutil" - jira: - colors: - rows: - even: "lightblue" - odd: "white" - domain: "https://company.atlassian.net" - enabled: true - position: - top: 1 - left: 1 - height: 1 - width: 1 - project: "WTF" - refreshInterval: 900 - username: "chris.cummer" - newrelic: - applicationId: 10594735 - enabled: true - deployCount: 10 - position: - top: 4 - left: 2 - height: 2 - width: 3 - refreshInterval: 900 - opsgenie: - displayEmpty: true - enabled: true - position: - top: 2 - left: 0 - height: 2 - width: 1 - refreshInterval: 21600 - power: - enabled: true - position: - top: 5 - left: 0 - height: 2 - width: 1 - refreshInterval: 15 - security: - enabled: true - position: - top: 4 - left: 0 - height: 2 - width: 1 - refreshInterval: 3600 - status: - enabled: false - position: - top: 5 - left: 0 - height: 1 - width: 1 - refreshInterval: 1 - system: - enabled: true - position: - top: 5 - left: 1 - height: 2 - width: 1 - refreshInterval: 3600 - todo: - checkedIcon: "X" - colors: - checked: gray - highlight: - fore: "black" - back: "orange" - enabled: true - filename: "todo.yml" - position: - top: 0 - left: 1 - height: 2 - width: 1 - refreshInterval: 3600 - weather: - apiKey: [YOUR API KEY] - # From http://openweathermap.org/help/city_list.txt - cityids: - - 3370352 - - 1283240 - WTF_OWM_API_KEY: [YOUR API KEY] - colors: - current: "lightblue" - enabled: true - language: "EN" - position: - top: 2 - left: 1 - height: 1 - width: 1 - refreshInterval: 90 - tempUnit: "C" - blockfolio: - enabled: true - displayHoldings: true - refreshInterval: 400 - device_token: "device token here, you can find how to get it here https://github.com/bob6664569/blockfolio-api-client" - colors: - name: blue - grows: green - drop: red - position: - top: 3 - left: 1 - width: 1 - height: 1 diff --git a/_sample_configs/sample_config.png b/_sample_configs/sample_config.png new file mode 100644 index 00000000..2de48f1e Binary files /dev/null and b/_sample_configs/sample_config.png differ diff --git a/_sample_configs/sample_config.yml b/_sample_configs/sample_config.yml new file mode 100644 index 00000000..1fccfe3a --- /dev/null +++ b/_sample_configs/sample_config.yml @@ -0,0 +1,180 @@ +wtf: + colors: + background: black + border: + focusable: darkslateblue + focused: orange + normal: gray + checked: yellow + highlight: + fore: black + back: gray + rows: + even: yellow + odd: white + grid: + # How _wide_ the columns are, in terminal characters. In this case we have + # four columns, each of which are 35 characters wide. + columns: [35, 35, 35, 35] + # How _high_ the rows are, in terminal lines. In this case we have four rows + # that support ten line of text and one of four. + rows: [10, 10, 10, 10, 4] + refreshInterval: 1 + openFileUtil: "open" + mods: + # You can have multiple widgets of the same type. + # The "key" is the name of the widget and the type is the actual + # widget you want to implement. + europe_time: + title: "Europe" + type: clocks + colors: + rows: + even: "lightblue" + odd: "white" + enabled: true + locations: + GMT: "Etc/GMT" + Amsterdam: "Europe/Amsterdam" + Berlin: "Europe/Berlin" + Barcelona: "Europe/Madrid" + Copenhagen: "Europe/Copenhagen" + London: "Europe/London" + Rome: "Europe/Rome" + Stockholm: "Europe/Stockholm" + position: + top: 0 + left: 0 + height: 1 + width: 1 + refreshInterval: 15 + sort: "alphabetical" + americas_time: + title: "Americas" + type: clocks + colors: + rows: + even: "lightblue" + odd: "white" + enabled: true + locations: + UTC: "Etc/UTC" + Vancouver: "America/Vancouver" + New_York: "America/New_York" + Sao_Paolo: "America/Sao_Paulo" + Denver: "America/Denver" + Iqaluit: "America/Iqaluit" + Bahamas: "America/Nassau" + Chicago: "America/Chicago" + position: + top: 0 + left: 1 + height: 1 + width: 1 + refreshInterval: 15 + sort: "alphabetical" + battery: + type: power + title: "⚡️" + enabled: true + position: + top: 1 + left: 3 + height: 1 + width: 1 + refreshInterval: 15 + todolist: + type: todo + checkedIcon: "X" + colors: + checked: gray + highlight: + fore: "black" + back: "orange" + enabled: true + filename: "todo.yml" + position: + top: 1 + left: 0 + height: 2 + width: 1 + refreshInterval: 3600 + ip: + type: ipinfo + title: "My IP" + colors: + name: "lightblue" + value: "white" + enabled: true + position: + top: 0 + left: 2 + height: 1 + width: 2 + refreshInterval: 150 + security_info: + type: security + title: "Staying safe" + enabled: true + position: + top: 1 + left: 2 + height: 1 + width: 1 + refreshInterval: 3600 + readme: + type: textfile + enabled: true + filePaths: + - "~/.config/wtf/config.yml" + format: true + formatStyle: "monokai" + position: + top: 1 + left: 1 + height: 1 + width: 1 + refreshInterval: 15 + news: + type: hackernews + title: "HackerNews" + enabled: true + numberOfStories: 10 + position: + top: 2 + left: 1 + height: 1 + width: 3 + storyType: top + refreshInterval: 900 + resources: + type: resourceusage + enabled: true + position: + top: 3 + left: 0 + height: 2 + width: 1 + refreshInterval: 1 + uptime: + type: cmdrunner + args: [""] + cmd: "uptime" + enabled: true + position: + top: 4 + left: 1 + height: 1 + width: 3 + refreshInterval: 30 + disks: + type: cmdrunner + cmd: "df" + args: ["-h"] + enabled: true + position: + top: 3 + left: 1 + height: 1 + width: 3 + refreshInterval: 3600 \ No newline at end of file diff --git a/_sample_configs/simple_config.yml b/_sample_configs/simple_config.yml deleted file mode 100644 index 94ed8555..00000000 --- a/_sample_configs/simple_config.yml +++ /dev/null @@ -1,89 +0,0 @@ -wtf: - colors: - # background: gray - border: - focusable: darkslateblue - focused: orange - normal: gray - grid: - columns: [40, 40] - rows: [13, 13, 4, 10] - refreshInterval: 1 - mods: - clocks: - colors: - rows: - even: "lightblue" - odd: "white" - enabled: true - locations: - Avignon: "Europe/Paris" - Barcelona: "Europe/Madrid" - Dubai: "Asia/Dubai" - UTC: "Etc/UTC" - Vancouver: "America/Vancouver" - Toronto: "America/Toronto" - position: - top: 0 - left: 0 - height: 1 - width: 1 - refreshInterval: 15 - sort: "alphabetical" - ipinfo: - colors: - name: "lightblue" - value: "white" - enabled: true - position: - top: 3 - left: 0 - height: 1 - width: 1 - refreshInterval: 150 - power: - enabled: true - position: - top: 3 - left: 1 - height: 1 - width: 1 - refreshInterval: 15 - title: "⚡️" - security: - enabled: true - position: - top: 1 - left: 0 - height: 1 - width: 1 - refreshInterval: 3600 - status: - enabled: true - position: - top: 2 - left: 0 - height: 1 - width: 1 - refreshInterval: 1 - system: - enabled: true - position: - top: 0 - left: 1 - height: 1 - width: 1 - refreshInterval: 3600 - textfile: - enabled: true - filePaths: - - "~/.config/wtf/config.yml" - - "~/.config/wtf/log.txt" - format: true - formatStyle: "vim" - position: - top: 1 - left: 1 - height: 2 - width: 1 - refreshInterval: 15 diff --git a/_sample_configs/uniconfig.png b/_sample_configs/uniconfig.png new file mode 100644 index 00000000..84f66a12 Binary files /dev/null and b/_sample_configs/uniconfig.png differ diff --git a/_sample_configs/uniconfig.yml b/_sample_configs/uniconfig.yml index dfafe535..333e9b6f 100644 --- a/_sample_configs/uniconfig.yml +++ b/_sample_configs/uniconfig.yml @@ -1,15 +1,26 @@ wtf: + colors: + background: black + border: + focusable: darkslateblue grid: columns: [40, 40] rows: [16] refreshInterval: 1 mods: - clocks: + americas_time: + title: "Americas" + type: clocks enabled: true locations: - Toronto: "America/Toronto" UTC: "Etc/UTC" Vancouver: "America/Vancouver" + New_York: "America/New_York" + Sao_Paolo: "America/Sao_Paulo" + Denver: "America/Denver" + Iqaluit: "America/Iqaluit" + Bahamas: "America/Nassau" + Chicago: "America/Chicago" position: top: 0 left: 0 @@ -21,7 +32,6 @@ wtf: enabled: true filePaths: - "~/.config/wtf/config.yml" - - "~/.config/wtf/log.txt" format: true formatStyle: "vim" position: diff --git a/modules/clocks/display.go b/modules/clocks/display.go index 58e46e52..eae5d075 100644 --- a/modules/clocks/display.go +++ b/modules/clocks/display.go @@ -6,7 +6,8 @@ import ( func (widget *Widget) display(clocks []Clock, dateFormat string, timeFormat string) { if len(clocks) == 0 { - widget.View.SetText(fmt.Sprintf("\n%s", " no timezone data available")) + title := fmt.Sprintf("\n%s", " no timezone data available") + widget.Redraw(widget.CommonSettings.Title, title, true) return } diff --git a/modules/cryptoexchanges/bittrex/display.go b/modules/cryptoexchanges/bittrex/display.go index cb8b5001..f9ddeca3 100644 --- a/modules/cryptoexchanges/bittrex/display.go +++ b/modules/cryptoexchanges/bittrex/display.go @@ -8,12 +8,12 @@ import ( func (widget *Widget) display() { if ok == false { - widget.View.SetText(errorText) + widget.Redraw(widget.CommonSettings.Title, errorText, true) return } summaryText := widget.summaryText(&widget.summaryList) - widget.View.SetText(summaryText) + widget.Redraw(widget.CommonSettings.Title, summaryText, false) } func (widget *Widget) summaryText(list *summaryList) string { diff --git a/modules/cryptoexchanges/bittrex/widget.go b/modules/cryptoexchanges/bittrex/widget.go index 0d366d84..95683fe3 100644 --- a/modules/cryptoexchanges/bittrex/widget.go +++ b/modules/cryptoexchanges/bittrex/widget.go @@ -80,9 +80,7 @@ func makeMarketCurrency(name string) *mCurrency { func (widget *Widget) Refresh() { widget.updateSummary() - widget.app.QueueUpdateDraw(func() { - widget.display() - }) + widget.display() } /* -------------------- Unexported Functions -------------------- */ @@ -142,9 +140,7 @@ func (widget *Widget) updateSummary() { } } - widget.app.QueueUpdateDraw(func() { - widget.display() - }) + widget.display() } func makeRequest(baseName, marketName string) *http.Request { diff --git a/modules/cryptoexchanges/blockfolio/widget.go b/modules/cryptoexchanges/blockfolio/widget.go index b1148607..5aa41472 100644 --- a/modules/cryptoexchanges/blockfolio/widget.go +++ b/modules/cryptoexchanges/blockfolio/widget.go @@ -36,15 +36,13 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget { func (widget *Widget) Refresh() { positions, err := Fetch(widget.device_token) if err != nil { + widget.Redraw(widget.CommonSettings.Title, err.Error(), true) return } content := widget.contentFrom(positions) - widget.app.QueueUpdateDraw(func() { - widget.View.SetTitle(widget.CommonSettings.Title) - widget.View.SetText(content) - }) + widget.Redraw(widget.CommonSettings.Title, content, false) } /* -------------------- Unexported Functions -------------------- */ diff --git a/modules/cryptoexchanges/cryptolive/widget.go b/modules/cryptoexchanges/cryptolive/widget.go index 651d1170..82ef76e0 100644 --- a/modules/cryptoexchanges/cryptolive/widget.go +++ b/modules/cryptoexchanges/cryptolive/widget.go @@ -48,9 +48,7 @@ func (widget *Widget) Refresh() { widget.toplistWidget.Refresh(&wg) wg.Wait() - widget.app.QueueUpdateDraw(func() { - widget.display() - }) + widget.display() } /* -------------------- Unexported Functions -------------------- */ @@ -60,5 +58,5 @@ func (widget *Widget) display() { str += widget.priceWidget.Result str += widget.toplistWidget.Result - widget.View.SetText(fmt.Sprintf("\n%s", str)) + widget.Redraw(widget.CommonSettings.Title, fmt.Sprintf("\n%s", str), false) } diff --git a/modules/ipaddresses/ipapi/widget.go b/modules/ipaddresses/ipapi/widget.go index 22029278..d7118b48 100644 --- a/modules/ipaddresses/ipapi/widget.go +++ b/modules/ipaddresses/ipapi/widget.go @@ -54,9 +54,7 @@ func NewWidget(app *tview.Application, settings *Settings) *Widget { func (widget *Widget) Refresh() { widget.ipinfo() - widget.app.QueueUpdateDraw(func() { - widget.View.SetText(widget.result) - }) + widget.Redraw(widget.CommonSettings.Title, widget.result, false) } //this method reads the config and calls ipinfo for ip information diff --git a/modules/logger/widget.go b/modules/logger/widget.go index b58d10e6..1a99965d 100644 --- a/modules/logger/widget.go +++ b/modules/logger/widget.go @@ -40,10 +40,7 @@ func (widget *Widget) Refresh() { logLines := widget.tailFile() - widget.app.QueueUpdateDraw(func() { - widget.View.SetTitle(widget.CommonSettings.Title) - widget.View.SetText(widget.contentFrom(logLines)) - }) + widget.Redraw(widget.CommonSettings.Title, widget.contentFrom(logLines), false) } /* -------------------- Unexported Functions -------------------- */ diff --git a/modules/spotify/widget.go b/modules/spotify/widget.go index 2c2f77d9..966ed40f 100644 --- a/modules/spotify/widget.go +++ b/modules/spotify/widget.go @@ -38,7 +38,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) * widget.View.SetWrap(true) widget.View.SetWordWrap(true) - widget.View.SetTitle(fmt.Sprint("[green]Spotify[white]")) widget.KeyboardWidget.SetView(widget.View) diff --git a/modules/spotifyweb/widget.go b/modules/spotifyweb/widget.go index 6cc6130f..53fbf6b7 100644 --- a/modules/spotifyweb/widget.go +++ b/modules/spotifyweb/widget.go @@ -122,7 +122,6 @@ func NewWidget(app *tview.Application, pages *tview.Pages, settings *Settings) * widget.View.SetWrap(true) widget.View.SetWordWrap(true) - widget.View.SetTitle("[green]Spotify Web[white]") widget.KeyboardWidget.SetView(widget.View) diff --git a/modules/twitter/widget.go b/modules/twitter/widget.go index b0d782cf..446546f2 100644 --- a/modules/twitter/widget.go +++ b/modules/twitter/widget.go @@ -68,7 +68,7 @@ func (widget *Widget) display() { if len(tweets) == 0 { str := fmt.Sprintf("\n\n\n%s", wtf.CenterText("[lightblue]No Tweets[white]", 50)) - widget.View.SetText(str) + widget.Redraw(title, str, true) return } diff --git a/modules/victorops/widget.go b/modules/victorops/widget.go index 1fb79d2c..d0d8622c 100644 --- a/modules/victorops/widget.go +++ b/modules/victorops/widget.go @@ -34,7 +34,6 @@ func (widget *Widget) Refresh() { } teams, err := Fetch(widget.settings.apiID, widget.settings.apiKey) - widget.View.SetTitle(widget.ContextualTitle(widget.CommonSettings.Title)) if err != nil { widget.Redraw(widget.CommonSettings.Title, err.Error(), true) @@ -44,16 +43,6 @@ func (widget *Widget) Refresh() { } } -func (widget *Widget) display() { - if widget.teams == nil { - return - } - - widget.View.SetWrap(false) - widget.View.Clear() - widget.View.SetText(widget.contentFrom(widget.teams)) -} - func (widget *Widget) contentFrom(teams []OnCallTeam) string { var str string