mirror of
https://github.com/EnumeratedDev/stormfetch.git
synced 2026-09-16 16:06:11 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
75deb165ad | ||
|
|
56511c90db | ||
|
|
42a60296a9 | ||
|
|
af4c534685 | ||
|
|
25a596cd5e | ||
|
|
4d414daccc | ||
|
|
664b639fb9 | ||
|
|
2b33b64602 | ||
|
|
200e300be0 | ||
|
|
139e64d682 | ||
|
|
0608d1b84b | ||
|
|
325d6bff13 |
+3
-1
@@ -1,2 +1,4 @@
|
||||
.idea
|
||||
build
|
||||
build
|
||||
stormfetch
|
||||
stormfetch.tar.gz
|
||||
@@ -7,10 +7,13 @@ endif
|
||||
ifeq ($(SYSCONFDIR),)
|
||||
SYSCONFDIR := $(PREFIX)/etc
|
||||
endif
|
||||
ifeq ($(GO),)
|
||||
GO := /usr/bin/go
|
||||
endif
|
||||
|
||||
build:
|
||||
mkdir -p build
|
||||
go build -o build/stormfetch stormfetch
|
||||
$(GO) build -o build/stormfetch stormfetch
|
||||
|
||||
install: build/stormfetch config/
|
||||
mkdir -p $(DESTDIR)$(BINDIR)
|
||||
@@ -18,5 +21,13 @@ install: build/stormfetch config/
|
||||
cp build/stormfetch $(DESTDIR)$(BINDIR)/stormfetch
|
||||
cp -r config/. $(DESTDIR)$(SYSCONFDIR)/stormfetch/
|
||||
|
||||
compress: build/stormfetch config/
|
||||
mkdir -p stormfetch/$(BINDIR)
|
||||
mkdir -p stormfetch/$(SYSCONFDIR)/stormfetch/
|
||||
cp build/stormfetch stormfetch/$(BINDIR)/stormfetch
|
||||
cp -r config/. stormfetch/$(SYSCONFDIR)/stormfetch/
|
||||
tar --owner=root --group=root -czf stormfetch.tar.gz stormfetch
|
||||
rm -r stormfetch
|
||||
|
||||
clean:
|
||||
rm -r build/
|
||||
@@ -6,12 +6,17 @@
|
||||
- [CapCreeperGR ](https://gitlab.com/CapCreeperGR)
|
||||
|
||||
### Project Information
|
||||
Stormfetch is a program that can read your system's information and display it in the terminal along with ascii art of the linux distribution you are running.
|
||||
Stormfetch is still in beta and 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
|
||||
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.
|
||||
|
||||
### Installation Guide
|
||||
#### AUR
|
||||
- If you are on Arch Linux, you can use your favorite AUR manager to install the `stormfetch` package.
|
||||
#### Building from source
|
||||
- Download `go` from your package manager or from the go website
|
||||
- Download `make` from your package manager
|
||||
- (Optional) Download `xorg-xhost` from your package manager to display DE/WM and monitor information
|
||||
- (Optional) Download `xorg-xdpyinfo` from your package manager to display screen resolution
|
||||
- (Optional) Download `lshw` from your package manager to display GPU information
|
||||
- Run the following command to compile the project
|
||||
```
|
||||
|
||||
+5
-4
@@ -1,4 +1,5 @@
|
||||
-`
|
||||
#/4;27;4;11
|
||||
${C1} -`
|
||||
.o+`
|
||||
`ooo/
|
||||
`+oooo:
|
||||
@@ -7,9 +8,9 @@
|
||||
`/:-:++oooo+:
|
||||
`/++++/+++++++:
|
||||
`/++++++++++++++:
|
||||
`/+++ooooooooooooo/`
|
||||
./ooosssso++osssssso+`
|
||||
.oossssso-````/ossssss+`
|
||||
`/+++o${C2}oooooooo${C1}oooo/`
|
||||
${C2} ${C1}./${C2}ooosssso++osssssso${C1}+`
|
||||
${C2} .oossssso-````/ossssss+`
|
||||
-osssssso. :ssssssso.
|
||||
:osssssss/ osssso+++.
|
||||
/ossssssss/ +ssssooo/-
|
||||
|
||||
+17
-16
@@ -1,16 +1,17 @@
|
||||
_,met$$$$$gg.
|
||||
,g$$$$$$$$$$$$$$$P.
|
||||
,g$$P" """Y$$.".
|
||||
,$$P' `$$$.
|
||||
',$$P ,ggs. `$$b:
|
||||
`d$$' ,$P"' . $$$
|
||||
$$P d$' , $$P
|
||||
$$: $$. - ,d$$'
|
||||
$$; Y$b._ _,d$P'
|
||||
Y$$. `.`"Y$$$$P"'
|
||||
`$$b "-.__
|
||||
`Y$$
|
||||
`Y$$.
|
||||
`$$b.
|
||||
`Y$$b.
|
||||
`"Y$b._
|
||||
#/1;7;9;15
|
||||
${C2} _,met&&&&&gg.
|
||||
,g&&&&&&&&&&&&&&&P.
|
||||
,g&&P" """Y&&.".
|
||||
,&&P' `&&&.
|
||||
',&&P ,ggs. `&&b:
|
||||
`d&&' ,&P"' ${C1}.${C2} &&&
|
||||
&&P d&' ${C1},${C2} &&P
|
||||
&&: &&. ${C1}-${C2} ,d&&'
|
||||
&&; Y&b._ _,d&P'
|
||||
Y&&. ${C1}`.${C2}`"Y&&&&P"'
|
||||
${C2} `&&b ${C1}"-.__
|
||||
${C2} `Y&&
|
||||
`Y&&.
|
||||
`&&b.
|
||||
`Y&&b.
|
||||
`"Y&b._
|
||||
|
||||
+14
-13
@@ -1,19 +1,20 @@
|
||||
.',;::::;,'.
|
||||
#/12;7;4;15
|
||||
${C1} .',;::::;,'.
|
||||
.';:cccccccccccc:;,.
|
||||
.;cccccccccccccccccccccc;.
|
||||
.:cccccccccccccccccccccccccc:.
|
||||
.;ccccccccccccc;.:dddl:.;ccccccc;.
|
||||
.:ccccccccccccc;OWMKOOXMWd;ccccccc:.
|
||||
.:ccccccccccccc;KMMc;cc;xMMc;ccccccc:.
|
||||
,cccccccccccccc;MMM.;cc;;WW:;cccccccc,
|
||||
:cccccccccccccc;MMM.;cccccccccccccccc:
|
||||
:ccccccc;oxOOOo;MMM0OOk.;cccccccccccc:
|
||||
cccccc;0MMKxdd:;MMMkddc.;cccccccccccc;
|
||||
ccccc;XM0';cccc;MMM.;cccccccccccccccc'
|
||||
ccccc;MMo;ccccc;MMW.;ccccccccccccccc;
|
||||
ccccc;0MNc.ccc.xMMd;ccccccccccccccc;
|
||||
cccccc;dNMWXXXWM0:;cccccccccccccc:,
|
||||
cccccccc;.:odl:.;cccccccccccccc:,.
|
||||
.;ccccccccccccc;${C2}.:dddl:.${C1};ccccccc;.
|
||||
.:ccccccccccccc;${C2}OWMKOOXMWd${C1};ccccccc:.
|
||||
.:ccccccccccccc;${C2}KMMc${C1};cc;${C2}xMMc${C1};ccccccc:.
|
||||
,cccccccccccccc;${C2}MMM.${C1};cc;${C2};WW:${C1};cccccccc,
|
||||
:cccccccccccccc;${C2}MMM.${C1};cccccccccccccccc:
|
||||
:ccccccc;${C2}oxOOOo${C1};${C2}MMM0OOk.${C1};cccccccccccc:
|
||||
cccccc;${C2}0MMKxdd:${C1};${C2}MMMkddc.${C1};cccccccccccc;
|
||||
ccccc;${C2}XM0'${C1};cccc;${C2}MMM.${C1};cccccccccccccccc'
|
||||
ccccc;${C2}MMo${C1};ccccc;${C2}MMW.${C1};ccccccccccccccc;
|
||||
ccccc;${C2}0MNc.${C1}ccc${C2}.xMMd${C1};ccccccccccccccc;
|
||||
cccccc;${C2}dNMWXXXWM0:${C1};cccccccccccccc:,
|
||||
cccccccc;${C2}.:odl:.${C1};cccccccccccccc:,.
|
||||
:cccccccccccccccccccccccccccc:'.
|
||||
.:cccccccccccccccccccccc:;,..
|
||||
'::cccccccccccccc::;,.
|
||||
|
||||
+18
-17
@@ -1,18 +1,19 @@
|
||||
-/oyddmdhs+:.
|
||||
-odNMMMMMMMMNNmhy+-`
|
||||
-yNMMMMMMMMMMMNNNmmdhy+-
|
||||
`omMMMMMMMMMMMMNmdmmmmddhhy/`
|
||||
omMMMMMMMMMMMNhhyyyohmdddhhhdo`
|
||||
.ydMMMMMMMMMMdhs++so/smdddhhhhdm+`
|
||||
oyhdmNMMMMMMMNdyooydmddddhhhhyhNd.
|
||||
:oyhhdNNMMMMMMMNNNmmdddhhhhhyymMh
|
||||
.:+sydNMMMMMNNNmmmdddhhhhhhmMmy
|
||||
/mMMMMMMNNNmmmdddhhhhhmMNhs:
|
||||
`oNMMMMMMMNNNmmmddddhhdmMNhs+`
|
||||
`sNMMMMMMMMNNNmmmdddddmNMmhs/.
|
||||
/NMMMMMMMMNNNNmmmdddmNMNdso:`
|
||||
+MMMMMMMNNNNNmmmmdmNMNdso/-
|
||||
yMMNNNNNNNmmmmmNNMmhs+/-`
|
||||
/hMMNNNNNNNNMNdhs++/-`
|
||||
`/ohdmmddhys+++/:.`
|
||||
#/5;7;13;69
|
||||
${C1} -/oyddmdhs+:.
|
||||
-o${C2}dNMMMMMMMMNNmhy+${C1}-`
|
||||
-y${C2}NMMMMMMMMMMMNNNmmdhy${C1}+-
|
||||
`o${C2}mMMMMMMMMMMMMNmdmmmmddhhy${C1}/`
|
||||
om${C2}MMMMMMMMMMMN${C1}hhyyyo${C2}hmdddhhhd${C1}o`
|
||||
.y${C2}dMMMMMMMMMMd${C1}hs++so/s${C2}mdddhhhhdm${C1}+`
|
||||
oy${C2}hdmNMMMMMMMN${C1}dyooy${C2}dmddddhhhhyhN${C1}d.
|
||||
:o${C2}yhhdNNMMMMMMMNNNmmdddhhhhhyym${C1}Mh
|
||||
.:${C2}+sydNMMMMMNNNmmmdddhhhhhhmM${C1}my
|
||||
/m${C2}MMMMMMNNNmmmdddhhhhhmMNh${C1}s:
|
||||
`o${C2}NMMMMMMMNNNmmmddddhhdmMNhs${C1}+`
|
||||
`s${C2}NMMMMMMMMNNNmmmdddddmNMmhs${C1}/.
|
||||
/N${C2}MMMMMMMMNNNNmmmdddmNMNdso${C1}:`
|
||||
+M${C2}MMMMMMNNNNNmmmmdmNMNdso${C1}/-
|
||||
yM${C2}MNNNNNNNmmmmmNNMmhs+/${C1}-`
|
||||
/h${C2}MMNNNNNNNNMNdhs++/${C1}-`
|
||||
`/${C2}ohdmmddhys+++/:${C1}.`
|
||||
`-//////:--.
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#/2;7;10;15
|
||||
${C2} .;ldkO0000Okdl;.
|
||||
.;d00xl:^''''''^:ok00d;.
|
||||
.d00l' 'o00d.
|
||||
.d0Kd'${C1} Okxol:;,. ${C2}:O0d.
|
||||
.OK${C1}KKK0kOKKKKKKKKKKOxo:, ${C2}lKO.
|
||||
,0K${C1}KKKKKKKKKKKKKKK0P^${C2},,,${C1}^dx:${C2} ;00,
|
||||
.OK${C1}KKKKKKKKKKKKKKKk'${C2}.oOPPb.${C1}'0k.${C2} cKO.
|
||||
:KK${C1}KKKKKKKKKKKKKKK: ${C2}kKx..dd ${C1}lKd${C2} 'OK:
|
||||
dKK${C1}KKKKKKKKKOx0KKKd ${C2}^0KKKO' ${C1}kKKc${C2} dKd
|
||||
dKK${C1}KKKKKKKKKK;.;oOKx,..${C2}^${C1}..;kKKK0.${C2} dKd
|
||||
:KK${C1}KKKKKKKKKK0o;...^cdxxOK0O/^^' ${C2}.0K:
|
||||
kKK${C1}KKKKKKKKKKKKK0x;,,......,;od ${C2}lKk
|
||||
'0K${C1}KKKKKKKKKKKKKKKKKKKK00KKOo^ ${C2}c00'
|
||||
'kK${C1}KKOxddxkOO00000Okxoc;'' ${C2}.dKk'
|
||||
l0Ko. .c00l'
|
||||
'l0Kk:. .;xK0l'
|
||||
'lkK0xl:;,,,,;:ldO0kl'
|
||||
'^:ldxkkkkxdl:^'
|
||||
@@ -0,0 +1,14 @@
|
||||
#/2;7;10;15
|
||||
${C1} ......
|
||||
.,cdxxxoc,. .:kKMMMNWMMMNk:.
|
||||
cKMMN0OOOKWMMXo. ; ;0MWk:. .:OMMk.
|
||||
;WMK;. .lKMMNM, :NMK, .OMW;
|
||||
cMW; 'WMMMN ,XMK, oMM'
|
||||
.MMc ..;l. xMN: KM0
|
||||
'MM. 'NMO oMM
|
||||
.MM, .kMMl xMN
|
||||
KM0 .kMM0. .dl:,.. .WMd
|
||||
.XM0. ,OMMK, OMMMK. .XMK
|
||||
oWMO:. .;xNMMk, NNNMKl. .xWMx
|
||||
:ONMMNXMMMKx; . ,xNMWKkxllox0NMWk,
|
||||
..... .:dOOXXKOxl,
|
||||
@@ -0,0 +1,18 @@
|
||||
#/6;10;5;12
|
||||
${C1} @@@@@@@@@
|
||||
@@@~~~~~~~~~@@
|
||||
@@~~~ ~~@
|
||||
@~~ @
|
||||
@~ @@@ @
|
||||
@@~ @ @@
|
||||
@@~~ @
|
||||
@@@~~ ~@@ @@@
|
||||
~~~ ~~@@@ @@@@~~~
|
||||
~~~@@@@~~~~
|
||||
@@@@ @@@@@@@ ~~~~ @@@@
|
||||
~~~~@@@@ @@~~~~~~~@@ @@@@
|
||||
~~~~@@@@~~ ~~@@@@~~~~
|
||||
@@@ ~~~~ @@@@@ ~~~~ @@@
|
||||
~~~@@@@ @@@@~~~~~@@@@ @@@@~~~
|
||||
~~~~@@@~~~~ ~~~~@@@~~~
|
||||
~~~ ~~~
|
||||
@@ -0,0 +1,21 @@
|
||||
#/1;7;3;15
|
||||
${C1} .-/+oossssoo+\-.
|
||||
´:+ssssssssssssssssss+:`
|
||||
-+ssssssssssssssssssyyssss+-
|
||||
.ossssssssssssssssss${C2}dMMMNy${C1}sssso.
|
||||
/sssssssssss${C2}hdmmNNmmyNMMMMh${C1}ssssss\
|
||||
+sssssssss${C2}hm${C1}yd${C2}MMMMMMMNddddy${C1}ssssssss+
|
||||
/ssssssss${C2}hNMMM${C1}yh${C2}hyyyyhmNMMMNh${C1}ssssssss\
|
||||
.ssssssss${C2}dMMMNh${C1}ssssssssss${C2}hNMMMd${C1}ssssssss.
|
||||
+ssss${C2}hhhyNMMNy${C1}ssssssssssss${C2}yNMMMy${C1}sssssss+
|
||||
oss${C2}yNMMMNyMMh${C1}ssssssssssssss${C2}hmmmh${C1}ssssssso
|
||||
oss${C2}yNMMMNyMMh${C1}sssssssssssssshmmmh${C1}ssssssso
|
||||
+ssss${C2}hhhyNMMNy${C1}ssssssssssss${C2}yNMMMy${C1}sssssss+
|
||||
.ssssssss${C2}dMMMNh${C1}ssssssssss${C2}hNMMMd${C1}ssssssss.
|
||||
\ssssssss${C2}hNMMM${C1}yh${C2}hyyyyhdNMMMNh${C1}ssssssss/
|
||||
+sssssssss${C2}dm${C1}yd${C2}MMMMMMMMddddy${C1}ssssssss+
|
||||
\sssssssssss${C2}hdmNNNNmyNMMMMh${C1}ssssss/
|
||||
.ossssssssssssssssss${C2}dMMMNy${C1}sssso.
|
||||
-+sssssssssssssssss${C2}yyy${C1}ssss+-
|
||||
`:+ssssssssssssssssss+:`
|
||||
.-\+oossssoo+/-.
|
||||
@@ -1,2 +1,5 @@
|
||||
distro_ascii: auto
|
||||
fetch_script: auto
|
||||
ansii_colors: []
|
||||
force_config_ansii: false
|
||||
dependency_warning: true
|
||||
|
||||
+14
-10
@@ -1,17 +1,21 @@
|
||||
source fetch_script_functions.sh
|
||||
|
||||
echo "Distribution: ${DISTRO_LONG_NAME} ($(uname -m))"
|
||||
echo "Hostname: $(cat /etc/hostname)"
|
||||
echo "Kernel: $(uname -s) $(uname -r)"
|
||||
echo "Packages: $(get_packages)"
|
||||
echo "Shell: $(get_shell)"
|
||||
echo "CPU: $(get_cpu_name) ($(nproc) threads)"
|
||||
echo -e "${C3}Distribution: ${C4}${DISTRO_LONG_NAME} ($(uname -m))"
|
||||
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}$(get_shell)"
|
||||
echo -e "${C3}CPU: ${C4}$(get_cpu_name) ($(nproc) threads)"
|
||||
if command_exists lshw; then
|
||||
echo "GPU: $(lshw -class display 2> /dev/null | grep 'product' | cut -d":" -f2 | xargs)"
|
||||
echo -e "${C3}GPU: ${C4}$(lshw -class display 2> /dev/null | grep 'product' | cut -d":" -f2 | xargs)"
|
||||
fi
|
||||
echo "Memory: $(get_used_mem) MiB / $(get_total_mem) MiB"
|
||||
echo -e "${C3}Memory: ${C4}$(get_used_mem) MiB / $(get_total_mem) MiB"
|
||||
if xhost >& /dev/null ; then
|
||||
echo "DE/WM: $(get_de_wm)"
|
||||
echo "Screen Resolution: $(get_screen_resolution)"
|
||||
if get_de_wm &> /dev/null; then
|
||||
echo -e "${C3}DE/WM: ${C4}$(get_de_wm)"
|
||||
fi
|
||||
if command_exists xdpyinfo ; then
|
||||
echo -e "${C3}Screen Resolution: ${C4}$(get_screen_resolution)"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
@@ -23,10 +23,10 @@ get_shell() {
|
||||
*)
|
||||
SHELL_NAME=${SHELL##*/}
|
||||
SHELL_VERSION="$($SHELL --version)"
|
||||
SHELL_VERSION=$(SHELL_VERSION//,//)
|
||||
SHELL_VERSION=$(SHELL_VERSION// //)
|
||||
SHELL_VERSION=$(SHELL_VERSION//VERSION//)
|
||||
SHELL_VERSION=$(SHELL_VERSION//"$SHELL_NAME"//)
|
||||
SHELL_VERSION=${SHELL_VERSION//","}
|
||||
SHELL_VERSION=${SHELL_VERSION//" "}
|
||||
SHELL_VERSION=${SHELL_VERSION//"version"}
|
||||
SHELL_VERSION=${SHELL_VERSION//"$SHELL_NAME"}
|
||||
echo "$SHELL_NAME $SHELL_VERSION"
|
||||
unset SHELL_NAME
|
||||
unset SHELL_VERSION
|
||||
@@ -51,16 +51,32 @@ get_used_mem() {
|
||||
}
|
||||
|
||||
get_de_wm() {
|
||||
if [[ $DESKTOP_SESSION == "plasma" ]]; then
|
||||
echo "KDE Plasma $(plasmashell --version | sed 's/plasmashell //g')"
|
||||
if ps -e | grep "plasmashell" &> /dev/null ; then
|
||||
echo "KDE Plasma $(plasmashell --version | awk '{print $2}')"
|
||||
elif ps -e | grep "gnome-session" &> /dev/null ; then
|
||||
echo "Gnome $(gnome-shell --version | awk '{print $3}')"
|
||||
elif ps -e | grep "xfce4-session" &> /dev/null ; then
|
||||
echo "XFCE $(xfce4-session --version | grep xfce4-session | awk '{print $2}')"
|
||||
elif ps -e | grep "cinnamon" &> /dev/null ; then
|
||||
echo "Cinnamon $(cinnamon --version | awk '{print $2}')"
|
||||
elif ps -e | grep "mate-panel" &> /dev/null ; then
|
||||
echo "Mate $(mate-about --version | awk '{print $4}')"
|
||||
elif ps -e | grep "lxsession" &> /dev/null ; then
|
||||
echo "LXDE"
|
||||
elif ps -e | grep "sway" &> /dev/null ; then
|
||||
echo "Sway $(sway --version | awk '{print $2}')"
|
||||
elif ps -e | grep "icewm-session" &> /dev/null ; then
|
||||
echo "IceWM $(icewm --version | awk '{print $2}' | sed 's/,//g')"
|
||||
elif [ ! -z $DESKTOP_SESSION ]; then
|
||||
echo "$DESKTOP_SESSION"
|
||||
else
|
||||
echo "$DESKTOP_SESSION"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
get_screen_resolution() {
|
||||
if xhost >& /dev/null ;then
|
||||
xdpyinfo | grep dimensions | tr -s ' ' | cut -d " " -f3
|
||||
if xhost >& /dev/null && command_exists xdpyinfo; then
|
||||
xdpyinfo | grep dimensions | tr -s ' ' | cut -d " " -f3
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@@ -7,17 +7,28 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var configPath = ""
|
||||
var fetchScriptPath = ""
|
||||
|
||||
var config = StormfetchConfig{}
|
||||
var config = StormfetchConfig{
|
||||
Ascii: "auto",
|
||||
FetchScript: "auto",
|
||||
AnsiiColors: make([]int, 0),
|
||||
ForceConfigAnsii: false,
|
||||
DependencyWarning: true,
|
||||
}
|
||||
|
||||
type StormfetchConfig struct {
|
||||
Ascii string `yaml:"distro_ascii"`
|
||||
FetchScript string `yaml:"fetch_script"`
|
||||
Ascii string `yaml:"distro_ascii"`
|
||||
FetchScript string `yaml:"fetch_script"`
|
||||
AnsiiColors []int `yaml:"ansii_colors"`
|
||||
ForceConfigAnsii bool `yaml:"force_config_ansii"`
|
||||
DependencyWarning bool `yaml:"dependency_warning"`
|
||||
}
|
||||
|
||||
type DistroInfo struct {
|
||||
@@ -67,10 +78,73 @@ func readConfig() {
|
||||
} else {
|
||||
log.Fatalf("Fetch script file not found: %s", err.Error())
|
||||
}
|
||||
// Show Dependency warning if enabled
|
||||
if config.DependencyWarning {
|
||||
dependencies := []string{"lshw", "xhost", "xdpyinfo"}
|
||||
var missing []string
|
||||
for _, depend := range dependencies {
|
||||
if _, err := os.Stat(path.Join("/usr/bin/", depend)); err != nil {
|
||||
missing = append(missing, depend)
|
||||
}
|
||||
}
|
||||
if len(missing) != 0 {
|
||||
fmt.Println("[WARNING] Stormfetch functionality may be limited due to the following dependencies not being installed:")
|
||||
for _, depend := range missing {
|
||||
fmt.Println(depend)
|
||||
}
|
||||
fmt.Println("You can disable this warning through your stormfetch config")
|
||||
}
|
||||
}
|
||||
// Fetch ascii art and apply colors
|
||||
colorMap := make(map[string]string)
|
||||
colorMap["C0"] = "\033[0m"
|
||||
setColorMap := func() {
|
||||
for i := 0; i < 6; i++ {
|
||||
if i > len(config.AnsiiColors)-1 {
|
||||
colorMap["C"+strconv.Itoa(i+1)] = "\033[0m"
|
||||
continue
|
||||
}
|
||||
colorMap["C"+strconv.Itoa(i+1)] = fmt.Sprintf("\033[1m\033[38;5;%dm", config.AnsiiColors[i])
|
||||
}
|
||||
}
|
||||
setColorMap()
|
||||
ascii := ""
|
||||
if strings.HasPrefix(getDistroAsciiArt(), "#/") {
|
||||
firstLine := strings.Split(getDistroAsciiArt(), "\n")[0]
|
||||
if !config.ForceConfigAnsii {
|
||||
ansiiColors := strings.Split(strings.TrimPrefix(firstLine, "#/"), ";")
|
||||
for i, color := range ansiiColors {
|
||||
atoi, err := strconv.Atoi(color)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if i < len(config.AnsiiColors) {
|
||||
config.AnsiiColors[i] = atoi
|
||||
} else {
|
||||
config.AnsiiColors = append(config.AnsiiColors, atoi)
|
||||
}
|
||||
}
|
||||
setColorMap()
|
||||
}
|
||||
ascii = os.Expand(getDistroAsciiArt(), func(s string) string {
|
||||
return colorMap[s]
|
||||
})
|
||||
ascii = strings.TrimPrefix(ascii, firstLine+"\n")
|
||||
} else {
|
||||
ascii = os.Expand(getDistroAsciiArt(), func(s string) string {
|
||||
return colorMap[s]
|
||||
})
|
||||
}
|
||||
asciiSplit := strings.Split(ascii, "\n")
|
||||
asciiNoColor := stripAnsii(ascii)
|
||||
//Execute fetch script
|
||||
cmd := exec.Command("/bin/bash", fetchScriptPath)
|
||||
cmd.Dir = path.Dir(fetchScriptPath)
|
||||
cmd.Env = os.Environ()
|
||||
cmd.Env = append(cmd.Env, "C0=\033[0m")
|
||||
for key, value := range colorMap {
|
||||
cmd.Env = append(cmd.Env, fmt.Sprintf("%s=%s", key, value))
|
||||
}
|
||||
cmd.Env = append(cmd.Env, "DISTRO_LONG_NAME="+getDistroInfo().LongName)
|
||||
cmd.Env = append(cmd.Env, "DISTRO_SHORT_NAME="+getDistroInfo().ShortName)
|
||||
out, err := cmd.Output()
|
||||
@@ -78,22 +152,34 @@ func readConfig() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
// Print Distro Information
|
||||
ascii := getDistroAscii()
|
||||
maxWidth := 0
|
||||
for _, line := range strings.Split(ascii, "\n") {
|
||||
for _, line := range strings.Split(asciiNoColor, "\n") {
|
||||
if len(line) > maxWidth {
|
||||
maxWidth = len(line)
|
||||
}
|
||||
}
|
||||
for lineIndex, line := range strings.Split(ascii, "\n") {
|
||||
for i := len(line); i < maxWidth+5; i++ {
|
||||
final := ""
|
||||
for lineIndex, line := range asciiSplit {
|
||||
lineVisibleLength := len(strings.Split(asciiNoColor, "\n")[lineIndex])
|
||||
lastAsciiColor := ""
|
||||
if lineIndex != 0 {
|
||||
r := regexp.MustCompile("\033[38;5;[0-9]+m")
|
||||
matches := r.FindAllString(asciiSplit[lineIndex-1], -1)
|
||||
if len(matches) != 0 {
|
||||
lastAsciiColor = r.FindAllString(asciiSplit[lineIndex-1], -1)[len(matches)-1]
|
||||
}
|
||||
}
|
||||
for i := lineVisibleLength; i < maxWidth+5; i++ {
|
||||
line = line + " "
|
||||
}
|
||||
if lineIndex < len(strings.Split(string(out), "\n")) {
|
||||
line = line + strings.Split(string(out), "\n")[lineIndex]
|
||||
asciiSplit[lineIndex] = lastAsciiColor + line
|
||||
str := string(out)
|
||||
if lineIndex < len(strings.Split(str, "\n")) {
|
||||
line = line + colorMap["C0"] + strings.Split(str, "\n")[lineIndex]
|
||||
}
|
||||
fmt.Println(line)
|
||||
final += lastAsciiColor + line + "\n"
|
||||
}
|
||||
fmt.Println(final)
|
||||
}
|
||||
|
||||
func readKeyValueFile(filepath string) (map[string]string, error) {
|
||||
@@ -158,7 +244,7 @@ func getDistroInfo() DistroInfo {
|
||||
}
|
||||
}
|
||||
|
||||
func getDistroAscii() string {
|
||||
func getDistroAsciiArt() string {
|
||||
defaultAscii :=
|
||||
` .--.
|
||||
|o_o |
|
||||
@@ -201,3 +287,9 @@ func getDistroAscii() string {
|
||||
return defaultAscii
|
||||
}
|
||||
}
|
||||
|
||||
func stripAnsii(str string) string {
|
||||
const ansi = "[\u001B\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\u0007)|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"
|
||||
var re = regexp.MustCompile(ansi)
|
||||
return re.ReplaceAllString(str, "")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user