Skip to content

Commit 1ab7783

Browse files
committed
Set defaults
1 parent 81eb4a5 commit 1ab7783

File tree

2 files changed

+41
-29
lines changed

2 files changed

+41
-29
lines changed

README.md

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ goDash is a simple, customizable dashboard written in Go. It provides an overvie
1010
- [Screenshots](#screenshots)
1111
- [Mobile](#mobile)
1212
- [Desktop](#desktop)
13-
- [Configuration](#configuration)
14-
- [Config](#config)
13+
- [Config](#config)
1514
- [Docker](#docker)
1615
- [run command](#run-command)
1716
- [compose file](#compose-file)
@@ -40,42 +39,25 @@ goDash is a simple, customizable dashboard written in Go. It provides an overvie
4039
<img src="img/desktop.webp" width="600px">
4140
</div>
4241

43-
## Configuration
44-
45-
goDash is configured using environment variables. Below is an example `.env` file:
46-
47-
```
48-
TZ=Europe/Berlin
49-
TITLE=My Dashboard
50-
PUBLIC_URL=https://mydashboard.example.com
51-
PORT=4000
52-
LOCATION_LATITUDE=48.7803
53-
LOCATION_LONGITUDE=9.1780
54-
WEATHER_KEY=your_openweather_api_key
55-
WEATHER_UNITS=metric
56-
WEATHER_LANG=en
57-
WEATHER_DIGITS=false
58-
```
59-
60-
### Config
42+
## Config
6143

6244
At startup, godash will look for a `config.yaml` file in the current directory or create one. If it exists, it will be used to override the default values.
6345

6446
Icons can be stored in a folder called icons or godash will automatically download from [https://selfh.st/icons/](https://selfh.st/icons/) with the prefix `sh/`
6547

6648
```yaml
6749
log_level: "info" # Valid options: debug, info, warn, error
68-
time_zone: "America/New_York" # Must be a valid IANA timezone (e.g., America/New_York, Europe/London)
50+
time_zone: "Europe/Berlin" # Must be a valid IANA timezone (e.g., America/New_York, Europe/London)
6951
title: "My Dashboard" # Any string
7052

7153
server:
7254
address: "0.0.0.0" # Valid IPv4 address, defaults to 0.0.0.0
73-
port: 8080 # Optional, must be between 1024 and 65535, defaults to 8080
55+
port: 8156 # Optional, must be between 1024 and 65535, defaults to 8156
7456

7557
weather:
7658
units: "celsius" # Valid options: celsius, fahrenheit
77-
latitude: 40.7128 # Optional, must be a valid latitude (-90 to 90)
78-
longitude: -74.0060 # Optional, must be a valid longitude (-180 to 180)
59+
latitude: 52.5163 # Optional, must be a valid latitude (-90 to 90)
60+
longitude: 13.3776 # Optional, must be a valid longitude (-180 to 180)
7961

8062
applications:
8163
- category: "Productivity" # Any string

config/config.go

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ type App struct {
5757
IgnoreDark bool `mapstructure:"ignore_dark"`
5858
}
5959

60+
type AppConfig struct {
61+
Name string `mapstructure:"name"`
62+
Icon string `mapstructure:"icon"`
63+
URL string `mapstructure:"url"`
64+
IgnoreDark bool `mapstructure:"ignore_dark"`
65+
}
66+
6067
func init() {
6168
os.Mkdir(ConfigFolder, os.ModePerm)
6269
os.Mkdir(iconsFolder, os.ModePerm)
@@ -65,13 +72,36 @@ func init() {
6572

6673
func New() {
6774
viper.SetDefault("log_level", "info")
68-
viper.SetDefault("time_zone", "Etc/UTC")
75+
viper.SetDefault("time_zone", "Europe/Berlin")
6976
viper.SetDefault("server.address", "0.0.0.0")
7077
viper.SetDefault("server.port", 8156)
71-
viper.SetDefault("title", "goDash")
72-
viper.SetDefault("weather.units", "metric")
73-
viper.SetDefault("weather.language", "en")
74-
viper.SetDefault("applications", []Category{})
78+
viper.SetDefault("title", "GoDash")
79+
viper.SetDefault("weather.units", "celsius")
80+
viper.SetDefault("weather.latitude", 52.5163)
81+
viper.SetDefault("weather.longitude", 13.3776)
82+
viper.SetDefault("applications", []map[string]interface{}{
83+
{
84+
"category": "Applications",
85+
"entries": []map[string]interface{}{
86+
{
87+
"name": "GoDash",
88+
"icon": "sh/homebox",
89+
"url": "https://gitlab.unjx.de/flohoss/godash",
90+
},
91+
},
92+
},
93+
})
94+
viper.SetDefault("links", []map[string]interface{}{
95+
{
96+
"category": "Applications",
97+
"entries": []map[string]interface{}{
98+
{
99+
"name": "GoDash",
100+
"url": "https://gitlab.unjx.de/flohoss/godash",
101+
},
102+
},
103+
},
104+
})
75105

76106
viper.SetConfigName("config")
77107
viper.SetConfigType("yaml")

0 commit comments

Comments
 (0)