mirror of
https://github.com/EnumeratedDev/stormfetch.git
synced 2026-09-24 03:36:11 +00:00
Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a919ffb71b
|
||
|
|
8147d302c8
|
||
|
|
8dfe7b3a0e
|
||
|
|
8cafe93b33
|
||
|
|
adcf06c149
|
||
|
|
5ef39f89cc
|
||
|
|
738d2c2086
|
||
|
|
637bd2c3e3 |
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
### 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.
|
||||||
Stormfetch is still in beta, so distro compatibility is limited. If you would like to contribute ASCII art or add other compatibility features feel free to create a pull request or notify me through GitLab Issues.
|
At the moment ascii art for different distributions is limited. If you would like to contribute ascii art feel free to make a pull request.
|
||||||
|
|
||||||
### How it looks
|
### How it looks
|
||||||

|

|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 121 KiB After Width: | Height: | Size: 12 MiB |
@@ -92,8 +92,24 @@ func GetGPUModels(hiddenGPUs []int) []GPU {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if device info is set
|
||||||
|
if gpu.DeviceInfo == nil {
|
||||||
|
ret = append(ret, GPU{
|
||||||
|
PCIAddress: gpu.Address,
|
||||||
|
Vendor: "Unknown",
|
||||||
|
Name: "GPU",
|
||||||
|
Product: "Unknown",
|
||||||
|
Subsystem: "Unknown",
|
||||||
|
Driver: "Unknown",
|
||||||
|
VramTotal: "Unknown",
|
||||||
|
VramUsed: "Unknown",
|
||||||
|
})
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// Set alternative names for vendors
|
// Set alternative names for vendors
|
||||||
var vendor string
|
var vendor string
|
||||||
|
|
||||||
switch gpu.DeviceInfo.Vendor.ID {
|
switch gpu.DeviceInfo.Vendor.ID {
|
||||||
case "1002":
|
case "1002":
|
||||||
vendor = "AMD"
|
vendor = "AMD"
|
||||||
|
|||||||
+6
-3
@@ -358,6 +358,11 @@ func initializeModuleMap() {
|
|||||||
localIpModule := StormfetchModule{stormfetchModuleConfig: stormfetchModuleConfig{Name: "local_ip", Format: "%3Local IP: %4$LOCAL_IP"}, Execute: func(sm StormfetchModule) string {
|
localIpModule := StormfetchModule{stormfetchModuleConfig: stormfetchModuleConfig{Name: "local_ip", Format: "%3Local IP: %4$LOCAL_IP"}, Execute: func(sm StormfetchModule) string {
|
||||||
localIP := GetLocalIP()
|
localIP := GetLocalIP()
|
||||||
|
|
||||||
|
// Return empty string if local IP is unavailable
|
||||||
|
if localIP == "Unknown" {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
return os.Expand(sm.Format, func(s string) string {
|
return os.Expand(sm.Format, func(s string) string {
|
||||||
switch s {
|
switch s {
|
||||||
case "LOCAL_IP":
|
case "LOCAL_IP":
|
||||||
@@ -370,7 +375,7 @@ func initializeModuleMap() {
|
|||||||
RegisterModule(localIpModule)
|
RegisterModule(localIpModule)
|
||||||
|
|
||||||
// DEWM module
|
// DEWM module
|
||||||
dewmModule := StormfetchModule{stormfetchModuleConfig: stormfetchModuleConfig{Name: "de_wm", Format: "%3${DEWM_TYPE}: %4${DEWM_NAME} ${DEWM_VERSION} ($DISPLAY_PROTOCOL)"}, Execute: func(sm StormfetchModule) string {
|
dewmModule := StormfetchModule{stormfetchModuleConfig: stormfetchModuleConfig{Name: "de_wm", Format: "%3${DEWM_TYPE}: %4${DEWM_NAME} ($DISPLAY_PROTOCOL)"}, Execute: func(sm StormfetchModule) string {
|
||||||
// Return empty string if currently in TTY
|
// Return empty string if currently in TTY
|
||||||
if os.Getenv("XDG_SESSION_TYPE") == "" || os.Getenv("XDG_SESSION_TYPE") == "tty" {
|
if os.Getenv("XDG_SESSION_TYPE") == "" || os.Getenv("XDG_SESSION_TYPE") == "tty" {
|
||||||
return ""
|
return ""
|
||||||
@@ -390,8 +395,6 @@ func initializeModuleMap() {
|
|||||||
return dewm.Name
|
return dewm.Name
|
||||||
case "DEWM_TYPE":
|
case "DEWM_TYPE":
|
||||||
return dewm.Type
|
return dewm.Type
|
||||||
case "DEWM_VERSION":
|
|
||||||
return dewm.Version
|
|
||||||
case "DISPLAY_PROTOCOL":
|
case "DISPLAY_PROTOCOL":
|
||||||
return displayProtocol
|
return displayProtocol
|
||||||
default:
|
default:
|
||||||
|
|||||||
+22
-8
@@ -146,21 +146,35 @@ func GetInitSystem() string {
|
|||||||
// Special cases
|
// Special cases
|
||||||
// OpenRC check
|
// OpenRC check
|
||||||
if _, err := os.Stat("/usr/sbin/openrc"); err == nil {
|
if _, err := os.Stat("/usr/sbin/openrc"); err == nil {
|
||||||
return "OpenRC " + runCommand("openrc --version | awk '{print $3}'", "/bin/sh")
|
openrcVersion := runCommand("openrc --version | awk '{print $3}'", "/bin/sh")
|
||||||
|
if openrcVersion != "" {
|
||||||
|
return "OpenRC " + openrcVersion
|
||||||
|
} else {
|
||||||
|
return "OpenRC"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default PID 1 process name checking
|
// Default PID 1 process name checking
|
||||||
switch process.Executable() {
|
initName := process.Executable()
|
||||||
|
initVersion := ""
|
||||||
|
switch initName {
|
||||||
case "systemd":
|
case "systemd":
|
||||||
return "Systemd " + runCommand("systemctl --version | head -n1 | awk '{print $2}'", "/bin/sh")
|
initName = "Systemd"
|
||||||
|
initVersion = runCommand("systemctl --version | head -n1 | awk '{print $2}'", "/bin/sh")
|
||||||
case "runit":
|
case "runit":
|
||||||
return "Runit"
|
initName = "Runit"
|
||||||
case "dinit":
|
case "dinit":
|
||||||
return "Dinit " + runCommand("dinit --version | head -n1 | awk '{print substr($3, 1, length($3)-1)}'", "/bin/sh")
|
initName = "Dinit"
|
||||||
|
initVersion = runCommand("dinit --version | head -n1 | awk '{print substr($3, 1, length($3)-1)}'", "/bin/sh")
|
||||||
case "enit":
|
case "enit":
|
||||||
return "Enit " + runCommand("enit --version | awk '{print $3}'", "/bin/sh")
|
initName = "Enit"
|
||||||
default:
|
initVersion = runCommand("enit --version | awk '{print $3}'", "/bin/sh")
|
||||||
return process.Executable()
|
}
|
||||||
|
|
||||||
|
if initVersion != "" {
|
||||||
|
return initName + " " + initVersion
|
||||||
|
} else {
|
||||||
|
return initName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+74
-22
@@ -14,7 +14,6 @@ import (
|
|||||||
type DEWM struct {
|
type DEWM struct {
|
||||||
Name string
|
Name string
|
||||||
Type string
|
Type string
|
||||||
Version string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetShell() string {
|
func GetShell() string {
|
||||||
@@ -34,21 +33,30 @@ func GetShell() string {
|
|||||||
shell = userInfo[6]
|
shell = userInfo[6]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
shellName := filepath.Base(shell)
|
shellName := "Unknown"
|
||||||
switch shellName {
|
shellVersion := ""
|
||||||
case "dash":
|
switch filepath.Base(shell) {
|
||||||
return "Dash"
|
|
||||||
case "bash":
|
case "bash":
|
||||||
return "Bash " + runCommand("echo $BASH_VERSION", "/bin/sh")
|
shellName = "Bash"
|
||||||
|
shellVersion = runCommand("$SHELL --version | head -n1 | awk '{print $4}'", "/bin/sh")
|
||||||
case "zsh":
|
case "zsh":
|
||||||
return "Zsh " + runCommand("$SHELL --version | awk '{print $2}'", "/bin/sh")
|
shellName = "Zsh"
|
||||||
|
shellVersion = runCommand("$SHELL --version | awk '{print $2}'", "/bin/sh")
|
||||||
case "fish":
|
case "fish":
|
||||||
return "Fish " + runCommand("$SHELL --version | awk '{print $3}'", "/bin/sh")
|
shellName = "Fish"
|
||||||
|
shellVersion = runCommand("$SHELL --version | awk '{print $3}'", "/bin/sh")
|
||||||
case "nu":
|
case "nu":
|
||||||
return "Nushell " + runCommand("$SHELL --version", "/bin/sh")
|
shellName = "Nushell"
|
||||||
|
shellVersion = runCommand("$SHELL --version", "/bin/sh")
|
||||||
default:
|
default:
|
||||||
return "Unknown"
|
return "Unknown"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if shellVersion != "" {
|
||||||
|
return shellName + " " + shellVersion
|
||||||
|
} else {
|
||||||
|
return shellName
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetDEWM() DEWM {
|
func GetDEWM() DEWM {
|
||||||
@@ -68,96 +76,140 @@ func GetDEWM() DEWM {
|
|||||||
dewm := DEWM{
|
dewm := DEWM{
|
||||||
Name: "KDE Plasma",
|
Name: "KDE Plasma",
|
||||||
Type: "DE",
|
Type: "DE",
|
||||||
Version: runCommand("plasmashell --version | awk '{print $2}'", "/bin/sh"),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if version := runCommand("plasmashell --version | awk '{print $2}'", "/bin/sh"); version != "" {
|
||||||
|
dewm.Name += " " + version
|
||||||
|
}
|
||||||
|
|
||||||
return dewm
|
return dewm
|
||||||
} else if processExists("gnome-session") {
|
} else if processExists("gnome-session") {
|
||||||
dewm := DEWM{
|
dewm := DEWM{
|
||||||
Name: "Gnome",
|
Name: "Gnome",
|
||||||
Type: "DE",
|
Type: "DE",
|
||||||
Version: runCommand("gnome-shell --version | awk '{print $3}'", "/bin/sh"),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if version := runCommand("gnome-shell --version | awk '{print $3}'", "/bin/sh"); version != "" {
|
||||||
|
dewm.Name += " " + version
|
||||||
|
}
|
||||||
|
|
||||||
return dewm
|
return dewm
|
||||||
} else if processExists("xfce4-session") {
|
} else if processExists("xfce4-session") {
|
||||||
dewm := DEWM{
|
dewm := DEWM{
|
||||||
Name: "XFCE",
|
Name: "XFCE",
|
||||||
Type: "DE",
|
Type: "DE",
|
||||||
Version: runCommand("xfce4-session --version | head -n1 | awk '{print $2}'", "/bin/sh"),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if version := runCommand("xfce4-session --version | head -n1 | awk '{print $2}'", "/bin/sh"); version != "" {
|
||||||
|
dewm.Name += " " + version
|
||||||
|
}
|
||||||
|
|
||||||
return dewm
|
return dewm
|
||||||
} else if processExists("cinnamon") {
|
} else if processExists("cinnamon") {
|
||||||
dewm := DEWM{
|
dewm := DEWM{
|
||||||
Name: "Cinnamon",
|
Name: "Cinnamon",
|
||||||
Type: "DE",
|
Type: "DE",
|
||||||
Version: runCommand("cinnamon --version | awk '{print $3}'", "/bin/sh"),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if version := runCommand("cinnamon --version | awk '{print $3}'", "/bin/sh"); version != "" {
|
||||||
|
dewm.Name += " " + version
|
||||||
|
}
|
||||||
|
|
||||||
return dewm
|
return dewm
|
||||||
} else if processExists("mate-panel") {
|
} else if processExists("mate-panel") {
|
||||||
dewm := DEWM{
|
dewm := DEWM{
|
||||||
Name: "MATE",
|
Name: "MATE",
|
||||||
Type: "DE",
|
Type: "DE",
|
||||||
Version: runCommand("mate-about --version | awk '{print $4}'", "/bin/sh"),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if version := runCommand("mate-about --version | awk '{print $4}'", "/bin/sh"); version != "" {
|
||||||
|
dewm.Name += " " + version
|
||||||
|
}
|
||||||
|
|
||||||
return dewm
|
return dewm
|
||||||
} else if processExists("lxsession") {
|
} else if processExists("lxsession") {
|
||||||
dewm := DEWM{
|
dewm := DEWM{
|
||||||
Name: "LXDE",
|
Name: "LXDE",
|
||||||
Type: "DE",
|
Type: "DE",
|
||||||
Version: "",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return dewm
|
return dewm
|
||||||
} else if processExists("lxqt-session") {
|
} else if processExists("lxqt-session") {
|
||||||
dewm := DEWM{
|
dewm := DEWM{
|
||||||
Name: "LXQt",
|
Name: "LXQt",
|
||||||
Type: "DE",
|
Type: "DE",
|
||||||
Version: runCommand("lxqt-session --version | head -n1 | awk '{print $2}'", "/bin/sh"),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if version := runCommand("lxqt-session --version | head -n1 | awk '{print $2}'", "/bin/sh"); version != "" {
|
||||||
|
dewm.Name += " " + version
|
||||||
|
}
|
||||||
|
|
||||||
return dewm
|
return dewm
|
||||||
} else if processExists("i3") || processExists("i3-with-shmlog") {
|
} else if processExists("i3") || processExists("i3-with-shmlog") {
|
||||||
dewm := DEWM{
|
dewm := DEWM{
|
||||||
Name: "i3",
|
Name: "i3",
|
||||||
Type: "WM",
|
Type: "WM",
|
||||||
Version: runCommand("i3 --version | awk '{print $3}'", "/bin/sh"),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if version := runCommand("i3 --version | awk '{print $3}'", "/bin/sh"); version != "" {
|
||||||
|
dewm.Name += " " + version
|
||||||
|
}
|
||||||
|
|
||||||
return dewm
|
return dewm
|
||||||
} else if processExists("sway") {
|
} else if processExists("sway") {
|
||||||
dewm := DEWM{
|
dewm := DEWM{
|
||||||
Name: "Sway",
|
Name: "Sway",
|
||||||
Type: "WM",
|
Type: "WM",
|
||||||
Version: runCommand("sway --version | awk '{print $3}'", "/bin/sh"),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if runCommand("sway --version | awk '{print $1}'", "/bin/sh") == "swayfx" {
|
if runCommand("sway --version | awk '{print $1}'", "/bin/sh") == "swayfx" {
|
||||||
dewm.Name = "SwayFX"
|
dewm.Name = "SwayFX"
|
||||||
} else {
|
} else {
|
||||||
dewm.Name = "Sway"
|
dewm.Name = "Sway"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if version := runCommand("sway --version | awk '{print $3}'", "/bin/sh"); version != "" {
|
||||||
|
dewm.Name += " " + version
|
||||||
|
}
|
||||||
|
|
||||||
return dewm
|
return dewm
|
||||||
} else if processExists("bspwm") {
|
} else if processExists("bspwm") {
|
||||||
dewm := DEWM{
|
dewm := DEWM{
|
||||||
Name: "Bspwm",
|
Name: "Bspwm",
|
||||||
Type: "WM",
|
Type: "WM",
|
||||||
Version: runCommand("bspwm -v", "/bin/sh"),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if version := runCommand("bspwm -v", "/bin/sh"); version != "" {
|
||||||
|
dewm.Name += " " + version
|
||||||
|
}
|
||||||
|
|
||||||
return dewm
|
return dewm
|
||||||
} else if processExists("Hyprland") {
|
} else if processExists("Hyprland") {
|
||||||
dewm := DEWM{
|
dewm := DEWM{
|
||||||
Name: "Hyprland",
|
Name: "Hyprland",
|
||||||
Type: "WM",
|
Type: "WM",
|
||||||
Version: runCommand("hyprctl version | sed -n 3p | awk '{print $2}' | tr -d 'v,'", "/bin/sh"),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if version := runCommand("hyprctl version | sed -n 3p | awk '{print $2}' | tr -d 'v,'", "/bin/sh"); version != "" {
|
||||||
|
dewm.Name += " " + version
|
||||||
|
}
|
||||||
|
|
||||||
return dewm
|
return dewm
|
||||||
} else if processExists("icewm-session") {
|
} else if processExists("icewm-session") {
|
||||||
dewm := DEWM{
|
dewm := DEWM{
|
||||||
Name: "IceWM",
|
Name: "IceWM",
|
||||||
Type: "WM",
|
Type: "WM",
|
||||||
Version: runCommand("icewm --version | awk '{print $2}'", "/bin/sh"),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if version := runCommand("icewm --version | awk '{print $2}'", "/bin/sh"); version != "" {
|
||||||
|
dewm.Name += " " + version
|
||||||
|
}
|
||||||
|
|
||||||
return dewm
|
return dewm
|
||||||
}
|
}
|
||||||
return DEWM{
|
return DEWM{
|
||||||
Name: "Unknown",
|
Name: "Unknown",
|
||||||
Type: "Unknown",
|
Type: "Unknown",
|
||||||
Version: "Unknown",
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user