Fixed chroot bugs and reduced executable size
Stormfetch will now only list CPU and memory information if available Added 'ldflag "-w"' to go build which reduces file size Added 'run' goal to Makefile
This commit is contained in:
parent
4a2833afff
commit
2984a7da5f
5
Makefile
5
Makefile
@ -13,7 +13,7 @@ endif
|
||||
|
||||
build:
|
||||
mkdir -p build
|
||||
$(GO) build -o build/stormfetch stormfetch
|
||||
$(GO) build -ldflags "-w" -o build/stormfetch stormfetch
|
||||
|
||||
install: build/stormfetch config/
|
||||
mkdir -p $(DESTDIR)$(BINDIR)
|
||||
@ -29,5 +29,8 @@ compress: build/stormfetch config/
|
||||
tar --owner=root --group=root -czf stormfetch.tar.gz stormfetch
|
||||
rm -r stormfetch
|
||||
|
||||
run: build/stormfetch
|
||||
build/stormfetch
|
||||
|
||||
clean:
|
||||
rm -r build/
|
@ -5,11 +5,15 @@ echo -e "${C3}Hostname: ${C4}$(cat /etc/hostname)"
|
||||
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
|
||||
if [ ! -z "$MEM_TOTAL" ] && [ ! -z "$MEM_USED" ]; then
|
||||
echo -e "${C3}Memory: ${C4}${MEM_USED} MiB / ${MEM_TOTAL} MiB"
|
||||
fi
|
||||
if xhost >& /dev/null ; then
|
||||
if [ ! -z "$DE_WM" ]; then
|
||||
echo -e "${C3}DE/WM: ${C4}${DE_WM}"
|
||||
|
2
main.go
2
main.go
@ -144,9 +144,11 @@ func readConfig() {
|
||||
cmd.Env = append(cmd.Env, "CPU_MODEL="+getCPUName())
|
||||
cmd.Env = append(cmd.Env, "CPU_THREADS="+strconv.Itoa(getCPUThreads()))
|
||||
memory := GetMemoryInfo()
|
||||
if memory != nil {
|
||||
cmd.Env = append(cmd.Env, "MEM_TOTAL="+strconv.Itoa(memory.MemTotal))
|
||||
cmd.Env = append(cmd.Env, "MEM_USED="+strconv.Itoa(memory.MemTotal-memory.MemAvailable))
|
||||
cmd.Env = append(cmd.Env, "MEM_FREE="+strconv.Itoa(memory.MemAvailable))
|
||||
}
|
||||
cmd.Env = append(cmd.Env, "DE_WM="+GetDEWM())
|
||||
cmd.Env = append(cmd.Env, "USER_SHELL="+GetShell())
|
||||
if getGPUName() != "" {
|
||||
|
10
utils.go
10
utils.go
@ -108,6 +108,9 @@ func getCPUName() string {
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
if len(cpu.Processors) == 0 {
|
||||
return ""
|
||||
}
|
||||
return cpu.Processors[0].Model
|
||||
}
|
||||
|
||||
@ -141,7 +144,7 @@ type Memory struct {
|
||||
MemAvailable int
|
||||
}
|
||||
|
||||
func GetMemoryInfo() Memory {
|
||||
func GetMemoryInfo() *Memory {
|
||||
toInt := func(raw string) int {
|
||||
if raw == "" {
|
||||
return 0
|
||||
@ -159,6 +162,9 @@ func GetMemoryInfo() Memory {
|
||||
return keyValue[0], toInt(keyValue[1])
|
||||
}
|
||||
|
||||
if _, err := os.Stat("/proc/meminfo"); err != nil {
|
||||
return nil
|
||||
}
|
||||
file, err := os.Open("/proc/meminfo")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@ -178,7 +184,7 @@ func GetMemoryInfo() Memory {
|
||||
res.MemAvailable = value / 1024
|
||||
}
|
||||
}
|
||||
return res
|
||||
return &res
|
||||
}
|
||||
|
||||
func GetShell() string {
|
||||
|
Loading…
x
Reference in New Issue
Block a user