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:
|
wtf:
|
||||||
grid:
|
grid:
|
||||||
columns: [40]
|
columns: [40, 40]
|
||||||
rows: [13, 3]
|
rows: [13, 13, 4]
|
||||||
refreshInterval: 1
|
refreshInterval: 1
|
||||||
mods:
|
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:
|
security:
|
||||||
enabled: true
|
enabled: true
|
||||||
position:
|
position:
|
||||||
top: 0
|
top: 1
|
||||||
left: 0
|
left: 0
|
||||||
height: 1
|
height: 1
|
||||||
width: 1
|
width: 1
|
||||||
@ -15,8 +35,25 @@ wtf:
|
|||||||
status:
|
status:
|
||||||
enabled: true
|
enabled: true
|
||||||
position:
|
position:
|
||||||
top: 1
|
top: 2
|
||||||
left: 0
|
left: 0
|
||||||
height: 1
|
height: 1
|
||||||
width: 1
|
width: 2
|
||||||
refreshInterval: 1
|
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 + "✘ "
|
icon = icon + "✘ "
|
||||||
case "needsAction":
|
case "needsAction":
|
||||||
icon = icon + "? "
|
icon = icon + "? "
|
||||||
|
case "tentative":
|
||||||
|
icon = icon + "~ "
|
||||||
default:
|
default:
|
||||||
icon = icon + ""
|
icon = icon + ""
|
||||||
}
|
}
|
||||||
|
5
wtf.go
5
wtf.go
@ -135,8 +135,6 @@ var Config *config.Config
|
|||||||
var FocusTracker wtf.FocusTracker
|
var FocusTracker wtf.FocusTracker
|
||||||
var Widgets []wtf.Wtfable
|
var Widgets []wtf.Wtfable
|
||||||
|
|
||||||
var result = wtf.CreateConfigDir()
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
builtat = "dev"
|
builtat = "dev"
|
||||||
version = "dev"
|
version = "dev"
|
||||||
@ -161,6 +159,9 @@ func main() {
|
|||||||
|
|
||||||
/* -------------------- end flag parsing and handling -------------------- */
|
/* -------------------- end flag parsing and handling -------------------- */
|
||||||
|
|
||||||
|
wtf.CreateConfigDir()
|
||||||
|
wtf.WriteConfigFile()
|
||||||
|
|
||||||
Config = wtf.LoadConfigFile(*flagConf)
|
Config = wtf.LoadConfigFile(*flagConf)
|
||||||
|
|
||||||
app := tview.NewApplication()
|
app := tview.NewApplication()
|
||||||
|
@ -2,6 +2,7 @@ package wtf
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/olebedev/config"
|
"github.com/olebedev/config"
|
||||||
@ -17,7 +18,7 @@ func ConfigDir() (string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CreateConfigDir creates the .wtf directory in the user's home dir
|
// CreateConfigDir creates the .wtf directory in the user's home dir
|
||||||
func CreateConfigDir() bool {
|
func CreateConfigDir() {
|
||||||
configDir, _ := ConfigDir()
|
configDir, _ := ConfigDir()
|
||||||
|
|
||||||
if _, err := os.Stat(configDir); os.IsNotExist(err) {
|
if _, err := os.Stat(configDir); os.IsNotExist(err) {
|
||||||
@ -26,8 +27,6 @@ func CreateConfigDir() bool {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateFile creates the named file in the config directory, if it does not already exist.
|
// 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
|
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