more variable safe terminal check

This commit is contained in:
nekohepott 2026-06-17 04:16:27 +03:00
parent 4c9203c03a
commit 6a118174fc
No known key found for this signature in database
2 changed files with 19 additions and 6 deletions

View File

@ -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") ![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. config file is created at `~/.config/gogofetch/config.toml`, all parameters are described in config file.
# NixOS # Nix
credits to melvi for flake credits to melvi for flake
to build with nix: to build with nix:
@ -43,7 +43,7 @@ nix build
``` ```
to run with nix: to run with nix:
``` ```
nix run nix run --refresh git+https://codeberg.org/nekohepott/goGoFetch
``` ```
to install with nixos: to install with nixos:
@ -71,11 +71,11 @@ to build:
``` ```
git clone https://codeberg.org/nekohepott/goGoFetch git clone https://codeberg.org/nekohepott/goGoFetch
cd goGoFetch cd goGoFetch
go build main.go go build -o gogofetch main.go
``` ```
and run: and run:
``` ```
./main ./gogofetch
``` ```
# Some screenshots # Some screenshots

View File

@ -182,7 +182,20 @@ func GetHostname() string {
} }
func GetTerminal() string { func GetTerminal() string {
shellPID := os.Getppid()
out, err := exec.Command("ps", "-p", fmt.Sprint(shellPID), "-o", "ppid=").Output()
if err != nil {
return os.Getenv("TERM") 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 { func GetDE() string {