From 7fdc494cc968f01b33ac28fc8d603babd24fbf2f Mon Sep 17 00:00:00 2001 From: timoxa0 Date: Thu, 9 Jan 2025 16:26:46 +0500 Subject: [PATCH] fetch: move fetch to ~/.local/bin/ufetch --- dot-local/bin/ufetch | 83 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100755 dot-local/bin/ufetch diff --git a/dot-local/bin/ufetch b/dot-local/bin/ufetch new file mode 100755 index 0000000..90351dc --- /dev/null +++ b/dot-local/bin/ufetch @@ -0,0 +1,83 @@ +#!/bin/sh +# +# ufetch-arch - tiny system info for arch + +## INFO + +# user is already defined +host="$(cat /etc/hostname)" +os='Arch Linux' +kernel="$(uname -sr)" +uptime="$(uptime -p | sed 's/up //')" +packages="$(pacman -Q | wc -l)" +shell="$(basename "${SHELL}")" + +## UI DETECTION + +parse_rcs() { + for f in "${@}"; do + wm="$(tail -n 1 "${f}" 2> /dev/null | cut -d ' ' -f 2)" + [ -n "${wm}" ] && echo "${wm}" && return + done +} + +rcwm="$(parse_rcs "${HOME}/.xinitrc" "${HOME}/.xsession")" + +ui='unknown' +uitype='UI' +if [ -n "${DE}" ]; then + ui="${DE}" + uitype='DE' +elif [ -n "${WM}" ]; then + ui="${WM}" + uitype='WM' +elif [ -n "${XDG_CURRENT_DESKTOP}" ]; then + ui="${XDG_CURRENT_DESKTOP}" + uitype='DE' +elif [ -n "${DESKTOP_SESSION}" ]; then + ui="${DESKTOP_SESSION}" + uitype='DE' +elif [ -n "${rcwm}" ]; then + ui="${rcwm}" + uitype='WM' +elif [ -n "${XDG_SESSION_TYPE}" ]; then + ui="${XDG_SESSION_TYPE}" +fi + +ui="$(basename "${ui}")" + +## DEFINE COLORS + +# probably don't change these +if [ -x "$(command -v tput)" ]; then + bold="$(tput bold 2> /dev/null)" + black="$(tput setaf 0 2> /dev/null)" + red="$(tput setaf 1 2> /dev/null)" + green="$(tput setaf 2 2> /dev/null)" + yellow="$(tput setaf 3 2> /dev/null)" + blue="$(tput setaf 4 2> /dev/null)" + magenta="$(tput setaf 5 2> /dev/null)" + cyan="$(tput setaf 6 2> /dev/null)" + white="$(tput setaf 7 2> /dev/null)" + reset="$(tput sgr0 2> /dev/null)" +fi + +# you can change these +lc="${reset}${bold}${red}" # labels +nc="${reset}${bold}${red}" # user and hostname +ic="${reset}" # info +c0="${reset}${red}" # first color + +## OUTPUT + +cat <