Skip to content

Commit

Permalink
feat: support cat logs using gnome-terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
nange committed Mar 21, 2024
1 parent 4e50634 commit c2cb52e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
12 changes: 11 additions & 1 deletion cmd/easyss/tray.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,9 +309,19 @@ func (st *SysTray) catLog() error {
win = fmt.Sprintf(win, st.ss.LogFilePath())
}

var linuxCmd []string
if runtime.GOOS == "linux" {
switch {
case util.SysSupportXTerminalEmulator():
linuxCmd = []string{"x-terminal-emulator", "-e", "tail", "-50f", st.ss.LogFilePath()}
case util.SysSupportGnomeTerminal():
linuxCmd = []string{"gnome-terminal", "--hide-menubar", "--geometry", "800*600", "--title", "View Easyss Logs", "--", "tail", "-50f", st.ss.LogFilePath()}
}
}

cmdMap := map[string][]string{
"windows": {"powershell", "-Command", "Start-Process", win},
"linux": {"x-terminal-emulator", "-e", "tail", "-50f", st.ss.LogFilePath()},
"linux": linuxCmd,
"darwin": {"open", "-a", "Console", st.ss.LogFilePath()},
}
_, err := util.Command(cmdMap[runtime.GOOS][0], cmdMap[runtime.GOOS][1:]...)
Expand Down
14 changes: 13 additions & 1 deletion util/sys.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,19 @@ import (
)

func SysSupportPowershell() bool {
lp, err := exec.LookPath("powershell")
return SysSupport("powershell")
}

func SysSupportXTerminalEmulator() bool {
return SysSupport("x-terminal-emulator")
}

func SysSupportGnomeTerminal() bool {
return SysSupport("gnome-terminal")
}

func SysSupport(bin string) bool {
lp, err := exec.LookPath(bin)
if lp != "" && err == nil {
return true
}
Expand Down

0 comments on commit c2cb52e

Please sign in to comment.