#!/bin/bash
# pipeNeofetch (similar to pipeScreenfetch)
# call from .config/openbox/menu.xml like
#
# License=YYCPL0
# Yes You Can Permissive License 0
# header
header () {
cat << HEAD
HEAD
}
# footer
footer () {
cat << FOOT
FOOT
}
xmlescape () {
echo "$@" | sed 's/&/\&/g; s/\</g; s/>/\>/g; s/"/\"/g; s/'"'"'/\'/g; s/^[ \t]*//;s/[ \t]*$//'
}
# checks critical
command -v neofetch >/dev/null 2>&1 || { header; echo " "; footer ; exit 1; }
header
# items loop over lines
neofetch --off --stdout --disable title term model --memory_percent on | while read -r line
do
#line=$(xmlescape "$line")
#sed replacement https://github.com/koalaman/shellcheck/wiki/SC2001
if (( ${#line} > 2 )); then
line="${line//_/.}" # Dot . instead of __ should make this 'jgmenu ob' compatible
echo "-
bash -c \"echo '$line' | /usr/bin/xsel --clipboard\"
"
fi
done
# debug
#parent="$(ps $PPID | tail -n 1 | awk "{print \$5}")"
#echo " "
footer
# x-terminal-emulator -e sh -c \"echo '$line' | /usr/bin/xclip -selection clipboard; sleep 5\" # < this is not working without sleep, woot??