diff --git a/fetch/apply.go b/fetch/apply.go index b6aa689..41cf497 100644 --- a/fetch/apply.go +++ b/fetch/apply.go @@ -16,6 +16,7 @@ import ( var ( pidS = strconv.Itoa(os.Getpid()) + hostname string launchTime = time.Now().Unix() ) @@ -23,6 +24,9 @@ var substitute = map[string]func(s *applyState) string{ "pid": func(_ *applyState) string { return pidS }, + "hostname": func(_ *applyState) string { + return hostname + }, "1min": func(s *applyState) string { s.populateLoadavg() return s.loadavg[0] diff --git a/fetch/apply_linux.go b/fetch/apply_linux.go index c1c3d29..d24321a 100644 --- a/fetch/apply_linux.go +++ b/fetch/apply_linux.go @@ -9,6 +9,14 @@ import ( "strings" ) +func init() { + if h, err := os.Hostname(); err != nil { + log.Fatalf("error reading hostname: %s", err) + } else { + hostname = h + } +} + func (s *applyState) populateLoadavg() { if s.loadavg != nil { return diff --git a/fetch/config.go b/fetch/config.go index d3237ed..21c7cd0 100644 --- a/fetch/config.go +++ b/fetch/config.go @@ -18,7 +18,7 @@ var defaultConfig = config{ Timestamps: &rpcfetch.ActivityTimestamps{Start: &launchTime}, Assets: &rpcfetch.ActivityAssets{ LargeImage: "yorha", - LargeText: "1252927154480611351", + LargeText: "%hostname", SmallImage: "flan", SmallText: "PID: %pid", },