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