mirror of
https://gitlab.com/jschx/ufetch.git
synced 2026-10-20 11:20:00 +00:00
Improve UI detection (fixes #16)
This commit is contained in:
1 parent
06729d8186
commit
498f92be41
38 files changed
+655
-378
No files matched your search
+18
-10
@@ -10,10 +10,21 @@ os='Linux' # I'd just like to interject for a moment...
|
||||
kernel="$(uname -sr)"
|
||||
uptime="$(uptime | awk -F, '{sub(".*up ",x,$1);print $1}' | sed -e 's/^[ \t]*//')"
|
||||
packages='unknown'
|
||||
shell="$(basename "$SHELL")"
|
||||
shell="$(basename "${SHELL}")"
|
||||
|
||||
## UI DETECTION
|
||||
|
||||
parse_rcs() {
|
||||
for f in "${@}"; do
|
||||
wm="$(tail -n 1 "${f}" 2> /dev/null | cut -d ' ' -f 2)"
|
||||
[ -n "${wm}" ] && echo "${wm}" && return
|
||||
done
|
||||
}
|
||||
|
||||
rcwm="$(parse_rcs "${HOME}/.xinitrc" "${HOME}/.xsession")"
|
||||
|
||||
ui='unknown'
|
||||
uitype='UI'
|
||||
if [ -n "${DE}" ]; then
|
||||
ui="${DE}"
|
||||
uitype='DE'
|
||||
@@ -26,17 +37,14 @@ elif [ -n "${XDG_CURRENT_DESKTOP}" ]; then
|
||||
elif [ -n "${DESKTOP_SESSION}" ]; then
|
||||
ui="${DESKTOP_SESSION}"
|
||||
uitype='DE'
|
||||
elif [ -f "${HOME}/.xinitrc" ]; then
|
||||
ui="$(tail -n 1 "${HOME}/.xinitrc" | cut -d ' ' -f 2)"
|
||||
elif [ -n "${rcwm}" ]; then
|
||||
ui="${rcwm}"
|
||||
uitype='WM'
|
||||
elif [ -f "${HOME}/.xsession" ]; then
|
||||
ui="$(tail -n 1 "${HOME}/.xsession" | cut -d ' ' -f 2)"
|
||||
uitype='WM'
|
||||
else
|
||||
ui='unknown'
|
||||
uitype='UI'
|
||||
elif [ -n "${XDG_SESSION_TYPE}" ]; then
|
||||
ui="${XDG_SESSION_TYPE}"
|
||||
fi
|
||||
ui="$(basename ${ui})"
|
||||
|
||||
ui="$(basename "${ui}")"
|
||||
|
||||
## DEFINE COLORS
|
||||
|
||||
|
||||
Reference in new issue
Block a user