getInfo 2.45.0

This commit is contained in:
kyodev 2017-11-25 19:39:57 +01:00
parent 027f226485
commit fc4517adb4
2 changed files with 213 additions and 191 deletions

View File

@ -1,7 +1,7 @@
#!/bin/bash
version=2.44.2
date="24/11/2017"
version=2.45.0
date="25/11/2017"
projet="simpledeb"
contact="IRC freenode ##sdeb ou https://framagit.org/kyodev/kyopages/issues/"
script="getInfo"
@ -24,18 +24,19 @@ f__affichage(){ # 29/10/2017
echo -e "$BLUE$affichage_text\n$YELLOW version $version - $date$STD\n"
}
# detect system architecture, assign $architecture : 32bits, i686 | 64bits, amd64, return 1 on unknown architecture
# detect system architecture, assign $architecture : 32bits, i686 | 64bits, amd64 (x86_64),
# return 1 on unknown architecture
# remarque, debian: dpkg --print-architecture affiche i386
f__architecture(){ # 08/2017 spécifique
f__architecture(){ # 26/11/2017 spécifique
case "$(uname -m)" in
amd64 | x86_64 )
architecture="64bits, amd64";;
architecture="64bits, amd64 (x86_64)";;
i?86 | x86 )
architecture="32bits, i686";;
* )
case "$(getconf LONG_BIT)" in
64 )
architecture="64bits, amd64";;
architecture="64bits, amd64 (x86_64)";;
32 )
architecture="32bits, i686";;
*)
@ -601,13 +602,13 @@ fi_disk(){ # 20/11/2017
[ "$alert_dd_temp" ] && alert_dd_temp=${alert_dd_temp::-1} # suppression dernier $'\n'
fi
# df, espaces des partitions montées seules
disk_df="$(df -h --output=source,target,fstype,size,used,avail,pcent --exclude=tmpfs --exclude=devtmpfs | grep -Ev 'devpts|none|proc|sys|tmpfs|udev')"
disk_df=$( df -h --output=source,target,fstype,size,used,avail,pcent --exclude=tmpfs --exclude=devtmpfs | grep -Ev 'devpts|none|proc|sys|tmpfs|udev' )
# df -i, inoeuds
disk_df_i="$(df -i --exclude=tmpfs --exclude=devtmpfs | grep -Ev 'devpts|none|proc|sys|tmpfs|udev')"
disk_df_i=$( df -i --exclude=tmpfs --exclude=devtmpfs | grep -Ev 'devpts|none|proc|sys|tmpfs|udev' )
# lsblk répertoire disques & partitions
disk_lsblk="$(lsblk -o NAME,FSTYPE,SIZE,LABEL,MOUNTPOINT,UUID)"
disk_lsblk=$( lsblk -o NAME,FSTYPE,SIZE,LABEL,MOUNTPOINT,UUID )
# fstab
fstab="$(f_grep_file "/etc/fstab" "nofile")"
fstab=$( f_grep_file "/etc/fstab" "nofile" )
# resume
resume=$( f_grep_file "/etc/initramfs-tools/conf.d/resume" "nofile" )
if [ "$resume" == "nofile" ]; then
@ -618,8 +619,8 @@ fi_disk(){ # 20/11/2017
alert_file_resume+="À investiguer si erreur au boot ou boot très long ou erreur update-initramfs. \n"
alert_file_resume+="Notes: <https://kyodev.frama.io/kyopages/debian/petits-soucis/#fichier-resume> \n"
fi
idResume="$(grep -Evs '^[[:blank:]]*#|^$' /etc/initramfs-tools/conf.d/resume | sed -En 's/.*UUID=([0-9a-Z-]*).*$/\1/p')"
idSwap="$(grep -Ev '^[[:blank:]]*#|^$' /etc/fstab | sed -En 's/UUID=([0-9a-Z-]*).*swap.*$/\1/p')"
idResume=$( grep -Evs '^[[:blank:]]*#|^$' /etc/initramfs-tools/conf.d/resume | sed -En 's/.*UUID=([0-9a-Z-]*).*$/\1/p' )
idSwap=$( grep -Ev '^[[:blank:]]*#|^$' /etc/fstab | sed -En 's/UUID=([0-9a-Z-]*).*swap.*$/\1/p' )
if [ "$idSwap" ] && [ "$idResume" ] && [ "$idSwap" != "$idResume" ]; then
alert_uuidResume+="vérifier la config resume, l'UUID ne correspond pas à celui du swap. \n"
alert_uuidResume+="id swap : $idSwap \nid resume: $idResume \n"
@ -734,7 +735,7 @@ fi_efi(){ # 20/11/2017
unset text
}
fi_graph(){ # 24/11/2017
fi_graph(){ # 25/11/2017
local slots cards cmd_cards ig
local stck_glxinfo stck_glxinfoOpt stck_glxinfoDri glx_dvc cmd_glx_dvc glx_dvc_temp openGl cmd_openGl
local providers resolutions pluriel modules cmt_modules text
@ -799,10 +800,10 @@ fi_graph(){ # 24/11/2017
}
if [[ "$wayland" && "$EUID" -eq 0 ]]; then # évite erreur $DISPLAY en root wayland
openGl="n/a en root sous wayland"
resolutions="n/a en root sous wayland"
providers="n/a en root sous wayland"
current_preferred="n/a en root sous wayland"
openGl="n/a:wayland root"
resolutions="n/a:wayland root"
providers="n/a:wayland root"
current_preferred="n/a:wayland root"
else
# openGl / glxinfo
if [ $( f__which glxinfo ) ]; then
@ -818,11 +819,11 @@ fi_graph(){ # 24/11/2017
if [ "$fg_nb_gpu" -gt 1 ]; then # plusieurs cartes, optirun et prime
if [ $( f__which optirun ) ]; then
stck_glxinfoOpt=$( optirun glxinfo )
glx_dvc_temp=$( grep 'Device: ' <<< $stck_glxinfoOpt )
glx_dvc_temp=$( grep 'Device: ' <<< $stck_glxinfoOpt | xargs )
cmd_glx_dvc="optirun $cmd_glx_dvc"
else
stck_glxinfoDri=$( DRI_PRIME=1 glxinfo )
glx_dvc_temp=$( grep 'Device: ' <<< $stck_glxinfoDri )
glx_dvc_temp=$( grep 'Device: ' <<< $stck_glxinfoDri | xargs )
cmd_glx_dvc="DRI_PRIME=1 $cmd_glx_dvc"
fi
[ "$glx_dvc_temp" != "$glx_dvc" ] && glx_dvc+="\n$glx_dvc_temp" # ajout si diff
@ -893,8 +894,8 @@ fi_graph(){ # 24/11/2017
unset text
}
fi_hw(){ # 10/11/2017
figet_hw
fi_hw(){ # 25/11/2017
[ "$fg_hw" ] || figet_hw
###
text="## hardware monitor ACPI \n\n"
f_display "fg_hw" "sans"
@ -903,11 +904,14 @@ fi_hw(){ # 10/11/2017
unset text
}
fi_journal(){ # 23/11/2017
fi_journal(){ # 25/11/2017
local jctl_boot jctl_alert_k jctl_crit_k jctl_err_k jctl_warn_k jctl_warn_nok jctl_last jctl_size file
local text nb_lignes=25
local alert_jctl_persist alert_firmBug
[ $( f__which journalctl ) ] || fi_dmesg # pas systemd, appel dmesg
if [ -z $( f__which journalctl ) ]; then
fi_dmesg # pas systemd, appel dmesg
return 0
fi
file="/tmp/$$-$RANDOM-journalctl"
[ "$EUID" -eq 0 ] || echo
f__sudo " LC_ALL=C journalctl --no-hostname --boot -1 &>$file-persistant ; \
@ -1003,7 +1007,7 @@ fi_journal(){ # 23/11/2017
unset text
}
fi_locale(){ # 24/11/2017
fi_locale(){ # 25/11/2017
local locale localectl timezone timedatectl xKeyboardMap keyboard text
local alert_rtc alert_ntp
# locale
@ -1012,7 +1016,7 @@ fi_locale(){ # 24/11/2017
# timezone
timezone="$(f_grep_file "/etc/timezone*")"
if [ $( f__which timedatectl ) ]; then
timedatectl="$(timedatectl status --no-pager)"
timedatectl=$( LC_ALL=C timedatectl status --no-pager )
if grep -iq 'Network time on: no' <<< "$timedatectl"; then
alert_ntp="Network time on: no \n"
alert_ntp+="Le système ne synchronise pas l'heure sur un serveur NTP. Si ce n'est pas voulu: \n"
@ -1028,7 +1032,7 @@ fi_locale(){ # 24/11/2017
fi
fi
# keyboard layout
keyboard="$(f_grep_file "/etc/default/keyboard*")"
keyboard=$( f_grep_file "/etc/default/keyboard*" )
if [[ "$wayland" && "$EUID" -eq 0 ]]; then # évite erreur $DISPLAY en root wayland
xKeyboardMap="n/a en root sous wayland"
else
@ -1051,22 +1055,22 @@ fi_locale(){ # 24/11/2017
unset text
}
fi_log_xorg(){ # 23/11/2017
fi_log_xorg(){ # 25/11/2017
local toScrut xfile xfileTest="" logXorg cmd_logXorg="" cmt_logXorg extract dateFile text nb_lignes=50
local info_logs
[ "$ENV_SSH" ] && return 0
[[ "$ENV_SSH" || "$ENV_DISPLAY" ]] && return 0
toScrut=(
/var/log/Xorg.0.log
/home/$user_/.local/share/xorg/Xorg.0.log
/var/lib/gdm3/.local/share/xorg/Xorg.0.log
)
# checkpoint
for xfile in "${toScrut[@]}"; do
for xfile in ${toScrut[@]}; do
[ -e "$xfile" ] && xfileTest+="y"
done
[ ${#xfileTest} -eq 0 ] && return 0 # aucun fichier à tester (wayland?), retour
# coeur fonction
for xfile in "${toScrut[@]}"; do
for xfile in ${toScrut[@]}; do
if [ -e "$xfile" ]; then
dateFile=$( date -r $xfile '+%d/%m/%Y %H:%M %z' )
extract=$( grep -Es '\(WW\)|\(EE\)|\(\?\?\)' $xfile | sed '/(WW) warning, (EE) error,/d' )
@ -1084,7 +1088,7 @@ fi_log_xorg(){ # 23/11/2017
logXorg+=" $xfile : <inexistant> "$'\n'$'\n'
fi
done
logXorg="${logXorg::-2}"
logXorg=${logXorg::-2}
[ "$cmd_logXorg" ] && cmd_logXorg=${cmd_logXorg% } || cmd_logXorg="<emplacement>"
info_logs="voir les options appliquées par défaut: **cat $cmd_logXorg | grep '(\\\*\\\*)**' "
cmd_logXorg="grep -Es '\(WW\)|\(EE\)|\(\?\?\)' $cmd_logXorg"
@ -1103,7 +1107,7 @@ fi_mem(){ # 20/11/2017
memoire="$fg_mem \n"
figet_mem "swap" "notitle"
memoire+="$fg_mem"
swappiness="$(cat /proc/sys/vm/swappiness 2>/dev/null)"
swappiness=$( cat /proc/sys/vm/swappiness 2>/dev/null )
###
text="## mémoire \n\n"
f_display "memoire" "cmd" "free -h"
@ -1511,28 +1515,28 @@ fi_reseau(){ # 20/11/2017
[ "$cards" ] && cards=${cards::-1} # suppression dernier $'\n'
[ $( f__wcv -l "$cards" ) -eq 0 ] && cards="lspci incompatible"
# ip a & route
ip_a="$(ip a | sed '/link\/ether/d; /valid_lft/d')" # filtre sur adr MAC & bail
# ip_a="$(sed '/inet6.*scope global/d; /inet6.*scope link/d' <<< $ip_a)" # filtre sur inet6 scope global & scope link (fe80::)
ip_a="$(sed '/inet6.*/d' <<< $ip_a)" # filtre sur inet6)
route="$(ip route show)"
ip_a=$( ip a | sed '/link\/ether/d; /valid_lft/d' ) # filtre sur adr MAC & bail
# ip_a=$( sed '/inet6.*scope global/d; /inet6.*scope link/d' <<< $ip_a ) # filtre sur inet6 scope global & scope link (fe80::)
ip_a=$( sed '/inet6.*/d' <<< $ip_a ) # filtre sur inet6)
route=$( ip route show )
# interfaces & resolv
interfaces="$(f_grep_file "/etc/network/interfaces*")"
interfaces="$(sed -E 's/wpa-psk [[:graph:]]+/wpa-psk <WPA key removed>/; s/:/: /' <<< $interfaces )"
resolv="$(f_grep_file "/etc/resolv.conf" nofile)"
interfaces=$( f_grep_file "/etc/network/interfaces*" )
interfaces=$( sed -E 's/wpa-psk [[:graph:]]+/wpa-psk <WPA key removed>/; s/:/: /' <<< $interfaces )
resolv=$( f_grep_file "/etc/resolv.conf" nofile )
# iwconfig
if [ $( f__which iwconfig ) ]; then #paquet wireless-tools requis
iwconfig="$(iwconfig 2>&1 | grep -v 'no wireless extensions' | grep -v '^[[:space:]]*$')"
iwconfig=$( LC_ALL=C iwconfig 2>&1 | grep -v 'no wireless extensions' | grep -v '^[[:space:]]*$' )
fi
# iwlist
if [ $( f__which iwlist ) ]; then # canal wifi utilisé; /sbin, paquet wireless-tools requis
canal_wifi="$(iwlist chan 2>&1 | grep 'Current Frequency' | grep -Eio 'channel [0-9]+')"
canal_wifi=$( LC_ALL=C iwlist chan 2>&1 | grep 'Current Frequency' | grep -Eio 'channel [0-9]+' )
fi
# network manager
netmgrpaths=("/usr/sbin/NetworkManager" "/usr/sbin/wicd" "/usr/sbin/connmand") # thanks wireless-info
netmgrnames=("NetworkManager" "Wicd" "ConnMan")
for ifx in "${!netmgrpaths[@]}"; do
[ -e "${netmgrpaths[$ifx]}" ] && netmgrinst+=${netmgrnames[$ifx]}
if [ "$(ps -ef | grep -c ${netmgrpaths[$ifx]})" -ge 2 ]; then
if [ $( ps -ef | grep -c ${netmgrpaths[$ifx]} ) -ge 2 ]; then
netmgrrun+="$(ps -ef | grep -o "${netmgrpaths[$ifx]}.*$" | head -n 1)"
fi
done
@ -1630,23 +1634,23 @@ fi_ssid(){ #v2 22/11/2017
rm "$fileOutput"
}
fi_system_analyse(){ #v 23/11/2017
fi_system_analyse(){ #v 25/11/2017
[ $( f__which systemd ) ] || return 0 # pas systemd
local bootTime cmd_bootTime cmt_bootTime pluriel text
local srvcFail cmd_srvcFail cmt_srvcFail qte_srvcFail isrvc srvcFail_list
local srvcFail cmd_srvcFail cmt_srvcFail qte_srvcFail isrvc srvcFail_list info_services
local bootBlame cmd_bootBlame cmt_bootBlame bootCritic cmd_bootCritic cmt_bootCritic
local bootGraph cmd_bootGraph cmt_bootGraph file="/tmp/getInfo-graph.svg"
local alert_srvcFail
# durée du précédent boot
bootTime=$( systemd-analyze time )
bootTime=$( LC_ALL=C systemd-analyze time )
bootTime=${bootTime/Startup finished in /Durée de boot: }
bootTime=${bootTime/userspace/espace utilisateur}
cmd_bootTime="systemd-analyze time"
cmt_bootTime="durée du boot, avant interface graphique"
# services en erreur
# srvcFail=$( systemctl --state=active,failed | grep -cE 'error|not-found|failed' )
srvcFail=$( systemctl --state=active,failed | gawk '
/error|not-found|failed/ { sub(/●/,"");
srvcFail=$( LC_ALL=C systemctl --state=active,failed | gawk '
/error|not-found|failed/ { sub(/●|*/,"");
printf "%-50s %-11s %-8s %-8s %s",$1,$2,$3,$4,$5; $1=$2=$3=$4=$5=""; print $0}' )
cmd_srvcFail="systemctl --state=active,failed | grep -E 'error|not-found|failed'"
qte_srvcFail=$( f__wcv -l $srvcFail )
@ -1664,12 +1668,13 @@ fi_system_analyse(){ #v 23/11/2017
alert_srvcFail=${alert_srvcFail//●}
srvcFail=$( printf "%-50s %-11s %-8s %-8s %s" Unit Load Active Sub Description )$'\n'"$srvcFail"
fi
info_services="voir tous les services: **systemctl list-units --type=service | pager**"
# détail par service
bootBlame=$( systemd-analyze blame | head -n 20 )
bootBlame=$( LC_ALL=C systemd-analyze blame | head -n 20 )
cmd_bootBlame="systemd-analyze blame | head -n 20"
cmt_bootBlame="détail par service"
# services critiques ralentisseurs
bootCritic=$( systemd-analyze critical-chain )
bootCritic=$( LC_ALL=C systemd-analyze critical-chain )
bootCritic=${bootCritic/The time after the unit is active or started is printed after the \"@\" character./ @: temps auquel l\'unité est active ou démarrée}
bootCritic=${bootCritic/The time the unit takes to start is printed after the \"+\" character./ +: temps que l\'unité prend pour démarrer}
cmd_bootCritic="systemd-analyze critical-chain"
@ -1694,6 +1699,7 @@ fi_system_analyse(){ #v 23/11/2017
[ "$srvcFail" ] || text+="* pas de service en erreur \n\n"
f_display "bootTime" "cmd" "$cmd_bootTime" "$cmt_bootTime"
f_display "srvcFail" "cmd" "$cmd_srvcFail" "$cmt_srvcFail"
f_dspl_alert "info_services" "info"
f_dspl_alert "alert_srvcFail" "alert"
f_display "bootBlame" "cmd" "$cmd_bootBlame" "$cmt_bootBlame"
f_display "bootCritic" "cmd" "$cmd_bootCritic" "$cmt_bootCritic"
@ -1702,30 +1708,25 @@ fi_system_analyse(){ #v 23/11/2017
unset text
}
fi_systeme(){ # 22/11/2017
fi_systeme(){ # 25/11/2017
local mbr uname bootImage initDaemon serverX shells lastboot uptime charge pluriel text
local alimentation alim_total ish ifs_origin ligne date_install
local alimentation alim_total ifs_origin ligne date_install
local alert_SLiM alert_microcode
[ -d /sys/firmware/efi ] && mbr="EFI" || mbr="Legacy (mbr)"
uname="$(uname -rmo)"
bootImage="$(gawk '/BOOT_IMAGE/ {print $1}' /proc/cmdline)"
bootImage="$(gawk '{print $1}{i=2; while (i <= NF-1) { print " ",$i; i++}}' /proc/cmdline)"
initDaemon="$(ps -p1 | gawk 'FNR==2 {print $4}')" #? ps -ax | gawk '$1==1' ou ps -p1 | gawk '$1==1'
[[ "$initDaemon" == "systemd" && $( f__which systemd ) ]] && initDaemon=$( systemd --version )
initDaemon=${initDaemon%%[[:space:]]+*}
uname=$( uname -rmo )
bootImage=$( gawk '/BOOT_IMAGE/ {print $1}' /proc/cmdline )
bootImage=$( gawk '{print $1}{i=2; while (i <= NF-1) { print " ",$i; i++}}' /proc/cmdline )
initDaemon=$( ps -p1 | gawk 'FNR==2 {print $4}' ) #? ps -ax | gawk '$1==1' ou ps -p1 | gawk '$1==1'
if [[ "$initDaemon" == "systemd" && $( f__which systemd ) ]]; then
initDaemon=$( systemd --version )
initDaemon=${initDaemon%%[[:space:]]\+*}
initDaemon=${initDaemon/systemd/systemd version}
[ "$ENV_SSH" ] && serverX="n/a (ssh)" || serverX="$XDG_SESSION_TYPE" # normalement retourne wayland
[ "$wayland" ] && serverX="$wayland"
[ "$serverX" ] || serverX="n/a"
if [ -e "/etc/shells" ]; then # by-pass sinon soucis sous fedora et openSuse
for ish in $(f_grep_file "/etc/shells" "nofile"); do
shells+=${ish##*/}" " # conservation dernier "champs", ifs '/'
done
shells=${shells%% } # suppression espace de fin
shells=$(tr ' ' '\n' <<< $shells | sort -u | tr '\n' ' ') # tri et suppression doublons
else
shells="n/a"
fi
serverX="$XDG_SESSION_TYPE" # normalement retourne wayland
[ "$wayland" ] && serverX="$wayland" # au cas où
[ "$serverX" ] || serverX="n/a"
[ "$ENV_DISPLAY" ] && serverX+=":no DISPLAY"
[ "$ENV_SSH" ] && serverX+=":ssh"
if [ $( grep -c 'AC' <<< $(ls /sys/class/power_supply/ 2>/dev/null) ) -gt 0 ]; then
alim_total=$( grep -cs . <<< $(ls /sys/class/power_supply/AC*/online) )
alimentation=$( gawk -v "alim_total=$alim_total" '
@ -1739,8 +1740,8 @@ fi_systeme(){ # 22/11/2017
done <<< $( ls -lt --time-style '+FORMAT %d/%m/%Y' / )
[[ "$date_install" =~ .*([0-9]{2}/[0-9]{2}/[0-9]{4}).* ]] && date_install=${BASH_REMATCH[1]}
# lastboot="$(last -n 1 --time-format iso reboot | gawk 'FNR==1 {sub(/T/," ",$5);print $5}')" # remis à jours en début de mois ?!!
lastboot="$(date -r /var/run/utmp '+%d/%m/%Y %H:%M %z')"
uptime=$(uptime)
lastboot=$( date -r /var/run/utmp '+%d/%m/%Y %H:%M %z' )
uptime=$( LC_ALL=C uptime )
charge=${uptime/*average: } # suppression jusqu'à 'average: '
charge=${charge//, / } # remplacement global ', ' par ' '
charge=${charge//,/.} # remplacement global , par .
@ -1800,7 +1801,7 @@ fi_systeme(){ # 22/11/2017
text+="desktop (DE): $fg_de \n"
text+="window manager: $fg_wm \n"
text+="shell actif: $fg_shell \n"
text+="shells installés: $shells \n"
text+="shells installés: $fg_shells \n"
[ "$fg_disk_part_fix_tot" ] && text+="$fg_disk_part_fix_tot \n"
[ "$alimentation" ] && text+="$alimentation \n"
if [ "$fg_batt" ]; then
@ -1820,8 +1821,8 @@ fi_systeme(){ # 22/11/2017
fi_usb(){ # 25/10/2017
local lsusb lsusb_t text
lsusb="$(lsusb)"
lsusb_t="$(lsusb -t)"
lsusb=$( lsusb )
lsusb_t=$( lsusb -t )
###
text="## USB \n\n"
f_display "lsusb" "cmd" "lsusb"
@ -1833,7 +1834,7 @@ fi_usb(){ # 25/10/2017
fi_vrms(){ # 20/11/2017
local vrms non_free contrib total text pluriel tempo
if [ $( f__which vrms ) ]; then
vrms="$(vrms)"
vrms=$( vrms )
non_free=$(( $( sed -En 's/([0-9]+) non-free packages,.*/\1/p' <<< "$vrms" ) ))
contrib=$(( $( sed -En 's/([0-9]+) contrib packages,.*/\1/p' <<< "$vrms" ) ))
if [[ "$non_free" -gt 0 || "$contrib" -gt 0 ]]; then
@ -2406,37 +2407,38 @@ figet_cpu_uarch(){ # 24/11/2017
}
# assigne $fg_de
figet_de(){ #v 21/11/2017 # thanks neofetch
figet_de(){ #v 25/11/2017 # thanks neofetch
local de="n/a"
fg_de="n/a"
[ "$ENV_DISPLAY" ] && fg_de+=":no Display"
[ "$ENV_SSH" ] && fg_de+=":ssh"
[[ "$fg_de" =~ : ]] && return 0 # retourne n/a: xprop ou n/a: ssh
[[ "$fg_de" =~ : ]] && return 0 # retourne n/a ...
##
de="$XDG_CURRENT_DESKTOP"
[ "$de" ] || "$DESKTOP_SESSION"
de=${DESKTOP_SESSION##*/} # suppression plus grande chaine au début jusqu'à /, pour $DESKTOP_SESSION
de=${de/X-} # supression de X-
de=${de/Budgie:GNOME/Budgie} # remplacement Budgie:GNOME par Budgie
if [ -z "$de" ]; then
de="$DESKTOP_SESSION"
de=${DESKTOP_SESSION##*/} # suppression plus grande chaine au début jusqu'à /
fi
# fallback to using xprop
if [[ "$wayland" && "$EUID" -eq 0 && "$de" == "n/a" ]]; then
fg_de+=": wayland root"
if [[ "$wayland" && "$EUID" -eq 0 && -z "$de" ]]; then
fg_de="n/a:wayland root"
return 0
elif [[ "$de" == "n/a" ]]; then
de=$( xprop -root | gawk 'IGNORECASE = 1;/KDE_SESSION_VERSION|^_MUFFIN|xfce/' )
elif [[ -z "$de" ]]; then
de=$( xprop -root | gawk 'IGNORECASE = 1;/KDE_SESSION_VERSION|^_MUFFIN/' )
fi
# Format strings
if [[ "${de,,}" =~ kde_session_version ]]; then
de="KDE"${de/* = }
if [[ "${de,,}" =~ kde_session_version ]]; then # test sur minuscules
de="kde"${de/* = }
elif [[ "${de,,}" =~ tde_full_session ]]; then
de="Trinity" # fork kde 3.5
elif [[ "${de,,}" =~ muffin || "$de" =~ Cinnamon ]]; then
de="trinity" # fork kde 3.5
elif [[ "${de,,}" =~ muffin || "${de,,}" =~ cinnamon ]]; then
de=$( cinnamon --version )
de=${de:-cinnamon}
elif [[ "${de,,}" =~ xfce ]]; then
de="xfce" # suppression xfce4 ou xfce5 (la version ne sort pas dans xprop ou $XDG_
de=${de:-cinnamon} # si nul, cinnamon
fi
fg_de=${de,,} # minuscule
fg_de=${fg_de^} # car 1 en majuscule
fg_de=${fg_de^} # caractère 1 en majuscule
}
# $fg_nb_disk : nb disk fixe & amovible, $fg_disk_table : tableau sommaire, fg_disk_serial
@ -2552,15 +2554,15 @@ figet_distrib(){ #v 23/11/2017
}
# display manager, assigne $fg_dsp_mngr (liste) ou 'n/a', $fg_dsp_mngr_actif
figet_dm(){ #v1 15/11/2017
figet_dm(){ #v1 25/11/2017
local dm_list="cdm entranced gdm3 gdm qingy kdm ldm lightdm lxdm mdm nodm orthos sddm slim wdm xdm"
local idm ps_aux systemctl x11
local idm ps systemctl x11
fg_dsp_mngr=""
ps_aux=$(ps -auxf)
ps_aux=${ps_aux,,} # tout en minuscules
ps=$(ps -ef) # plus joli pour cmde manuelle ps=$(ps -auxf)
ps=${ps,,} # tout en minuscules
for idm in $dm_list; do
if grep -iq "bin/$idm$" <<< "$ps_aux"; then
# if [ "${ps_aux/*"$idm"*/test}" == "test" ]; then # pb: doublon gdm/gdm3 fun & speed? grepless (remplacement $idm et alentours, si idm présent, valeur test)
if grep -iq "bin/$idm$" <<< "$ps"; then
# if [ "${ps/*"$idm"*/test}" == "test" ]; then # pb: doublon gdm/gdm3 fun & speed? grepless (remplacement $idm et alentours, si idm présent, valeur test)
fg_dsp_mngr+="$idm "
fg_dsp_mngr_actif="$idm"
elif [[ -e /var/run/$idm".pid" || -e /var/run/$idm".pid" || -e /run/$idm || -e /run/$idm || -d /run/$idm/ || -d /var/run/$idm/ ]]; then
@ -2573,7 +2575,7 @@ figet_dm(){ #v1 15/11/2017
x11=$(cat /etc/X11/default-display-manager)
fg_dsp_mngr=${x11##*/} # conservation dernier champs ifs '/'
fi
if [[ -z "$fg_dsp_mngr" && "${ps_aux/*startx*/test}" == "test" ]]; then
if [[ -z "$fg_dsp_mngr" && "${ps/*startx*/test}" == "test" ]]; then
fg_dsp_mngr="(startx)"
fg_dsp_mngr_actif="(startx)"
fi
@ -2932,47 +2934,59 @@ figet_mod_net(){ # thanks wireless-info
}
# assigne $fg_nb_screen, $fg_resolution. return fg_resolution=n/a[ (ssh)] & fg_nb_screen=n/a ou valeurs
figet_screen(){ #v2 21/11/2017
figet_screen(){ #v2 25/11/2017
fg_nb_screen="n/a"
fg_resolution="n/a"
[ "$ENV_SSH" ] && fg_nb_screen+=": ssh"
[ "$ENV_DISPLAY" ] && fg_resolution+=":no Display"
[ "$ENV_SSH" ] && fg_resolution+=":ssh"
[ $( f__which xrandr ) ] || fg_resolution+=":xrandr absent"
[[ "$wayland" && "$EUID" -eq 0 ]] && fg_nb_screen+=": wayland root"
[ $( f__which xdpyinfo ) ] || fg_resolution+=":xdpyinfo absent"
[[ "$wayland" && "$EUID" -eq 0 ]] && fg_resolution+=":wayland root"
[[ "$fg_resolution" =~ : ]] && return 0 # retourne n/a: xprop ou n/a: ssh
[[ "$fg_resolution" =~ : ]] && return 0 # retourne n/a ... toutes les causes dans $fg_resolution
##
# xrandr & et xdpyinfo ne retourne pas de nombre écrans correct (multiplex? hybrid?)
if [ $( f__which xrandr ) ]; then
fg_resolution=$( gawk '/[0-9]\*/ {gsub(/\*\+/,"",$2); printf "%s pixels (%dHz), ", $1, $2}' <<< $( xrandr --query ) )
elif [ $( f__which xdpyinfo ) ]; then
fg_resolution=$( gawk '/dimensions/ { print $2, $3 ", " }' <<< $(xdpyinfo) )
fi
fg_resolution="${fg_resolution%,*}" # suppression ',*'
[ "$(xargs <<< $fg_resolution)" ] || fg_resolution="n/a"
[ "$fg_resolution" != "n/a" ] && fg_nb_screen=$( grep -o 'pixels' <<< $fg_resolution | grep -c . )
[[ "$fg_resolution" =~ n/a ]] || fg_nb_screen=$( grep -o 'pixels' <<< $fg_resolution | grep -c . )
}
figet_shell(){ # thanks neofetch, assigne $fg_shell # 30/10/2017
local shell
shell="${SHELL##*/}"
case "${SHELL##*/}" in
"bash")
shell+=" ${BASH_VERSION/-*}" ;;
"zsh")
shell+="$(zsh --version)"
shell="${shell/ zsh}" ;;
"mksh" | "ksh")
shell+="$("$SHELL" -c 'printf "%s" "$KSH_VERSION"')"
shell="${shell/ * KSH}" ;;
"tcsh" | "csh")
shell+="$("$SHELL" --version)"
shell="${shell/tcsh}"
shell="${shell/\(*}" ;;
"fish")
shell+="$(fish -c 'printf "%s" "$FISH_VERSION"')" ;;
# assigne $fg_shell, $fg_shells
figet_shell(){ #v2 25/11/2017 # thanks neofetch
local shell ish
# shell en cours
fg_shell=${SHELL##*/} # suppression jusqu'au dernier /, pas de chemin
case ${shell:=$fg_shell} in # shell nul, donc assigné avec $fg_shell
bash )
shell+=" ${BASH_VERSION%-*}" # BASH_VERSION: 4.4.12(1)-release, suppression -* final
;;
mksh | ksh )
shell+=" "$( "$SHELL" -c 'printf "%s" "$KSH_VERSION"' )
shell=${shell/ * KSH} # suppression ' * KSH'
shell=${shell/version} # suppression 'version'
;;
* )
shell+=" "$( $SHELL --version 2>/dev/null )
;;
esac
fg_shell="$shell"
shell=${shell/$fg_shell} # suppression ' nomDuShell'
shell=${shell/, version}
shell=${shell/xonsh\//xonsh }
shell=${shell/options*}
shell=${shell/\(*\)}
shell=${shell/ / } # suppression espace double
fg_shell+="$shell"
# shells installés détectés
if [ -e "/etc/shells" ]; then # by-pass sinon soucis sous fedora et openSuse?
for ish in $( f_grep_file "/etc/shells" "nofile" ); do # élimine lignes vides et commentées
fg_shells+=${ish##*/}" " # conservation dernier "champs", ifs '/'
done
fg_shells=${fg_shells% } # suppression espace de fin
fg_shells=$(tr ' ' '\n' <<< $fg_shells | sort -u | tr '\n' ' ') # tri et suppression doublons
else
fg_shells="n/a"
fi
}
figet_test_batt(){ # 20/11/2017
@ -3035,7 +3049,7 @@ figet_test_gpu(){ # 30/10/2017
f_display "fg_gpu" "var" "fg_gpu"
}
figet_test_hw(){ # 20/11/2017
figet_test_hw(){ # 25/11/2017
local text var_temp
# matériel
figet_dmi
@ -3071,7 +3085,7 @@ figet_test_hw(){ # 20/11/2017
fi
f_display "var_temp" "var" "hwmon0/temp1_input à là neofetch"
# fonction script
figet_hw
[ "$fg_hw" ] || figet_hw
f_display "fg_hw" "var" "figet_hw"
}
@ -3125,42 +3139,44 @@ figet_ucode(){ # 24/11/2017
}
# assigne $fg_wm
figet_wm(){ #v 21/11/2017 thanks neofetch
figet_wm(){ #v 25/11/2017 thanks neofetch
local id wm_brut compositor
fg_wm="n/a"
[ $( f__which xprop ) ] || fg_wm+=":xprop absent" # ! pas de xprop, pas de wm?!
[ "$ENV_DISPLAY" ] && fg_wm+=":no Display"
[ "$ENV_SSH" ] && fg_wm+=":ssh"
[ $( f__which xprop ) ] || fg_wm+=": xprop absent"
[[ "$wayland" && "$EUID" -eq 0 ]] && fg_wm+=":wayland root"
[[ "$fg_wm" =~ : ]] && return 0 # retourne n/a: xprop ou n/a: ssh
[[ "$fg_wm" =~ : ]] && return 0 # retourne n/a ...
##
id=$( xprop -root -notype _NET_SUPPORTING_WM_CHECK )
id=${id##* } # suppression plus grande chaîne au début jusqu"à ' '
wm_brut=$( xprop -id "$id" -notype -len 100 -f _NET_WM_NAME 8t )
[ "$debug" ] && echo "$wm_brut"
fg_wm=${wm_brut/*_NET_WM_NAME = } # suppression jusqu'à 'NAME = '
[ "$debug" ] && echo -e "\n$wm_brut\n"
wm_brut=${wm_brut,,} # minuscules
fg_wm=${wm_brut/*_net_wm_name = } # suppression jusqu'à 'name = '
fg_wm=${fg_wm/\"} # suppression premier"
fg_wm=${fg_wm/\"*} # suppression 2e " avec éventuels caractères suivants
# Window Maker does not set _NET_WM_NAME
[[ "$fg_wm" =~ "WINDOWMAKER" ]] && fg_wm="wmaker"
[[ "$fg_wm" =~ "windowmaker" ]] && fg_wm="wmaker"
# Fallback for Wayland wms (sway)
[[ "$fg_wm" == "xwlc" ]] && fg_wm=$( ps -e | grep -m1 -Eo 'sway|orbment|velox|orbital' )
if [[ "$wm_brut" =~ MUTTER_VERSION ]]; then
compositor=${wm_brut/*_MUTTER_VERSION = } # suppression jusqu'à ...
if [[ "$fg_wm" =~ mutter_version ]]; then
compositor=${wm_brut/*_mutter_version = } # suppression jusqu'à ...
compositor=${compositor/\"} # suppression premier"
compositor=${compositor/\"*} # suppression 2e " avec éventuels caractères suivants
compositor="(Mutter version $compositor)"
compositor="(Mutter v$compositor)"
fi
if [[ "$wm_brut" =~ MUFFIN_VERSION ]]; then # en aveugle, jamais vu d'essai
compositor=${wm_brut/*MUFFIN_VERSION = } # suppression jusqu'à ...
if [[ "$fg_wm" =~ muffin_version ]]; then # en aveugle, jamais vu d'essai
compositor=${wm_brut/*muffin_version = } # suppression jusqu'à ...
compositor=${compositor/\"} # suppression premier"
compositor=${compositor/\"*} # suppression 2e " avec éventuels caractères suivants
compositor="(Muffin version $compositor)"
compositor="(Muffin v$compositor)"
fi
if [[ "$wm_brut" =~ MARCO_VERSION ]]; then
compositor=${wm_brut/*_MARCO_VERSION = } # suppression jusqu'à ...
if [[ "${fg_wm,,}" =~ marco_version ]]; then
compositor=${wm_brut/*_marco_version = } # suppression jusqu'à ...
compositor=${compositor/\"} # suppression premier"
compositor=${compositor/\"*} # suppression 2e " avec éventuels caractères suivants
compositor="(Marco version $compositor)"
compositor="(Marco v$compositor)"
fi
[ "$compositor" ] && fg_wm="$fg_wm $compositor"
}
@ -3350,7 +3366,7 @@ fscript_update(){ # 06/11/2017
rm -rf "$dirTemp/"
}
prg_init(){ # 23/11/2017
prg_init(){ # 25/11/2017
PATH='/usr/sbin:/usr/bin:/sbin:/bin'
TERM=xterm
IFS=$' \t\n'
@ -3366,9 +3382,7 @@ prg_init(){ # 23/11/2017
# exec 2>"$script.log" # à tester
# test bash v4
bashVersion=( $( grep -o 'version 4' <<< $( bash --version ) ) )
[ ${bashVersion[1]} -ge 4 ] || f__error "bash v4 requis" \
"version installée: $( grep -m1 'version' <<< $(bash --version) )"
[ "$BASH_VERSINFO" == 4 ] || f__error "bash v4 requis" "version installée: $BASH_VERSION"
# test /proc
[ -e /proc/cpuinfo ] || f__error "/proc/cpuinfo non trouvé" "/proc ne doit pas être monté"
@ -3381,18 +3395,15 @@ prg_init(){ # 23/11/2017
[ "$OS" == "bsd" ] && f__info "ce script pour Linux n'est pas prévu de fonctionner sur BSD..."
[ "$OS" == "windows" ] && f__info "ce script pour Linux n'est pas prévu de fonctionner sous windows..."
[ "$OS" != "linux" ] && f__error "Linux requis"
# recherche wayland
[ "$(ps -ef | grep -c 'wayland')" -gt 1 ] && wayland="wayland"
# essai détection erreur No protocol specified, Can't open display :0 (root Fedora)
if [[ "$wayland" && "$EUID" -eq 0 ]]; then
f__info "Wayland ne permet pas de lancer des applications graphiques en Root" \
"seul l'utilisateur ayant démarré le serveur X peut permettre des connexions à celui-ci" \
"le plus simple est de redémarrer le script en utilisateur pour déterminer certaines propriétés graphiques ou essayer: \n" \
"$GREEN""xhost si:localuser:root$BLUE pour autoriser,$GREEN xhost -si:localuser:root$BLUE pour enlever cette autorisation"
fi
# test SSH
[[ "$SSH_CLIENT" || "$SSH_CLIENT" || "$SSH_CLIENT" ]] && ENV_SSH="ssh"
# test $DISPLAY
[ -z "$DISPLAY" ] && ENV_DISPLAY="no DISPLAY"
# détermination user derrière root
f__user
retourFUser="$?"

View File

@ -3,6 +3,17 @@
* f__wcv, f_display_grep, f_dspl_md, f__wget_test, fscript_get_version, fscript_update
* ! f__requis (debOnly), fscript_install, f__scandir
## 2.45.0 25/11/2017
* nouveau: gestion no $DISPLAY
* révision: version bash en test et affichage
* révision: figet_shell, fi_systeme, shell & shellS
* révision: général, LC_ALL=C oubliés
* révision: figet_wm, fi_graph
* fix: fi_systeme, openSuse uptime
* fix: figet_de, cinnamon
## 2.44.2 24/11/2017
* nouveau: figet_ucode, indépendant de debian