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.conf | 4 ++++ statusbar.go | 13 ++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/statusbar.conf b/statusbar.conf index dc46741..f5cd68f 100644 --- a/statusbar.conf +++ b/statusbar.conf @@ -13,3 +13,7 @@ mountpoints = [ "/", "/mnt/storage", "/mnt/storage1" ] labelplaying = "▶ " labelpaused = "⏸ " labelstopped = "-" + +[clock] +label = "" +format = "Monday 2006-01-02 15:04:05" 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