8 Commits
5 changed files with 43 additions and 17 deletions
+3 -1
View File
@@ -1,3 +1,5 @@
SHELL := /bin/bash
ifeq ($(PREFIX),) ifeq ($(PREFIX),)
PREFIX := /usr/local PREFIX := /usr/local
endif endif
@@ -35,4 +37,4 @@ run: build/stormfetch
clean: clean:
rm -r build/ rm -r build/
.PHONY: build .PHONY: build
+1 -1
View File
@@ -3,7 +3,7 @@
## A simple linux fetch program written in go and bash ## A simple linux fetch program written in go and bash
### Developers: ### Developers:
- [CapCreeperGR ](https://gitlab.com/CapCreeperGR) - [EnumDev](https://gitlab.com/EnumDev)
### Project Information ### Project Information
Stormfetch is a program that can read your system's information and display it in the terminal along with the ASCII art of the Linux distribution you are running. Stormfetch is a program that can read your system's information and display it in the terminal along with the ASCII art of the Linux distribution you are running.
+4
View File
@@ -7,6 +7,7 @@ echo -e "${C3}Packages: ${C4}$(get_packages)"
echo -e "${C3}Shell: ${C4}${USER_SHELL}" echo -e "${C3}Shell: ${C4}${USER_SHELL}"
echo -e "${C3}Init: ${C4}${INIT_SYSTEM}" echo -e "${C3}Init: ${C4}${INIT_SYSTEM}"
echo -e "${C3}Libc: ${C4}${LIBC}" echo -e "${C3}Libc: ${C4}${LIBC}"
[ -n "$MOTHERBOARD" ] && echo -e "${C3}Motherboard: ${C4}${MOTHERBOARD}"
[ -n "$CPU_MODEL" ] && echo -e "${C3}CPU: ${C4}${CPU_MODEL} (${CPU_THREADS} threads)" [ -n "$CPU_MODEL" ] && echo -e "${C3}CPU: ${C4}${CPU_MODEL} (${CPU_THREADS} threads)"
for i in $(seq "${CONNECTED_GPUS}"); do for i in $(seq "${CONNECTED_GPUS}"); do
gpu="GPU$i" gpu="GPU$i"
@@ -42,3 +43,6 @@ if [ -n "$DISPLAY_PROTOCOL" ]; then
done done
fi fi
[ -n "$DE_WM" ] && echo -e "${C3}DE/WM: ${C4}${DE_WM}" [ -n "$DE_WM" ] && echo -e "${C3}DE/WM: ${C4}${DE_WM}"
# Exiting with error code 0 in case the condition above returns 1
exit 0
+2 -1
View File
@@ -128,6 +128,7 @@ func SetupFetchEnv(showTimeTaken bool) []string {
setVariable("DISTRO_LONG_NAME", func() string { return getDistroInfo().LongName }) setVariable("DISTRO_LONG_NAME", func() string { return getDistroInfo().LongName })
setVariable("DISTRO_SHORT_NAME", func() string { return getDistroInfo().ShortName }) setVariable("DISTRO_SHORT_NAME", func() string { return getDistroInfo().ShortName })
setVariable("CPU_MODEL", func() string { return getCPUName() }) setVariable("CPU_MODEL", func() string { return getCPUName() })
setVariable("MOTHERBOARD", func() string { return getMotherboardModel() })
setVariable("CPU_THREADS", func() string { return strconv.Itoa(getCPUThreads()) }) setVariable("CPU_THREADS", func() string { return strconv.Itoa(getCPUThreads()) })
start := time.Now().UnixMilli() start := time.Now().UnixMilli()
memory := GetMemoryInfo() memory := GetMemoryInfo()
@@ -259,7 +260,7 @@ func runStormfetch() {
} }
out, err := cmd.Output() out, err := cmd.Output()
if err != nil { if err != nil {
log.Fatal(err) log.Fatalf("Error: Could not run fetch script: %s", err)
} }
// Print Distro Information // Print Distro Information
maxWidth := 0 maxWidth := 0
+33 -14
View File
@@ -73,8 +73,8 @@ func getDistroAsciiArt() string {
} }
userConfDir, err := os.UserConfigDir() userConfDir, err := os.UserConfigDir()
if err != nil { if err != nil {
if _, err := os.Stat(path.Join("/etc/stormfetch/ascii/", id)); err == nil { if _, err := os.Stat(path.Join(systemConfigDir, "stormfetch/ascii/", id)); err == nil {
bytes, err := os.ReadFile(path.Join("/etc/stormfetch/ascii/", id)) bytes, err := os.ReadFile(path.Join(systemConfigDir, "stormfetch/ascii/", id))
if err != nil { if err != nil {
return defaultAscii return defaultAscii
} }
@@ -89,8 +89,8 @@ func getDistroAsciiArt() string {
return defaultAscii return defaultAscii
} }
return string(bytes) return string(bytes)
} else if _, err := os.Stat(path.Join("/etc/stormfetch/ascii/", id)); err == nil { } else if _, err := os.Stat(path.Join(systemConfigDir, "stormfetch/ascii/", id)); err == nil {
bytes, err := os.ReadFile(path.Join("/etc/stormfetch/ascii/", id)) bytes, err := os.ReadFile(path.Join(systemConfigDir, "stormfetch/ascii/", id))
if err != nil { if err != nil {
return defaultAscii return defaultAscii
} }
@@ -100,6 +100,14 @@ func getDistroAsciiArt() string {
} }
} }
func getMotherboardModel() string {
bytes, err := os.ReadFile("/sys/devices/virtual/dmi/id/board_name")
if err != nil {
return ""
}
return strings.TrimSpace(string(bytes))
}
func getCPUName() string { func getCPUName() string {
cpu, err := ghw.CPU() cpu, err := ghw.CPU()
if err != nil { if err != nil {
@@ -236,7 +244,7 @@ func GetShell() string {
func GetDEWM() string { func GetDEWM() string {
processes, err := ps.Processes() processes, err := ps.Processes()
if err != nil { if err != nil {
log.Fatal(err) log.Fatalf("Error: could not get processes: %s", err)
} }
var executables []string var executables []string
for _, process := range processes { for _, process := range processes {
@@ -265,7 +273,7 @@ func GetDEWM() string {
} else if processExists("gnome-session") { } else if processExists("gnome-session") {
return "Gnome " + runCommand("gnome-shell --version | awk '{print $3}'") return "Gnome " + runCommand("gnome-shell --version | awk '{print $3}'")
} else if processExists("xfce4-session") { } else if processExists("xfce4-session") {
return "XFCE " + runCommand("xfce4-session --version | grep xfce4-session | awk '{print $2}'") return "XFCE " + runCommand("xfce4-session --version | head -n1 | awk '{print $2}'")
} else if processExists("cinnamon") { } else if processExists("cinnamon") {
return "Cinnamon " + runCommand("cinnamon --version | awk '{print $3}'") return "Cinnamon " + runCommand("cinnamon --version | awk '{print $3}'")
} else if processExists("mate-panel") { } else if processExists("mate-panel") {
@@ -411,18 +419,29 @@ func GetInitSystem() string {
return strings.TrimSpace(string(out)) return strings.TrimSpace(string(out))
} }
link, err := os.Readlink("/sbin/init") process, err := ps.FindProcess(1)
if err != nil { if err != nil {
return "Unknown" return ""
} }
if path.Base(link) == "systemd" {
return "Systemd " + runCommand("systemctl --version | head -1 | awk '{print $2}'") // Special cases
} else if path.Base(link) == "openrc-init" { // OpenRC check
if _, err := os.Stat("/usr/sbin/openrc"); err == nil {
return "OpenRC " + runCommand("openrc --version | awk '{print $3}'") return "OpenRC " + runCommand("openrc --version | awk '{print $3}'")
} else if path.Base(link) == "runit-init" { }
// Default PID 1 process name checking
switch process.Executable() {
case "systemd":
return "Systemd " + runCommand("systemctl --version | head -n1 | awk '{print $2}'")
case "runit":
return "Runit" return "Runit"
} else { case "dinit":
return "Unknown" return "Dinit " + runCommand("dinit --version | head -n1 | awk '{print substr($3, 1, length($3)-1)}'")
case "enit":
return "Enit " + runCommand("enit --version | awk '{print $3}'")
default:
return process.Executable()
} }
} }