mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Closes #33. Creates .wtf dir and config.yml if they don't exist.
This commit is contained in:
parent
9f59ee1f9f
commit
27107fcd37
@ -1,13 +1,33 @@
|
||||
wtf:
|
||||
grid:
|
||||
columns: [40]
|
||||
rows: [13, 3]
|
||||
columns: [40, 40]
|
||||
rows: [13, 13, 4]
|
||||
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"
|
||||
security:
|
||||
enabled: true
|
||||
position:
|
||||
top: 0
|
||||
top: 1
|
||||
left: 0
|
||||
height: 1
|
||||
width: 1
|
||||
@ -15,8 +35,25 @@ wtf:
|
||||
status:
|
||||
enabled: true
|
||||
position:
|
||||
top: 1
|
||||
top: 2
|
||||
left: 0
|
||||
height: 1
|
||||
width: 1
|
||||
width: 2
|
||||
refreshInterval: 1
|
||||
system:
|
||||
enabled: true
|
||||
position:
|
||||
top: 0
|
||||
left: 1
|
||||
height: 1
|
||||
width: 1
|
||||
refreshInterval: 3600
|
||||
textfile:
|
||||
enabled: true
|
||||
filePath: "~/.wtf/config.yml"
|
||||
position:
|
||||
top: 1
|
||||
left: 1
|
||||
height: 1
|
||||
width: 1
|
||||
refreshInterval: 15
|
||||
|
@ -217,6 +217,8 @@ func (widget *Widget) responseIcon(event *calendar.Event) string {
|
||||
icon = icon + "✘ "
|
||||
case "needsAction":
|
||||
icon = icon + "? "
|
||||
case "tentative":
|
||||
icon = icon + "~ "
|
||||
default:
|
||||
icon = icon + ""
|
||||
}
|
||||
|
5
wtf.go
5
wtf.go
@ -135,8 +135,6 @@ var Config *config.Config
|
||||
var FocusTracker wtf.FocusTracker
|
||||
var Widgets []wtf.Wtfable
|
||||
|
||||
var result = wtf.CreateConfigDir()
|
||||
|
||||
var (
|
||||
builtat = "dev"
|
||||
version = "dev"
|
||||
@ -161,6 +159,9 @@ func main() {
|
||||
|
||||
/* -------------------- end flag parsing and handling -------------------- */
|
||||
|
||||
wtf.CreateConfigDir()
|
||||
wtf.WriteConfigFile()
|
||||
|
||||
Config = wtf.LoadConfigFile(*flagConf)
|
||||
|
||||
app := tview.NewApplication()
|
||||
|
@ -2,6 +2,7 @@ package wtf
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/olebedev/config"
|
||||
@ -17,7 +18,7 @@ func ConfigDir() (string, error) {
|
||||
}
|
||||
|
||||
// CreateConfigDir creates the .wtf directory in the user's home dir
|
||||
func CreateConfigDir() bool {
|
||||
func CreateConfigDir() {
|
||||
configDir, _ := ConfigDir()
|
||||
|
||||
if _, err := os.Stat(configDir); os.IsNotExist(err) {
|
||||
@ -26,8 +27,6 @@ func CreateConfigDir() bool {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// CreateFile creates the named file in the config directory, if it does not already exist.
|
||||
@ -87,3 +86,83 @@ func ReadConfigFile(fileName string) (string, error) {
|
||||
|
||||
return string(fileData), nil
|
||||
}
|
||||
|
||||
// WriteConfigFile creates a simple config file in the config directory if
|
||||
// one does not already exist
|
||||
func WriteConfigFile() {
|
||||
filePath, err := CreateFile("config.yml")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// If the file is empty, write to it
|
||||
file, err := os.Stat(filePath)
|
||||
|
||||
if file.Size() == 0 {
|
||||
err = ioutil.WriteFile(filePath, []byte(simpleConfig), 0644)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const simpleConfig = `
|
||||
wtf:
|
||||
grid:
|
||||
columns: [40, 40]
|
||||
rows: [13, 13, 4]
|
||||
refreshInterval: 1
|
||||
mods:
|
||||
clocks:
|
||||
colors:
|
||||
rows:
|
||||
even: "lightblue"
|
||||
odd: "white"
|
||||
enabled: true
|
||||
locations:
|
||||
Avignon: "Europe/Paris"
|
||||
Barcelona: "Europe/Madrid"
|
||||
Dubai: "Asia/Dubai"
|
||||
Vancouver: "America/Vancouver"
|
||||
Toronto: "America/Toronto"
|
||||
position:
|
||||
top: 0
|
||||
left: 0
|
||||
height: 1
|
||||
width: 1
|
||||
refreshInterval: 15
|
||||
sort: "alphabetical"
|
||||
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: 2
|
||||
refreshInterval: 1
|
||||
system:
|
||||
enabled: true
|
||||
position:
|
||||
top: 0
|
||||
left: 1
|
||||
height: 1
|
||||
width: 1
|
||||
refreshInterval: 3600
|
||||
textfile:
|
||||
enabled: true
|
||||
filePath: "~/.wtf/config.yml"
|
||||
position:
|
||||
top: 1
|
||||
left: 1
|
||||
height: 1
|
||||
width: 1
|
||||
refreshInterval: 30
|
||||
`
|
||||
|
Loading…
x
Reference in New Issue
Block a user