dots

Personal dotfiles
git clone git://git.gormless.xyz/dots.git
Log | Files | Refs

ufetch (2142B)


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