2 Commits
5 changed files with 28 additions and 9 deletions
+3 -1
View File
@@ -33,4 +33,6 @@ run: build/stormfetch
build/stormfetch build/stormfetch
clean: clean:
rm -r build/ rm -r build/
.PHONY: build
+1
View File
@@ -3,3 +3,4 @@ fetch_script: auto
ansii_colors: [] ansii_colors: []
force_config_ansii: false force_config_ansii: false
dependency_warning: true dependency_warning: true
hidden_gpus: []
+4 -1
View File
@@ -6,7 +6,10 @@ echo -e "${C3}Kernel: ${C4}$(uname -s) $(uname -r)"
echo -e "${C3}Packages: ${C4}$(get_packages)" echo -e "${C3}Packages: ${C4}$(get_packages)"
echo -e "${C3}Shell: ${C4}${USER_SHELL}" 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 "$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 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 for i in $(seq ${MOUNTED_PARTITIONS}); do
device="PARTITION${i}_DEVICE" device="PARTITION${i}_DEVICE"
+11 -2
View File
@@ -22,6 +22,7 @@ var config = StormfetchConfig{
AnsiiColors: make([]int, 0), AnsiiColors: make([]int, 0),
ForceConfigAnsii: false, ForceConfigAnsii: false,
DependencyWarning: true, DependencyWarning: true,
HiddenGPUS: make([]int, 0),
} }
type StormfetchConfig struct { type StormfetchConfig struct {
@@ -31,6 +32,7 @@ type StormfetchConfig struct {
AnsiiColors []int `yaml:"ansii_colors"` AnsiiColors []int `yaml:"ansii_colors"`
ForceConfigAnsii bool `yaml:"force_config_ansii"` ForceConfigAnsii bool `yaml:"force_config_ansii"`
DependencyWarning bool `yaml:"dependency_warning"` DependencyWarning bool `yaml:"dependency_warning"`
HiddenGPUS []int `yaml:"hidden_gpus"`
} }
func main() { func main() {
@@ -141,8 +143,15 @@ func SetupFetchEnv() []string {
env["MONITOR"+strconv.Itoa(i+1)] = monitor env["MONITOR"+strconv.Itoa(i+1)] = monitor
} }
} }
if getGPUName() != "" { gpus := getGPUNames()
env["GPU_MODEL"] = getGPUName() 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)) var ret = make([]string, len(env))
+9 -5
View File
@@ -119,7 +119,8 @@ func getCPUThreads() int {
return int(cpu.TotalThreads) return int(cpu.TotalThreads)
} }
func getGPUName() string { func getGPUNames() []string {
var ret []string
null, _ := os.Open(os.DevNull) null, _ := os.Open(os.DevNull)
serr := os.Stderr serr := os.Stderr
os.Stderr = null os.Stderr = null
@@ -127,14 +128,17 @@ func getGPUName() string {
defer null.Close() defer null.Close()
os.Stderr = serr os.Stderr = serr
if err != nil { if err != nil {
return "" return nil
} }
for _, graphics := range gpu.GraphicsCards { for i, graphics := range gpu.GraphicsCards {
if slices.Contains(config.HiddenGPUS, i+1) {
continue
}
if graphics.DeviceInfo != nil { if graphics.DeviceInfo != nil {
return graphics.DeviceInfo.Product.Name ret = append(ret, graphics.DeviceInfo.Product.Name)
} }
} }
return "" return ret
} }
type Memory struct { type Memory struct {