2
0
mirror of https://github.com/miguelmota/cointop synced 2024-11-10 13:10:26 +00:00

Hide open shortcut in statusbar if no open command found

This commit is contained in:
Miguel Mota 2019-06-27 22:03:10 -07:00
parent 52496b87fb
commit f1da2dcb40
No known key found for this signature in database
GPG Key ID: 67EC1161588A00F9
2 changed files with 15 additions and 2 deletions

View File

@ -41,3 +41,8 @@ func URL(s string) error {
}
return nil
}
// CommandExists returns true if an 'open' command exists
func CommandExists() bool {
return openCmd != ""
}

View File

@ -3,6 +3,7 @@ package cointop
import (
"fmt"
"github.com/miguelmota/cointop/cointop/common/open"
"github.com/miguelmota/cointop/cointop/common/pad"
)
@ -44,7 +45,14 @@ func (ct *Cointop) updateStatusbar(s string) error {
return nil
}
func (ct *Cointop) refreshRowLink() {
func (ct *Cointop) refreshRowLink() error {
var shortcut string
if !open.CommandExists() {
shortcut = "[O]Open "
}
url := ct.rowLinkShort()
ct.updateStatusbar(fmt.Sprintf("%sOpen %s", "[O]", url))
ct.updateStatusbar(fmt.Sprintf("%s%s", shortcut, url))
return nil
}