diff options
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -41,6 +41,7 @@ var ( replace = false isSharing = false isDataSharing = false + maxTitleLen = 70 writer io.Writer = os.Stdout shareWriter, dataWriter io.Writer ) @@ -184,7 +185,11 @@ func formatOutput(p *player, icon string, fstr string) string { case tokAlbum: buf = append(buf, []byte(p.Album)...) case tokTitle: - buf = append(buf, []byte(p.Title)...) + title := p.Title + if maxTitleLen > 0 && len(title) > maxTitleLen { + title = title[:maxTitleLen-3] + "..." + } + buf = append(buf, []byte(title)...) case tokPosition: position := secondsToString(int(p.Position / 1000000)) buf = append(buf, []byte(position)...) @@ -571,6 +576,8 @@ func main() { "Interpolate track position (helpful for players that don't update regularly, e.g mpDris2)") flag.BoolVar(&replace, "replace", replace, "Replace existing waybar-mpris if found. When false, new instance will clone the original instances output.") + flag.IntVar(&maxTitleLen, "max-title", maxTitleLen, + "Maximum length of title. If the title's longer N-3 characters will be printed and ... will be printed at the end.") var command string flag.StringVar(&command, "send", "", "send command to already runnning waybar-mpris instance. (options: "+strings.Join(commands, "/")+")") |