diff --git a/Makefile b/Makefile index 242db01..b8ad104 100644 --- a/Makefile +++ b/Makefile @@ -33,4 +33,6 @@ run: build/stormfetch build/stormfetch clean: - rm -r build/ \ No newline at end of file + rm -r build/ + +.PHONY: build \ No newline at end of file diff --git a/config/fetch_script.sh b/config/fetch_script.sh index a289b1b..b755f4a 100644 --- a/config/fetch_script.sh +++ b/config/fetch_script.sh @@ -6,7 +6,10 @@ echo -e "${C3}Kernel: ${C4}$(uname -s) $(uname -r)" echo -e "${C3}Packages: ${C4}$(get_packages)" echo -e "${C3}Shell: ${C4}${USER_SHELL}" if [ ! -z "$CPU_MODEL" ]; then echo -e "${C3}CPU: ${C4}${CPU_MODEL} (${CPU_THREADS} threads)"; fi -if [ ! -z "$GPU_MODEL" ]; then echo -e "${C3}GPU: ${C4}${GPU_MODEL}"; fi +for i in $(seq ${CONNECTED_GPUS}); do + gpu="GPU$i" + echo -e "${C3}GPU: ${C4}${!gpu}" + done if [ ! -z "$MEM_TOTAL" ] && [ ! -z "$MEM_USED" ]; then echo -e "${C3}Memory: ${C4}${MEM_USED} MiB / ${MEM_TOTAL} MiB"; fi for i in $(seq ${MOUNTED_PARTITIONS}); do device="PARTITION${i}_DEVICE" diff --git a/main.go b/main.go index 63e70d5..6e30e71 100644 --- a/main.go +++ b/main.go @@ -141,8 +141,15 @@ func SetupFetchEnv() []string { env["MONITOR"+strconv.Itoa(i+1)] = monitor } } - if getGPUName() != "" { - env["GPU_MODEL"] = getGPUName() + gpus := getGPUNames() + if len(gpus) != 0 { + env["CONNECTED_GPUS"] = strconv.Itoa(len(gpus)) + for i, gpu := range gpus { + if gpu == "" { + continue + } + env["GPU"+strconv.Itoa(i+1)] = gpu + } } var ret = make([]string, len(env)) diff --git a/utils.go b/utils.go index 89361b7..62f377a 100644 --- a/utils.go +++ b/utils.go @@ -119,7 +119,8 @@ func getCPUThreads() int { return int(cpu.TotalThreads) } -func getGPUName() string { +func getGPUNames() []string { + var ret []string null, _ := os.Open(os.DevNull) serr := os.Stderr os.Stderr = null @@ -127,14 +128,14 @@ func getGPUName() string { defer null.Close() os.Stderr = serr if err != nil { - return "" + return nil } for _, graphics := range gpu.GraphicsCards { if graphics.DeviceInfo != nil { - return graphics.DeviceInfo.Product.Name + ret = append(ret, graphics.DeviceInfo.Product.Name) } } - return "" + return ret } type Memory struct {