| 1 | #!/bin/sh |
| 2 | # |
| 3 | # ufetch-arch - tiny system info for arch |
| 4 | |
| 5 | ## INFO |
| 6 | |
| 7 | # user is already defined |
| 8 | host="$(cat /etc/hostname)" |
| 9 | os='Arch Linux' |
| 10 | kernel="$(uname -sr)" |
| 11 | uptime="$(uptime -p | sed 's/up //')" |
| 12 | packages="$(pacman -Q | wc -l)" |
| 13 | shell="$(basename "${SHELL}")" |
| 14 | |
| 15 | ## UI DETECTION |
| 16 | |
| 17 | parse_rcs() { |
| 18 | for f in "${@}"; do |
| 19 | wm="$(tail -n 1 "${f}" 2> /dev/null | cut -d ' ' -f 2)" |
| 20 | [ -n "${wm}" ] && echo "${wm}" && return |
| 21 | done |
| 22 | } |
| 23 | |
| 24 | rcwm="$(parse_rcs "${HOME}/.xinitrc" "${HOME}/.xsession")" |
| 25 | |
| 26 | ui='unknown' |
| 27 | uitype='UI' |
| 28 | if [ -n "${DE}" ]; then |
| 29 | ui="${DE}" |
| 30 | uitype='DE' |
| 31 | elif [ -n "${WM}" ]; then |
| 32 | ui="${WM}" |
| 33 | uitype='WM' |
| 34 | elif [ -n "${XDG_CURRENT_DESKTOP}" ]; then |
| 35 | ui="${XDG_CURRENT_DESKTOP}" |
| 36 | uitype='DE' |
| 37 | elif [ -n "${DESKTOP_SESSION}" ]; then |
| 38 | ui="${DESKTOP_SESSION}" |
| 39 | uitype='DE' |
| 40 | elif [ -n "${rcwm}" ]; then |
| 41 | ui="${rcwm}" |
| 42 | uitype='WM' |
| 43 | elif [ -n "${XDG_SESSION_TYPE}" ]; then |
| 44 | ui="${XDG_SESSION_TYPE}" |
| 45 | fi |
| 46 | |
| 47 | ui="$(basename "${ui}")" |
| 48 | |
| 49 | ## DEFINE COLORS |
| 50 | |
| 51 | # probably don't change these |
| 52 | if [ -x "$(command -v tput)" ]; then |
| 53 | bold="$(tput bold)" |
| 54 | black="$(tput setaf 0)" |
| 55 | red="$(tput setaf 1)" |
| 56 | green="$(tput setaf 2)" |
| 57 | yellow="$(tput setaf 3)" |
| 58 | blue="$(tput setaf 4)" |
| 59 | magenta="$(tput setaf 5)" |
| 60 | cyan="$(tput setaf 6)" |
| 61 | white="$(tput setaf 7)" |
| 62 | reset="$(tput sgr0)" |
| 63 | fi |
| 64 | |
| 65 | # you can change these |
| 66 | lc="${reset}${bold}${blue}" # labels |
| 67 | nc="${reset}${bold}${blue}" # user and hostname |
| 68 | ic="${reset}" # info |
| 69 | c0="${reset}${blue}" # first color |
| 70 | |
| 71 | ## OUTPUT |
| 72 | |
| 73 | cat <<EOF |
| 74 | |
| 75 | ${c0} /\\ ${nc}${USER}${ic}@${nc}${host}${reset} |
| 76 | ${c0} / \\ ${lc}OS: ${ic}${os}${reset} |
| 77 | ${c0} /\\ \\ ${lc}KERNEL: ${ic}${kernel}${reset} |
| 78 | ${c0} / __ \\ ${lc}UPTIME: ${ic}${uptime}${reset} |
| 79 | ${c0} / ( ) \\ ${lc}PACKAGES: ${ic}${packages}${reset} |
| 80 | ${c0} / __| |__\\\\ ${lc}SHELL: ${ic}${shell}${reset} |
| 81 | ${c0} /.\` \`.\\ ${lc}${uitype}: ${ic}${ui}${reset} |
| 82 | |
| 83 | EOF |