Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cmd/backrest/tray.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,18 @@ func startTray() {
systray.Run(func() { onReady(status) }, func() {})
}

var mStatusText *systray.MenuItem

func onReady(status *trayStatus) {
systray.SetTooltip("Backrest")
systray.SetIcon(icon)

if runtime.GOOS == "darwin" {
mStatusText = systray.AddMenuItem("", "")
mStatusText.Disable()
mStatusText.Hide()
}

mOpenUI := systray.AddMenuItem("Open WebUI", "Open the Backrest WebUI in your default browser")
mOpenLog := systray.AddMenuItem("Open Log Dir", "Open the Backrest log directory")
mQuit := systray.AddMenuItem("Quit", "Kills the backrest process and exits the tray app")
Expand Down
22 changes: 13 additions & 9 deletions cmd/backrest/tray_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,15 @@ func (t *trayStatus) refresh() {
if log == nil {
return
}
state, tooltip := computeStatus(log)
state, message := computeStatus(log)
if ic := statusIcon(state); ic != nil {
systray.SetIcon(ic)
}
systray.SetTooltip(tooltip)
systray.SetTooltip("Backrest — " + message)
if mStatusText != nil {
mStatusText.SetTitle(message)
mStatusText.Show()
}
}

// computeStatus returns the tray state and tooltip for the most recent backup.
Expand All @@ -100,22 +104,22 @@ func computeStatus(log *oplog.OpLog) (trayState, string) {
})

if last == nil {
return stateIdle, "Backrest — no backups yet"
return stateIdle, "No backups yet"
}
when := relativeTime(last.GetUnixTimeEndMs())
switch last.GetStatus() {
case v1.OperationStatus_STATUS_INPROGRESS:
return stateRunning, "Backrest — backup in progress…"
return stateRunning, "Backup in progress…"
case v1.OperationStatus_STATUS_SUCCESS:
return stateOK, "Backrest — last backup succeeded " + when
return stateOK, "Last backup succeeded " + when
case v1.OperationStatus_STATUS_WARNING:
return stateWarning, "Backrest — last backup finished with warnings " + when
return stateWarning, "Last backup finished with warnings " + when
case v1.OperationStatus_STATUS_ERROR, v1.OperationStatus_STATUS_SYSTEM_CANCELLED:
return stateError, "Backrest — last backup failed " + when
return stateError, "Last backup failed " + when
case v1.OperationStatus_STATUS_USER_CANCELLED:
return stateIdle, "Backrest — last backup was cancelled " + when
return stateIdle, "Last backup was cancelled " + when
default:
return stateIdle, "Backrest — no backups yet"
return stateIdle, "No backups yet"
}
}

Expand Down