diff options
| author | Julian Hurst <julian.hurst92@gmail.com> | 2020-07-11 01:27:10 +0200 |
|---|---|---|
| committer | Julian Hurst <julian.hurst92@gmail.com> | 2020-07-11 01:27:10 +0200 |
| commit | c15493633d9dd660939ba26b633649f08e64cabd (patch) | |
| tree | 8f7b2710f52fb0289ad0529433f554eb3404c471 /statusbar.go | |
| parent | 0fac42e5bcbe4550a17c10162d72ea44ffa5bcdb (diff) | |
| download | statusbar-c15493633d9dd660939ba26b633649f08e64cabd.tar.gz | |
Add hostname support
Diffstat (limited to 'statusbar.go')
| -rw-r--r-- | statusbar.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/statusbar.go b/statusbar.go index 29d6846..cc810bd 100644 --- a/statusbar.go +++ b/statusbar.go @@ -36,6 +36,7 @@ type Config struct { Music MusicConfig Clock ClockConfig Battery BatteryConfig + Hostname HostnameConfig } type IPConfig struct { @@ -68,6 +69,10 @@ type BatteryConfig struct { SubLabel string `toml:"sublabel"` } +type HostnameConfig struct { + Label string +} + func diskSizes(config MountConfig) string { var b strings.Builder var statfs syscall.Statfs_t @@ -302,6 +307,17 @@ func buildBattery(config BatteryConfig) string { return b.String() } +func buildHostname(config HostnameConfig) string { + var b strings.Builder + b.WriteString(config.Label) + hostname, err := os.Hostname() + if err != nil { + panic(err) + } + b.WriteString(hostname) + return b.String() +} + func getDefaultConfigPath() string { return "/etc/statusbar.conf" } @@ -351,6 +367,8 @@ func main() { b.WriteString(buildMusic(config.Music)) case "battery": b.WriteString(buildBattery(config.Battery)) + case "hostname": + b.WriteString(buildHostname(config.Hostname)) default: } if i < len(config.Sections) - 1 { |
