more variable safe terminal check
This commit is contained in:
parent
4c9203c03a
commit
6a118174fc
10
README.md
10
README.md
@ -1,4 +1,4 @@
|
|||||||
# Fetch tool written in Go with image support
|
# Fetch tool for linux written in Go with image support
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
@ -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
|
||||||
|
|||||||
@ -182,7 +182,20 @@ func GetHostname() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetTerminal() 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 {
|
func GetDE() string {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user