mirror of
https://github.com/EnumeratedDev/stormfetch.git
synced 2026-09-16 07:56:12 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
76974ee789 | ||
|
|
20cf7fe869 | ||
|
|
c5e02c07b5 | ||
|
|
e8a95e5313 | ||
|
|
0fd198d83e | ||
|
|
673f231c42 | ||
|
|
e311649a48 | ||
|
|
712fd78e21 | ||
|
|
7d83b0996d | ||
|
|
f3a016b674 | ||
|
|
0e2631d5b0 | ||
|
|
153758b68e |
@@ -8,7 +8,7 @@ ifeq ($(SYSCONFDIR),)
|
|||||||
SYSCONFDIR := $(PREFIX)/etc
|
SYSCONFDIR := $(PREFIX)/etc
|
||||||
endif
|
endif
|
||||||
ifeq ($(GO),)
|
ifeq ($(GO),)
|
||||||
GO := /usr/bin/go
|
GO := $(shell type -a -P go | head -n 1)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
build:
|
build:
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#/45;27;45;7
|
||||||
|
${C1} 'o'
|
||||||
|
'ooo'
|
||||||
|
'ooxoo'
|
||||||
|
'ooxxxoo'
|
||||||
|
'oookkxxoo'
|
||||||
|
'oiioxkkxxoo'
|
||||||
|
':;:iiiioxxxoo'
|
||||||
|
`'.;::ioxxoo'
|
||||||
|
'-. `':;jiooo'
|
||||||
|
'oooio-.. `'i:io'
|
||||||
|
'ooooxxxxoio:,. `'-;'
|
||||||
|
'ooooxxxxxkkxoooIi:-. `'
|
||||||
|
'ooooxxxxxkkkkxoiiiiiji'
|
||||||
|
'ooooxxxxxkxxoiiii:'` .i'
|
||||||
|
'ooooxxxxxoi:::'` .;ioxo'
|
||||||
|
'ooooxooi::'` .:iiixkxxo'
|
||||||
|
'ooooi:'` `'';ioxxo'
|
||||||
|
'i:'` '':io'
|
||||||
|
'` `'
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
#/33;7;11;15
|
||||||
|
${C1} /////////////
|
||||||
|
/////////////////////
|
||||||
|
///////${C2}*767${C1}////////////////
|
||||||
|
//////${C2}7676767676*${C1}//////////////
|
||||||
|
/////${C2}76767${C1}//${C2}7676767${C1}//////////////
|
||||||
|
/////${C2}767676${C1}///${C2}*76767${C1}///////////////
|
||||||
|
///////${C2}767676${C1}///${C2}76767${C1}.///${C2}7676*${C1}///////
|
||||||
|
/////////${C2}767676${C1}//${C2}76767${C1}///${C2}767676${C1}////////
|
||||||
|
//////////${C2}76767676767${C1}////${C2}76767${C1}/////////
|
||||||
|
///////////${C2}76767676${C1}//////${C2}7676${C1}//////////
|
||||||
|
////////////,${C2}7676${C1},///////${C2}767${C1}///////////
|
||||||
|
/////////////*${C2}7676${C1}///////${C2}76${C1}////////////
|
||||||
|
///////////////${C2}7676${C1}////////////////////
|
||||||
|
///////////////${C2}7676${C1}///${C2}767${C1}////////////
|
||||||
|
//////////////////////${C2}'${C1}////////////
|
||||||
|
//////${C2}.7676767676767676767,${C1}//////
|
||||||
|
/////${C2}767676767676767676767${C1}/////
|
||||||
|
///////////////////////////
|
||||||
|
/////////////////////
|
||||||
|
/////////////
|
||||||
+15
-18
@@ -1,18 +1,15 @@
|
|||||||
#/6;10;5;12
|
#/27;39;5;12
|
||||||
${C1} @@@@@@@@@
|
${C1}@@@@ ${C1}@@@${C2}*
|
||||||
@@@~~~~~~~~~@@
|
${C1}@@${C2}~~~~${C1}@@ ${C1}@@${C2}~~~
|
||||||
@@~~~ ~~@
|
${C1}@@${C2}~~ ${C2}~~${C1}@ ${C1}@@${C2}~~
|
||||||
@~~ @
|
${C1}@@${C2}~~ ${C2}~${C1}@ ${C1}@@@${C2}~~
|
||||||
@~ @@@ @
|
${C2}*${C1}@@${C2}~~ ${C1}@@@@ ${C2}~${C1}@@@@${C2}~~~ ${C1}@@@${C2}*
|
||||||
@@~ @ @@
|
${C2}~~ ${C1}@@${C2}~~~~${C1}@@ ${C2}~~~~ ${C1}@@${C2}~~~
|
||||||
@@~~ @
|
${C1}@@${C2}~~ ${C2}~~${C1}@ ${C1}@@${C2}~~
|
||||||
@@@~~ ~@@ @@@
|
${C1}@@${C2}~~ ${C2}~${C1}@ ${C1}@@@${C2}~~
|
||||||
~~~ ~~@@@ @@@@~~~
|
${C2}*${C1}@@${C2}~~ ${C1}@@@@ ${C2}~${C1}@@@@${C2}~~~ ${C1}@@@${C2}*
|
||||||
~~~@@@@~~~~
|
${C2}~~ ${C1}@@${C2}~~~~${C1}@@ ${C2}~~~~ ${C1}@@${C2}~~~
|
||||||
@@@@ @@@@@@@ ~~~~ @@@@
|
${C1}@@${C2}~~ ${C2}~~${C1}@ ${C1}@@${C2}~~
|
||||||
~~~~@@@@ @@~~~~~~~@@ @@@@
|
${C1}@@${C2}~~ ${C2}~${C1}@ ${C1}@@@${C2}~~
|
||||||
~~~~@@@@~~ ~~@@@@~~~~
|
${C2}*${C1}@@${C2}~~ ${C2}~${C1}@@@@${C2}~~~
|
||||||
@@@ ~~~~ @@@@@ ~~~~ @@@
|
${C2}~~ ${C2}~~~~
|
||||||
~~~@@@@ @@@@~~~~~@@@@ @@@@~~~
|
|
||||||
~~~~@@@~~~~ ~~~~@@@~~~
|
|
||||||
~~~ ~~~
|
|
||||||
|
|||||||
+10
-8
@@ -5,14 +5,15 @@ echo -e "${C3}Hostname: ${C4}$(cat /etc/hostname)"
|
|||||||
echo -e "${C3}Kernel: ${C4}$(uname -s) $(uname -r)"
|
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
|
echo -e "${C3}Init: ${C4}${INIT_SYSTEM}"
|
||||||
for i in $(seq ${CONNECTED_GPUS}); do
|
echo -e "${C3}Libc: ${C4}${LIBC}"
|
||||||
|
[ -n "$CPU_MODEL" ] && echo -e "${C3}CPU: ${C4}${CPU_MODEL} (${CPU_THREADS} threads)"
|
||||||
|
for i in $(seq "${CONNECTED_GPUS}"); do
|
||||||
gpu="GPU$i"
|
gpu="GPU$i"
|
||||||
echo -e "${C3}GPU: ${C4}${!gpu}"
|
echo -e "${C3}GPU: ${C4}${!gpu}"
|
||||||
done
|
done
|
||||||
if [ ! -z "$MEM_TOTAL" ] && [ ! -z "$MEM_USED" ]; then echo -e "${C3}Memory: ${C4}${MEM_USED} MiB / ${MEM_TOTAL} MiB"; fi
|
[ -n "$MEM_TOTAL" ] && [ -n "$MEM_USED" ] && echo -e "${C3}Memory: ${C4}${MEM_USED} MiB / ${MEM_TOTAL} MiB"
|
||||||
for i in $(seq ${MOUNTED_PARTITIONS}); do
|
for i in $(seq "${MOUNTED_PARTITIONS}"); do
|
||||||
device="PARTITION${i}_DEVICE"
|
|
||||||
mountpoint="PARTITION${i}_MOUNTPOINT"
|
mountpoint="PARTITION${i}_MOUNTPOINT"
|
||||||
label="PARTITION${i}_LABEL"
|
label="PARTITION${i}_LABEL"
|
||||||
type="PARTITION${i}_TYPE"
|
type="PARTITION${i}_TYPE"
|
||||||
@@ -32,11 +33,12 @@ for i in $(seq ${MOUNTED_PARTITIONS}); do
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [ ! -z "$DISPLAY_PROTOCOL" ]; then
|
[ -n "$LOCAL_IPV4" ] && echo -e "${C3}Local IPv4 Address: ${C4}${LOCAL_IPV4}"
|
||||||
|
if [ -n "$DISPLAY_PROTOCOL" ]; then
|
||||||
echo -e "${C3}Display Protocol: ${C4}${DISPLAY_PROTOCOL}"
|
echo -e "${C3}Display Protocol: ${C4}${DISPLAY_PROTOCOL}"
|
||||||
for i in $(seq ${CONNECTED_MONITORS}); do
|
for i in $(seq "${CONNECTED_MONITORS}"); do
|
||||||
monitor="MONITOR$i"
|
monitor="MONITOR$i"
|
||||||
echo -e "${C3}Screen $i: ${C4}${!monitor}"
|
echo -e "${C3}Screen $i: ${C4}${!monitor}"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
if [ ! -z "$DE_WM" ]; then echo -e "${C3}DE/WM: ${C4}${DE_WM}"; fi
|
[ -n "$DE_WM" ] && echo -e "${C3}DE/WM: ${C4}${DE_WM}"
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ require (
|
|||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20240506104042-037f3cc74f2a // indirect
|
||||||
github.com/go-ole/go-ole v1.2.6 // indirect
|
github.com/go-ole/go-ole v1.2.6 // indirect
|
||||||
github.com/jackmordaunt/pcidb v1.0.1 // indirect
|
github.com/jackmordaunt/pcidb v1.0.1 // indirect
|
||||||
github.com/jackmordaunt/wmi v1.2.4 // indirect
|
github.com/jackmordaunt/wmi v1.2.4 // indirect
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
github.com/BurntSushi/xgb v0.0.0-20210121224620-deaf085860bc h1:7D+Bh06CRPCJO3gr2F7h1sriovOZ8BMhca2Rg85c2nk=
|
github.com/BurntSushi/xgb v0.0.0-20210121224620-deaf085860bc h1:7D+Bh06CRPCJO3gr2F7h1sriovOZ8BMhca2Rg85c2nk=
|
||||||
github.com/BurntSushi/xgb v0.0.0-20210121224620-deaf085860bc/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
github.com/BurntSushi/xgb v0.0.0-20210121224620-deaf085860bc/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||||
|
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20240506104042-037f3cc74f2a h1:vxnBhFDDT+xzxf1jTJKMKZw3H0swfWk9RpWbBbDK5+0=
|
||||||
|
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20240506104042-037f3cc74f2a/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||||
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
|
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
|
||||||
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
|
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
|
||||||
github.com/jackmordaunt/ghw v1.0.4 h1:as+COFuPuXaNQC3WqzoHS/E2JYWZU7gN8ompNTUxNxs=
|
github.com/jackmordaunt/ghw v1.0.4 h1:as+COFuPuXaNQC3WqzoHS/E2JYWZU7gN8ompNTUxNxs=
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var systemConfigDir = "/etc/"
|
var systemConfigDir = "/etc/"
|
||||||
@@ -18,6 +19,8 @@ var systemConfigDir = "/etc/"
|
|||||||
var configPath = ""
|
var configPath = ""
|
||||||
var fetchScriptPath = ""
|
var fetchScriptPath = ""
|
||||||
|
|
||||||
|
var TimeTaken = false
|
||||||
|
|
||||||
var config = StormfetchConfig{
|
var config = StormfetchConfig{
|
||||||
Ascii: "auto",
|
Ascii: "auto",
|
||||||
FetchScript: "auto",
|
FetchScript: "auto",
|
||||||
@@ -86,8 +89,9 @@ func readConfig() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func readFlags() {
|
func readFlags() {
|
||||||
flag.StringVar(&config.Ascii, "ascii", config.Ascii, "help message for flagname")
|
flag.StringVar(&config.Ascii, "ascii", config.Ascii, "Set distro ascii")
|
||||||
flag.StringVar(&config.DistroName, "distro-name", config.DistroName, "help message for flagname")
|
flag.StringVar(&config.DistroName, "distro-name", config.DistroName, "Set distro name")
|
||||||
|
flag.BoolVar(&TimeTaken, "time-taken", false, "Show time taken for fetched information")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,19 +115,37 @@ func checkDependencies() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetupFetchEnv() []string {
|
func SetupFetchEnv(showTimeTaken bool) []string {
|
||||||
var env = make(map[string]string)
|
var env = make(map[string]string)
|
||||||
env["DISTRO_LONG_NAME"] = getDistroInfo().LongName
|
setVariable := func(key string, setter func() string) {
|
||||||
env["DISTRO_SHORT_NAME"] = getDistroInfo().ShortName
|
start := time.Now().UnixMilli()
|
||||||
env["CPU_MODEL"] = getCPUName()
|
env[key] = setter()
|
||||||
env["CPU_THREADS"] = strconv.Itoa(getCPUThreads())
|
end := time.Now().UnixMilli()
|
||||||
|
if showTimeTaken {
|
||||||
|
fmt.Println(fmt.Sprintf("Setting '%s' took %d milliseconds", key, end-start))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setVariable("DISTRO_LONG_NAME", func() string { return getDistroInfo().LongName })
|
||||||
|
setVariable("DISTRO_SHORT_NAME", func() string { return getDistroInfo().ShortName })
|
||||||
|
setVariable("CPU_MODEL", func() string { return getCPUName() })
|
||||||
|
setVariable("CPU_THREADS", func() string { return strconv.Itoa(getCPUThreads()) })
|
||||||
|
start := time.Now().UnixMilli()
|
||||||
memory := GetMemoryInfo()
|
memory := GetMemoryInfo()
|
||||||
|
end := time.Now().UnixMilli()
|
||||||
|
if showTimeTaken {
|
||||||
|
fmt.Println(fmt.Sprintf("Setting '%s' took %d milliseconds", "MEM_*", end-start))
|
||||||
|
}
|
||||||
if memory != nil {
|
if memory != nil {
|
||||||
env["MEM_TOTAL"] = strconv.Itoa(memory.MemTotal)
|
env["MEM_TOTAL"] = strconv.Itoa(memory.MemTotal)
|
||||||
env["MEM_USED"] = strconv.Itoa(memory.MemTotal - memory.MemAvailable)
|
env["MEM_USED"] = strconv.Itoa(memory.MemTotal - memory.MemAvailable)
|
||||||
env["MEM_FREE"] = strconv.Itoa(memory.MemAvailable)
|
env["MEM_FREE"] = strconv.Itoa(memory.MemAvailable)
|
||||||
}
|
}
|
||||||
|
start = time.Now().UnixMilli()
|
||||||
partitions := getMountedPartitions()
|
partitions := getMountedPartitions()
|
||||||
|
end = time.Now().UnixMilli()
|
||||||
|
if showTimeTaken {
|
||||||
|
fmt.Println(fmt.Sprintf("Setting '%s' took %d milliseconds", "PARTITION_*", end-start))
|
||||||
|
}
|
||||||
if len(partitions) != 0 {
|
if len(partitions) != 0 {
|
||||||
env["MOUNTED_PARTITIONS"] = strconv.Itoa(len(partitions))
|
env["MOUNTED_PARTITIONS"] = strconv.Itoa(len(partitions))
|
||||||
for i, part := range partitions {
|
for i, part := range partitions {
|
||||||
@@ -140,17 +162,30 @@ func SetupFetchEnv() []string {
|
|||||||
env["PARTITION"+strconv.Itoa(i+1)+"_FREE_SIZE"] = FormatBytes(part.FreeSize)
|
env["PARTITION"+strconv.Itoa(i+1)+"_FREE_SIZE"] = FormatBytes(part.FreeSize)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
env["DE_WM"] = GetDEWM()
|
setVariable("DE_WM", func() string { return GetDEWM() })
|
||||||
env["USER_SHELL"] = GetShell()
|
setVariable("USER_SHELL", func() string { return GetShell() })
|
||||||
env["DISPLAY_PROTOCOL"] = GetDisplayProtocol()
|
setVariable("DISPLAY_PROTOCOL", func() string { return GetDisplayProtocol() })
|
||||||
|
setVariable("LIBC", func() string { return GetLibc() })
|
||||||
|
setVariable("INIT_SYSTEM", func() string { return GetInitSystem() })
|
||||||
|
setVariable("LOCAL_IPV4", func() string { return GetLocalIP() })
|
||||||
|
start = time.Now().UnixMilli()
|
||||||
monitors := getMonitorResolution()
|
monitors := getMonitorResolution()
|
||||||
|
end = time.Now().UnixMilli()
|
||||||
|
if showTimeTaken {
|
||||||
|
fmt.Println(fmt.Sprintf("Setting '%s' took %d milliseconds", "MONITOR_*", end-start))
|
||||||
|
}
|
||||||
if len(monitors) != 0 {
|
if len(monitors) != 0 {
|
||||||
env["CONNECTED_MONITORS"] = strconv.Itoa(len(monitors))
|
env["CONNECTED_MONITORS"] = strconv.Itoa(len(monitors))
|
||||||
for i, monitor := range monitors {
|
for i, monitor := range monitors {
|
||||||
env["MONITOR"+strconv.Itoa(i+1)] = monitor
|
env["MONITOR"+strconv.Itoa(i+1)] = monitor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
start = time.Now().UnixMilli()
|
||||||
gpus := getGPUNames()
|
gpus := getGPUNames()
|
||||||
|
end = time.Now().UnixMilli()
|
||||||
|
if showTimeTaken {
|
||||||
|
fmt.Println(fmt.Sprintf("Setting '%s' took %d milliseconds", "GPU_*", end-start))
|
||||||
|
}
|
||||||
if len(gpus) != 0 {
|
if len(gpus) != 0 {
|
||||||
env["CONNECTED_GPUS"] = strconv.Itoa(len(gpus))
|
env["CONNECTED_GPUS"] = strconv.Itoa(len(gpus))
|
||||||
for i, gpu := range gpus {
|
for i, gpu := range gpus {
|
||||||
@@ -217,7 +252,7 @@ func runStormfetch() {
|
|||||||
cmd := exec.Command("/bin/bash", fetchScriptPath)
|
cmd := exec.Command("/bin/bash", fetchScriptPath)
|
||||||
cmd.Dir = path.Dir(fetchScriptPath)
|
cmd.Dir = path.Dir(fetchScriptPath)
|
||||||
cmd.Env = os.Environ()
|
cmd.Env = os.Environ()
|
||||||
cmd.Env = append(cmd.Env, SetupFetchEnv()...)
|
cmd.Env = append(cmd.Env, SetupFetchEnv(TimeTaken)...)
|
||||||
cmd.Env = append(cmd.Env, "C0=\033[0m")
|
cmd.Env = append(cmd.Env, "C0=\033[0m")
|
||||||
for key, value := range colorMap {
|
for key, value := range colorMap {
|
||||||
cmd.Env = append(cmd.Env, fmt.Sprintf("%s=%s", key, value))
|
cmd.Env = append(cmd.Env, fmt.Sprintf("%s=%s", key, value))
|
||||||
|
|||||||
@@ -3,13 +3,13 @@ package main
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/BurntSushi/xgb"
|
"github.com/go-gl/glfw/v3.3/glfw"
|
||||||
"github.com/BurntSushi/xgb/xinerama"
|
|
||||||
"github.com/jackmordaunt/ghw"
|
"github.com/jackmordaunt/ghw"
|
||||||
"github.com/mitchellh/go-ps"
|
"github.com/mitchellh/go-ps"
|
||||||
"github.com/moby/sys/mountinfo"
|
"github.com/moby/sys/mountinfo"
|
||||||
"log"
|
"log"
|
||||||
"math"
|
"math"
|
||||||
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path"
|
"path"
|
||||||
@@ -121,22 +121,17 @@ func getCPUThreads() int {
|
|||||||
|
|
||||||
func getGPUNames() []string {
|
func getGPUNames() []string {
|
||||||
var ret []string
|
var ret []string
|
||||||
null, _ := os.Open(os.DevNull)
|
cmd := exec.Command("/bin/bash", "-c", "lspci -v -m | grep 'VGA' -A6 | grep '^Device:' | sed 's/^Device://' | awk '{$1=$1};1'")
|
||||||
serr := os.Stderr
|
bytes, err := cmd.Output()
|
||||||
os.Stderr = null
|
|
||||||
gpu, err := ghw.GPU()
|
|
||||||
defer null.Close()
|
|
||||||
os.Stderr = serr
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
for i, graphics := range gpu.GraphicsCards {
|
for _, name := range strings.Split(string(bytes), "\n") {
|
||||||
if slices.Contains(config.HiddenGPUS, i+1) {
|
name = strings.TrimSpace(name)
|
||||||
|
if name == "" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if graphics.DeviceInfo != nil {
|
ret = append(ret, name)
|
||||||
ret = append(ret, graphics.DeviceInfo.Product.Name)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
@@ -231,6 +226,8 @@ func GetShell() string {
|
|||||||
return "Zsh " + runCommand("$SHELL --version | awk '{print $2}'")
|
return "Zsh " + runCommand("$SHELL --version | awk '{print $2}'")
|
||||||
case "fish":
|
case "fish":
|
||||||
return "Fish " + runCommand("$SHELL --version | awk '{print $3}'")
|
return "Fish " + runCommand("$SHELL --version | awk '{print $3}'")
|
||||||
|
case "nu":
|
||||||
|
return "Nushell " + runCommand("$SHELL --version")
|
||||||
default:
|
default:
|
||||||
return "Unknown"
|
return "Unknown"
|
||||||
}
|
}
|
||||||
@@ -275,10 +272,18 @@ func GetDEWM() string {
|
|||||||
return "MATE " + runCommand("mate-about --version | awk '{print $4}'")
|
return "MATE " + runCommand("mate-about --version | awk '{print $4}'")
|
||||||
} else if processExists("lxsession") {
|
} else if processExists("lxsession") {
|
||||||
return "LXDE"
|
return "LXDE"
|
||||||
|
} else if processExists("i3") {
|
||||||
|
return "i3 " + runCommand("i3 --version | awk '{print $3}'")
|
||||||
} else if processExists("sway") {
|
} else if processExists("sway") {
|
||||||
|
if runCommand("sway --version | awk '{print $1}'") == "swayfx" {
|
||||||
|
return "SwayFX " + runCommand("sway --version | awk '{print $3}'")
|
||||||
|
} else {
|
||||||
return "Sway " + runCommand("sway --version | awk '{print $3}'")
|
return "Sway " + runCommand("sway --version | awk '{print $3}'")
|
||||||
|
}
|
||||||
} else if processExists("bspwm") {
|
} else if processExists("bspwm") {
|
||||||
return "Bspwm " + runCommand("bspwm -v")
|
return "Bspwm " + runCommand("bspwm -v")
|
||||||
|
} else if processExists("Hyprland") {
|
||||||
|
return "Hyprland " + runCommand("hyprctl version | sed -n 3p | awk '{print $2}' | tr -d 'v,'")
|
||||||
} else if processExists("icewm-session") {
|
} else if processExists("icewm-session") {
|
||||||
return "IceWM " + runCommand("icewm --version | awk '{print $2}'")
|
return "IceWM " + runCommand("icewm --version | awk '{print $2}'")
|
||||||
}
|
}
|
||||||
@@ -297,20 +302,16 @@ func GetDisplayProtocol() string {
|
|||||||
|
|
||||||
func getMonitorResolution() []string {
|
func getMonitorResolution() []string {
|
||||||
var monitors []string
|
var monitors []string
|
||||||
if GetDisplayProtocol() == "X11" {
|
if GetDisplayProtocol() != "" {
|
||||||
conn, err := xgb.NewConn()
|
err := glfw.Init()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
panic(err)
|
||||||
}
|
}
|
||||||
err = xinerama.Init(conn)
|
for _, monitor := range glfw.GetMonitors() {
|
||||||
if err != nil {
|
mode := monitor.GetVideoMode()
|
||||||
return nil
|
monitors = append(monitors, fmt.Sprintf("%dx%d %dHz", mode.Width, mode.Height, mode.RefreshRate))
|
||||||
}
|
|
||||||
reply, _ := xinerama.QueryScreens(conn).Reply()
|
|
||||||
conn.Close()
|
|
||||||
for _, screen := range reply.ScreenInfo {
|
|
||||||
monitors = append(monitors, strconv.Itoa(int(screen.Width))+"x"+strconv.Itoa(int(screen.Height)))
|
|
||||||
}
|
}
|
||||||
|
defer glfw.Terminate()
|
||||||
}
|
}
|
||||||
return monitors
|
return monitors
|
||||||
}
|
}
|
||||||
@@ -394,6 +395,67 @@ func getMountedPartitions() []partition {
|
|||||||
return partitions
|
return partitions
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetInitSystem() string {
|
||||||
|
runCommand := func(command string) string {
|
||||||
|
cmd := exec.Command("/bin/bash", "-c", command)
|
||||||
|
workdir, err := os.Getwd()
|
||||||
|
if err != nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
cmd.Dir = workdir
|
||||||
|
cmd.Env = os.Environ()
|
||||||
|
out, err := cmd.Output()
|
||||||
|
if err != nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return strings.TrimSpace(string(out))
|
||||||
|
}
|
||||||
|
|
||||||
|
link, err := os.Readlink("/sbin/init")
|
||||||
|
if err != nil {
|
||||||
|
return "Unknown"
|
||||||
|
}
|
||||||
|
if path.Base(link) == "systemd" {
|
||||||
|
return "Systemd " + runCommand("systemctl --version | head -1 | awk '{print $2}'")
|
||||||
|
} else if path.Base(link) == "openrc-init" {
|
||||||
|
return "OpenRC " + runCommand("openrc --version | awk '{print $3}'")
|
||||||
|
} else if path.Base(link) == "runit-init" {
|
||||||
|
return "Runit"
|
||||||
|
} else {
|
||||||
|
return "Unknown"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetLibc() string {
|
||||||
|
cmd := exec.Command("/bin/bash", "-c", "find /usr/lib64/ -maxdepth 1 -name 'ld-*' | grep musl")
|
||||||
|
if err := cmd.Run(); err != nil {
|
||||||
|
cmd = exec.Command("/bin/bash", "-c", "ldd --version | head -1 | cut -d' ' -f4")
|
||||||
|
bytes, err := cmd.Output()
|
||||||
|
if err != nil {
|
||||||
|
return "Glibc"
|
||||||
|
}
|
||||||
|
return "Glibc " + strings.TrimSpace(string(bytes))
|
||||||
|
}
|
||||||
|
cmd = exec.Command("/bin/bash", "-c", "ldd 2>&1 | grep 'Version' | cut -d' ' -f2")
|
||||||
|
bytes, err := cmd.Output()
|
||||||
|
if err != nil {
|
||||||
|
return "Musl"
|
||||||
|
}
|
||||||
|
return "Musl " + strings.TrimSpace(string(bytes))
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetLocalIP() string {
|
||||||
|
conn, err := net.Dial("udp", "8.8.8.8:80")
|
||||||
|
if err != nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
defer conn.Close()
|
||||||
|
|
||||||
|
localAddr := conn.LocalAddr().(*net.UDPAddr)
|
||||||
|
|
||||||
|
return localAddr.IP.String()
|
||||||
|
}
|
||||||
|
|
||||||
func FormatBytes(bytes uint64) string {
|
func FormatBytes(bytes uint64) string {
|
||||||
var suffixes [6]string
|
var suffixes [6]string
|
||||||
suffixes[0] = "B"
|
suffixes[0] = "B"
|
||||||
|
|||||||
Reference in New Issue
Block a user