diff --git a/README.md b/README.md index 2e0b07f..066552f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Fetch tool written in Go with image support +# Fetch tool for linux written in Go with image support ![Fetch image](assets/screenshot.png "fetch") @@ -34,7 +34,7 @@ gogofetch -h config file is created at `~/.config/gogofetch/config.toml`, all parameters are described in config file. -# NixOS +# Nix credits to melvi for flake to build with nix: @@ -43,7 +43,7 @@ nix build ``` to run with nix: ``` -nix run +nix run --refresh git+https://codeberg.org/nekohepott/goGoFetch ``` to install with nixos: @@ -71,11 +71,11 @@ to build: ``` git clone https://codeberg.org/nekohepott/goGoFetch cd goGoFetch -go build main.go +go build -o gogofetch main.go ``` and run: ``` -./main +./gogofetch ``` # Some screenshots diff --git a/src/providers/systemstats.go b/src/providers/systemstats.go index 39a3d2a..9466b17 100644 --- a/src/providers/systemstats.go +++ b/src/providers/systemstats.go @@ -182,7 +182,20 @@ func GetHostname() string { } func GetTerminal() string { - return os.Getenv("TERM") + shellPID := os.Getppid() + out, err := exec.Command("ps", "-p", fmt.Sprint(shellPID), "-o", "ppid=").Output() + if err != nil { + return os.Getenv("TERM") + } + + terminalPID := strings.TrimSpace(string(out)) + nameOut, err := exec.Command("ps", "-p", terminalPID, "-o", "comm=").Output() + if err != nil { + return os.Getenv("TERM") + } + // those subprocess ARE NOT SLOWING DOWN THE FETCH MELVI, execution time is the same, you can check it + + return strings.TrimSpace(string(nameOut)) } func GetDE() string {