Initial commit
This commit is contained in:
parent
6648e9716f
commit
f50caf66be
37
Makefile
Normal file
37
Makefile
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
include options.mk
|
||||||
|
|
||||||
|
help:
|
||||||
|
@echo "make install Install ${NAME}."
|
||||||
|
@echo "make uninstall Uninstall ${NAME}."
|
||||||
|
@echo "make clean: Remove tarballs."
|
||||||
|
@echo "make dist Create distro package for ${NAME}."
|
||||||
|
@echo "make pkg_arch Create Arch package ${NAME}."
|
||||||
|
|
||||||
|
install: clean
|
||||||
|
cp ${NAME} ${PREFIX}${DESTDIR}/bin
|
||||||
|
chmod +x ${PREFIX}${DESTDIR}/bin/${NAME}
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
rm -rf ~/.config/${NAME}
|
||||||
|
rm -f ${PREFIX}${DESTDIR}/bin/${NAME}
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *.tar* *zst* *${NAME}-${VER}.PKGBUILD
|
||||||
|
|
||||||
|
dist: clean
|
||||||
|
mkdir -p ${NAME}-${VER}
|
||||||
|
cp ${NAME} README.md LICENSE Makefile *.mk ${NAME}-${VER}
|
||||||
|
[ -f "PKGBUILD" ] && cp -f PKGBUILD ${NAME}-${VER} || :
|
||||||
|
tar -cf ${NAME}-${VER}.tar ${NAME}-${VER}
|
||||||
|
gzip ${NAME}-${VER}.tar
|
||||||
|
rm -rf ${NAME}-${VER}.tar ${NAME}-${VER}
|
||||||
|
gpg --detach-sign --yes --local-user $$(whoami) ${NAME}-${VER}.tar.gz || :
|
||||||
|
|
||||||
|
pkg_arch: dist
|
||||||
|
command -v makepkg > /dev/null || exit 1
|
||||||
|
[ -f PKGBUILD ] || exit 1
|
||||||
|
cp -f PKGBUILD PKGBUILD.orig
|
||||||
|
sed -i "s/VERSION/${VER}/g; s/MD5SUM/$$(md5sum *.tar.gz | cut -d ' ' -f 1)/g" PKGBUILD
|
||||||
|
makepkg -sfr --sign || exit 1
|
||||||
|
rm -rf src/ pkg/
|
||||||
|
cp PKGBUILD ${NAME}-${VER}.PKGBUILD; mv PKGBUILD.orig PKGBUILD
|
36
PKGBUILD
Normal file
36
PKGBUILD
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
pkgname=neosfetch
|
||||||
|
pkgver=VERSION
|
||||||
|
pkgrel=1
|
||||||
|
epoch=
|
||||||
|
pkgdesc="Minimal user-centric fetch script, successor to sfetch"
|
||||||
|
arch=(x86_64)
|
||||||
|
url="https://git.speedie.site/speedie/neosfetch"
|
||||||
|
license=('GPL')
|
||||||
|
groups=()
|
||||||
|
|
||||||
|
depends=(
|
||||||
|
binutils
|
||||||
|
)
|
||||||
|
|
||||||
|
makedepends=()
|
||||||
|
checkdepends=()
|
||||||
|
optdepends=()
|
||||||
|
provides=(neosfetch nsfetch)
|
||||||
|
conflicts=()
|
||||||
|
replaces=()
|
||||||
|
backup=()
|
||||||
|
options=()
|
||||||
|
install=
|
||||||
|
changelog=
|
||||||
|
source=(
|
||||||
|
"$pkgname-$pkgver.tar.gz"
|
||||||
|
#"https://ls.speedie.gq/releases/$pkgname/$pkgname-$pkgver.tar.gz"
|
||||||
|
)
|
||||||
|
noextract=()
|
||||||
|
md5sums=(MD5SUM)
|
||||||
|
validpgpkeys=()
|
||||||
|
|
||||||
|
package() {
|
||||||
|
cd "$pkgname-$pkgver"
|
||||||
|
install -Dm755 ${pkgname} "${pkgdir}"/usr/bin/${pkgname}
|
||||||
|
}
|
19
README.md
19
README.md
|
@ -1,3 +1,20 @@
|
||||||
# neosfetch
|
# neosfetch
|
||||||
|
|
||||||
Minimal user-centric fetch script, successor to sfetch
|
Minimal user-centric fetch script, successor to sfetch
|
||||||
|
|
||||||
|
# License
|
||||||
|
|
||||||
|
Copyright (C) 2023 speedie
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
130
nsfetch
Executable file
130
nsfetch
Executable file
|
@ -0,0 +1,130 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# neosfetch
|
||||||
|
# Minimal user-centric fetch script
|
||||||
|
#
|
||||||
|
# Copyright (C) 2023 speedie
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
NSFETCH_CONFIG="${NSFETCH_CONFIG:-${XDG_CONFIG_HOME:-${HOME}/.config}/nsfetch/nsfetchrc}"
|
||||||
|
NSFETCH_V="${NSFETCH_V:-0.1}"
|
||||||
|
|
||||||
|
d_user() { printf "%s" "$(whoami)"; }
|
||||||
|
d_hostname() { [ -f "${ETC_DIR}/hostname" ] && cat /etc/hostname; }
|
||||||
|
d_tram() { printf "%d" "$(($(grep MemTotal /proc/meminfo | awk '{ print $2 }') / ${MEMDIV:-1024}))"; }
|
||||||
|
d_fram() { printf "%d" "$(($(grep MemFree /proc/meminfo | awk '{ print $2 }') / ${MEMDIV:-1024}))"; }
|
||||||
|
d_uram() { printf "%d" "$(($(d_tram) - $(d_fram)))"; }
|
||||||
|
d_kernel() { uname -s; }
|
||||||
|
d_kernelv() { uname -r; }
|
||||||
|
d_cpu_model() { lscpu | sed -nr '/Model name/ s/.*:\s*(.*) @ .*/\1/p'; }
|
||||||
|
d_cores() { printf "%d" "$(($(grep -c "cores" /proc/cpuinfo) / 2))"; }
|
||||||
|
d_threads() { grep -c "cores" /proc/cpuinfo; }
|
||||||
|
rc() {
|
||||||
|
mkdir -p "$(dirname "${NSFETCH_CONFIG}")"
|
||||||
|
[ ! -f "${NSFETCH_CONFIG}" ] && cat << EOF > "${NSFETCH_CONFIG}"
|
||||||
|
# neosfetch default configuration file
|
||||||
|
# See https://git.speedie.site/speedie/neosfetch for more information.
|
||||||
|
|
||||||
|
ETC_DIR="\${ETC_DIR:-/etc}" # Path to your /etc directory
|
||||||
|
MEMDIV="1024" # Number to divide RAM count in KB with
|
||||||
|
|
||||||
|
ns_pf() {
|
||||||
|
p "\$(d_user)@\$(d_hostname)"
|
||||||
|
p "RAM: \$(d_tram) MiB"
|
||||||
|
p "CPU: \$(d_cpu_model)"
|
||||||
|
p "KERNEL: \$(d_kernel)"
|
||||||
|
a
|
||||||
|
}
|
||||||
|
|
||||||
|
d_pkgc() {
|
||||||
|
case "\$dist" in
|
||||||
|
"arch") pkgc="\$(pacman -Q | grep -c "")" ;;
|
||||||
|
"debian") pkgc="\$(dpkg --get-selections | grep -c "")" ;;
|
||||||
|
"void") pkgc="\$(xbps-query -s | grep -c "")" ;;
|
||||||
|
gentoo|funtoo) pkgc="\$(ls -d /var/db/pkg/*/* | grep -c "")" ;;
|
||||||
|
*) pkgc="0" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
printf "%d" "\${pkgc:-0}"
|
||||||
|
}
|
||||||
|
|
||||||
|
d_dist() {
|
||||||
|
case "\$dist" in
|
||||||
|
"arch") printf "Arch Linux\n" ;;
|
||||||
|
"debian") printf "Debian GNU/Linux\n" ;;
|
||||||
|
"void") printf "Void Linux\n" ;;
|
||||||
|
"gentoo") printf "Gentoo Linux\n" ;;
|
||||||
|
"funtoo") printf "Funtoo Linux\n" ;;
|
||||||
|
*) printf "Unknown\n" ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
rs() {
|
||||||
|
[ ! -f "\${ETC_DIR}/os-release" ] && printf "%s: %s/os-release not found. Is %s set up properly?\n" "\$(basename "\$0")" "\${ETC_DIR}" "\${ETC_DIR}" >> /dev/stderr && return 1
|
||||||
|
|
||||||
|
case "\$(cat "\${ETC_DIR}/os-release")" in
|
||||||
|
*Arch*|*arch*) dist="arch" ;;
|
||||||
|
*Artix*|*artix*) dist="arch" ;;
|
||||||
|
*Debian*|*debian*) dist="debian" ;;
|
||||||
|
*Gentoo*|*gentoo*) dist="gentoo" ;;
|
||||||
|
*Funtoo*|*funtoo*) dist="funtoo" ;;
|
||||||
|
*Void*|*void*) dist="void" ;;
|
||||||
|
*) dist="unknown" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
p() {
|
||||||
|
i="\${i:-1}"
|
||||||
|
printf "%s %s\n" "\$(printf "%s" "\${art:-NULL}" | head -n \$i | tail -1)" "\${1:-NULL}" >> /tmp/nsf_buf
|
||||||
|
i="\$((i+1))"
|
||||||
|
}
|
||||||
|
|
||||||
|
a() {
|
||||||
|
cat "/tmp/nsf_buf"; rm -f "/tmp/nsf_buf"
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
[ ! -f "${NSFETCH_CONFIG}" ] && printf "%s: failed to create config file '%s'\n" "$(basename "$0")" "${NSFETCH_CONFIG}" >> /dev/stderr && exit 1
|
||||||
|
. "${NSFETCH_CONFIG}"
|
||||||
|
}
|
||||||
|
|
||||||
|
ra() {
|
||||||
|
for v in "$@"; do
|
||||||
|
case "$v" in
|
||||||
|
"") continue ;;
|
||||||
|
-h|--help) printf "usage: %s [-h] [-v]\n" "$(basename "$0")" ;;
|
||||||
|
-v|--version) printf "%s %s\n" "$(basename $0)" "${NSFETCH_V:-0}" && exit 0 ;;
|
||||||
|
*) printf "%s: Invalid argument: '%s'\n" "$(basename "$0")" "$v" >> /dev/stderr && return 1
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
[ -z "$v" ] && return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
pf() {
|
||||||
|
[ -z "$(command -v ns_pf)" ] && printf "%s: ns_pf func not found in '%s'\n" "$(basename "$0")" "${NSFETCH_CONFIG}" >> /dev/stderr && return 1
|
||||||
|
ns_pf
|
||||||
|
}
|
||||||
|
|
||||||
|
r() {
|
||||||
|
ra "$@" || exit $?
|
||||||
|
rc || exit $?
|
||||||
|
rs || exit $?
|
||||||
|
|
||||||
|
pf || exit $?
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
r "$@"; exit $?
|
3
options.mk
Normal file
3
options.mk
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
VER = 0.1
|
||||||
|
PREFIX = "/usr"
|
||||||
|
NAME = nsfetch
|
Loading…
Reference in a new issue