From cc3606526a78e5e8e90a22b46ef36d5746214b57 Mon Sep 17 00:00:00 2001 From: Julian Hurst Date: Sun, 5 Jul 2020 21:41:48 +0200 Subject: Add clock label and format --- statusbar.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'statusbar.go') 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) } -- cgit v1.2.3