mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
now will load weather api key from config if not in env
This commit is contained in:
parent
e83d92b911
commit
4b9c42844b
@ -207,6 +207,7 @@ wtf:
|
||||
cityids:
|
||||
- 3370352
|
||||
- 1283240
|
||||
WTF_OWM_API_KEY: [YOUR API KEY]
|
||||
colors:
|
||||
current: "lightblue"
|
||||
enabled: true
|
||||
|
@ -1,11 +1,13 @@
|
||||
package weather
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
owm "github.com/briandowns/openweathermap"
|
||||
"github.com/gdamore/tcell"
|
||||
"github.com/rivo/tview"
|
||||
"github.com/senorprogrammer/wtf/logger"
|
||||
"github.com/senorprogrammer/wtf/wtf"
|
||||
)
|
||||
|
||||
@ -34,8 +36,9 @@ type Widget struct {
|
||||
|
||||
// NewWidget creates and returns a new instance of the weather Widget.
|
||||
func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
||||
configKey := "weather"
|
||||
widget := Widget{
|
||||
TextWidget: wtf.NewTextWidget(" Weather ", "weather", true),
|
||||
TextWidget: wtf.NewTextWidget(" Weather ", configKey, true),
|
||||
|
||||
app: app,
|
||||
pages: pages,
|
||||
@ -44,6 +47,11 @@ func NewWidget(app *tview.Application, pages *tview.Pages) *Widget {
|
||||
Idx: 0,
|
||||
}
|
||||
|
||||
if widget.APIKey == "" {
|
||||
logger.Log("loading weather WTF_OWM_API_KEY key from config")
|
||||
widget.APIKey = wtf.Config.UString(fmt.Sprintf("wtf.mods.%s.WTF_OWM_API_KEY", configKey), "")
|
||||
}
|
||||
|
||||
widget.View.SetInputCapture(widget.keyboardIntercept)
|
||||
|
||||
return &widget
|
||||
|
Loading…
x
Reference in New Issue
Block a user