Krolyxon
Commit 28b8728

Branches

Refs →

dotfiles-x11.localbinufetch

83 lines · 1.9 KB · Bourne Again Shell (bash)

1#!/bin/sh
2#
3# ufetch-arch - tiny system info for arch
4
5## INFO
6
7# user is already defined
8host="$(cat /etc/hostname)"
9os='Arch Linux'
10kernel="$(uname -sr)"
11uptime="$(uptime -p | sed 's/up //')"
12packages="$(pacman -Q | wc -l)"
13shell="$(basename "${SHELL}")"
14
15## UI DETECTION
16
17parse_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
24rcwm="$(parse_rcs "${HOME}/.xinitrc" "${HOME}/.xsession")"
25
26ui='unknown'
27uitype='UI'
28if [ -n "${DE}" ]; then
29 ui="${DE}"
30 uitype='DE'
31elif [ -n "${WM}" ]; then
32 ui="${WM}"
33 uitype='WM'
34elif [ -n "${XDG_CURRENT_DESKTOP}" ]; then
35 ui="${XDG_CURRENT_DESKTOP}"
36 uitype='DE'
37elif [ -n "${DESKTOP_SESSION}" ]; then
38 ui="${DESKTOP_SESSION}"
39 uitype='DE'
40elif [ -n "${rcwm}" ]; then
41 ui="${rcwm}"
42 uitype='WM'
43elif [ -n "${XDG_SESSION_TYPE}" ]; then
44 ui="${XDG_SESSION_TYPE}"
45fi
46
47ui="$(basename "${ui}")"
48
49## DEFINE COLORS
50
51# probably don't change these
52if [ -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)"
63fi
64
65# you can change these
66lc="${reset}${bold}${blue}" # labels
67nc="${reset}${bold}${blue}" # user and hostname
68ic="${reset}" # info
69c0="${reset}${blue}" # first color
70
71## OUTPUT
72
73cat <<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
83EOF