2017-05-06 00:37:27 -05:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# ufetch-debian - tiny system info for debian
|
|
|
|
|
|
|
|
## INFO
|
|
|
|
|
|
|
|
# user is already defined
|
2018-03-24 14:01:24 -05:00
|
|
|
host="$(hostname)"
|
2019-06-02 10:30:46 -05:00
|
|
|
os="Debian $(cat /etc/debian_version)"
|
2017-05-06 00:37:27 -05:00
|
|
|
kernel="$(uname -sr)"
|
|
|
|
uptime="$(uptime -p | sed 's/up //')"
|
2019-06-02 10:30:46 -05:00
|
|
|
packages="$(dpkg -l | grep -c ^i)"
|
2019-01-14 15:26:24 +13:00
|
|
|
shell="$(basename "$SHELL")"
|
2018-04-26 18:38:50 -05:00
|
|
|
|
2019-02-13 18:03:13 -06:00
|
|
|
## UI DETECTION
|
|
|
|
|
|
|
|
if [ -n "${DE}" ]; then
|
2019-03-25 01:04:04 +13:00
|
|
|
ui="${DE}"
|
|
|
|
uitype='DE'
|
2019-02-13 18:03:13 -06:00
|
|
|
elif [ -n "${WM}" ]; then
|
2019-03-25 01:04:04 +13:00
|
|
|
ui="${WM}"
|
|
|
|
uitype='WM'
|
2019-02-13 18:03:13 -06:00
|
|
|
elif [ -n "${XDG_CURRENT_DESKTOP}" ]; then
|
2019-03-25 01:04:04 +13:00
|
|
|
ui="${XDG_CURRENT_DESKTOP}"
|
|
|
|
uitype='DE'
|
2019-02-13 18:03:13 -06:00
|
|
|
elif [ -n "${DESKTOP_SESSION}" ]; then
|
2019-03-25 01:04:04 +13:00
|
|
|
ui="${DESKTOP_SESSION}"
|
|
|
|
uitype='DE'
|
2019-02-13 18:03:13 -06:00
|
|
|
elif [ -f "${HOME}/.xinitrc" ]; then
|
2019-03-25 01:04:04 +13:00
|
|
|
ui="$(tail -n 1 "${HOME}/.xinitrc" | cut -d ' ' -f 2)"
|
|
|
|
uitype='WM'
|
2019-02-13 18:03:13 -06:00
|
|
|
elif [ -f "${HOME}/.xsession" ]; then
|
2019-03-25 01:04:04 +13:00
|
|
|
ui="$(tail -n 1 "${HOME}/.xsession" | cut -d ' ' -f 2)"
|
|
|
|
uitype='WM'
|
2019-06-02 10:30:46 -05:00
|
|
|
elif [ -h /etc/alternatives/x-session-manager ]; then
|
|
|
|
ui="$(update-alternatives --query x-session-manager | awk -F'/' '/Value/{print $4}')"
|
|
|
|
uitype='DE'
|
|
|
|
elif [ -h /etc/alternatives/x-window-manager ]; then
|
|
|
|
ui="$(update-alternatives --query x-window-manager | awk -F'/' '/Value/{print $4}')"
|
|
|
|
uitype='WM'
|
2018-04-26 18:38:50 -05:00
|
|
|
else
|
2019-03-25 01:04:04 +13:00
|
|
|
ui='unknown'
|
|
|
|
uitype='UI'
|
2017-05-06 00:37:27 -05:00
|
|
|
fi
|
|
|
|
|
|
|
|
## DEFINE COLORS
|
|
|
|
|
|
|
|
# probably don't change these
|
2018-07-18 20:19:43 -03:00
|
|
|
if [ -x "$(command -v tput)" ]; then
|
|
|
|
bold="$(tput bold)"
|
|
|
|
black="$(tput setaf 0)"
|
|
|
|
red="$(tput setaf 1)"
|
|
|
|
green="$(tput setaf 2)"
|
|
|
|
yellow="$(tput setaf 3)"
|
|
|
|
blue="$(tput setaf 4)"
|
|
|
|
magenta="$(tput setaf 5)"
|
|
|
|
cyan="$(tput setaf 6)"
|
|
|
|
white="$(tput setaf 7)"
|
|
|
|
reset="$(tput sgr0)"
|
|
|
|
fi
|
2017-05-06 00:37:27 -05:00
|
|
|
|
|
|
|
# you can change these
|
2019-01-14 15:47:41 +13:00
|
|
|
lc="${reset}${bold}${red}" # labels
|
|
|
|
nc="${reset}${bold}${red}" # user and hostname
|
2019-10-04 14:17:29 -05:00
|
|
|
ic="${reset}" # info
|
2019-01-14 15:47:41 +13:00
|
|
|
c0="${reset}${bold}${red}" # first color
|
|
|
|
c1="${reset}${red}" # second color
|
2017-05-06 00:37:27 -05:00
|
|
|
|
|
|
|
## OUTPUT
|
|
|
|
|
|
|
|
cat <<EOF
|
|
|
|
|
2019-01-14 15:01:47 +13:00
|
|
|
${c0} _____ ${nc}${USER}${ic}@${nc}${host}${reset}
|
2018-03-24 14:01:24 -05:00
|
|
|
${c0} / __ \\ ${lc}OS: ${ic}${os}${reset}
|
|
|
|
${c0} | / | ${lc}KERNEL: ${ic}${kernel}${reset}
|
|
|
|
${c0} | ${c1}\\___- ${lc}UPTIME: ${ic}${uptime}${reset}
|
|
|
|
${c1} -_ ${lc}PACKAGES: ${ic}${packages}${reset}
|
|
|
|
${c1} --_ ${lc}SHELL: ${ic}${shell}${reset}
|
2019-02-13 18:03:13 -06:00
|
|
|
${c0} ${lc}${uitype}: ${ic}${ui}${reset}
|
2017-05-06 00:37:27 -05:00
|
|
|
|
|
|
|
EOF
|