diff --git a/cmd/easyss/tray.go b/cmd/easyss/tray.go index 25a534d5..d1f40fc5 100644 --- a/cmd/easyss/tray.go +++ b/cmd/easyss/tray.go @@ -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:]...) diff --git a/util/sys.go b/util/sys.go index 22ede292..89fb42fc 100644 --- a/util/sys.go +++ b/util/sys.go @@ -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 }