diff options
| author | Julian Hurst <julian.hurst92@gmail.com> | 2020-07-05 21:41:48 +0200 |
|---|---|---|
| committer | Julian Hurst <julian.hurst92@gmail.com> | 2020-07-05 21:41:48 +0200 |
| commit | cc3606526a78e5e8e90a22b46ef36d5746214b57 (patch) | |
| tree | 34b745883424662bd849bfbb7577b007c3c27fef /statusbar.go | |
| parent | 4f94299a15f6724ec45fb27022cd45f80ca0164e (diff) | |
| download | statusbar-cc3606526a78e5e8e90a22b46ef36d5746214b57.tar.gz | |
Add clock label and format
Diffstat (limited to 'statusbar.go')
| -rw-r--r-- | statusbar.go | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/statusbar.go b/statusbar.go index 607b545..6becd39 100644 --- a/statusbar.go +++ b/statusbar.go @@ -19,6 +19,7 @@ type Config struct { IP IPConfig Mounts MountConfig Music MusicConfig + Clock ClockConfig } type IPConfig struct { @@ -38,6 +39,11 @@ type MusicConfig struct { LabelStopped string `toml:"labelstopped"` } +type ClockConfig struct { + Label string + Format string +} + func diskSizes(mounts []string) string { var b strings.Builder var statfs syscall.Statfs_t @@ -112,9 +118,9 @@ func ip(interfaceName string, IPv4Only bool) string { return b.String() } -func clock() string { +func clock(format string) string { t := time.Now() - return t.Format("Monday 2006-01-02 15:04:05") + return t.Format(format) } func nowPlayingMPD() string { @@ -186,7 +192,8 @@ func main() { b.WriteString(diskSizes(config.Mounts.MountPoints)) b.WriteString(" ]") b.WriteString(config.Separator) - b.WriteString(clock()) + b.WriteString(config.Clock.Label) + b.WriteString(clock(config.Clock.Format)) fmt.Println(b.String()) time.Sleep(10 * time.Second) } |
