2019-03-13 04:14:30 -07:00
|
|
|
// +build !windows
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2020-11-04 23:56:12 -08:00
|
|
|
"errors"
|
2019-03-13 04:14:30 -07:00
|
|
|
"os"
|
2021-08-01 06:25:15 -07:00
|
|
|
"time"
|
2021-05-22 07:50:34 -07:00
|
|
|
|
|
|
|
terminal "github.com/wayneashleyberry/terminal-dimensions"
|
2019-03-13 04:14:30 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
func (env *environment) isRunningAsRoot() bool {
|
2021-08-01 06:25:15 -07:00
|
|
|
defer env.tracer.trace(time.Now(), "isRunningAsRoot")
|
2019-03-13 04:14:30 -07:00
|
|
|
return os.Geteuid() == 0
|
|
|
|
}
|
2020-10-12 07:01:08 -07:00
|
|
|
|
|
|
|
func (env *environment) homeDir() string {
|
|
|
|
return os.Getenv("HOME")
|
|
|
|
}
|
2020-11-04 23:56:12 -08:00
|
|
|
|
2020-11-12 00:43:32 -08:00
|
|
|
func (env *environment) getWindowTitle(imageName, windowTitleRegex string) (string, error) {
|
2020-11-04 23:56:12 -08:00
|
|
|
return "", errors.New("not implemented")
|
|
|
|
}
|
2021-02-14 23:26:52 -08:00
|
|
|
|
|
|
|
func (env *environment) isWsl() bool {
|
2021-08-01 06:25:15 -07:00
|
|
|
defer env.tracer.trace(time.Now(), "isWsl")
|
2021-02-14 23:26:52 -08:00
|
|
|
// one way to check
|
|
|
|
// version := env.getFileContent("/proc/version")
|
|
|
|
// return strings.Contains(version, "microsoft")
|
|
|
|
// using env variable
|
|
|
|
return env.getenv("WSL_DISTRO_NAME") != ""
|
|
|
|
}
|
2021-05-22 07:50:34 -07:00
|
|
|
|
|
|
|
func (env *environment) getTerminalWidth() (int, error) {
|
2021-08-01 06:25:15 -07:00
|
|
|
defer env.tracer.trace(time.Now(), "getTerminalWidth")
|
2021-05-22 07:50:34 -07:00
|
|
|
width, err := terminal.Width()
|
|
|
|
return int(width), err
|
|
|
|
}
|