$TITLE

#!/usr/bin/env bash #shellcheck disable=SC2155 #shellcheck source=/dev/null # usr/share/bigbashview/bcc/apps/drivers/index.sh.htm # Description: Detect firmware needed # Created: 2022/02/28 # Altered: 2023/08/18 # # Copyright (c) 2023-2023, Vilmar Catafesta # 2022-2023, Bruno Gonçalves # 2022-2023, Rafael Ruscher # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. APP="${0##*/}" _VERSION_="1.0.0-20230818" LIBRARY=${LIBRARY:-'/usr/share/bigbashview/bcc/shell'} [[ -f "${LIBRARY}/bcclib.sh" ]] && source "${LIBRARY}/bcclib.sh" function sh_config { #Translation export TEXTDOMAINDIR="/usr/share/locale" export TEXTDOMAIN=biglinux-driver-manager declare -g user_drivers="$HOME/.config/bigcontrolcenter-drivers" declare -g CATEGORY=$"Categorias" declare -g CATEGORY_Star=$"Principais" declare -g CATEGORY_Star_Tit=$"Driver detectado:" declare -g CATEGORY_Star_Desc=$"* A detecção não inclui impressoras e scanners" #declare -g CATEGORY_Star_Desc=$"Em uma busca por mais de mil dispositivos que necessitam de drivers ou firmwares complementares foi detectada a compatibilidade deste computador com os seguintes pacotes: #
* A detecção não inclui impressoras e scanners" declare -g CATEGORY_Gpu=$"Placa de vídeo" declare -g CATEGORY_Wifi=$"Wifi" declare -g CATEGORY_Ethernet=$"Rede Cabeada" declare -g CATEGORY_Bluetooth=$"Bluetooth" declare -g CATEGORY_Printer=$"Impressora" declare -g CATEGORY_Printer3D=$"Impressora 3D" declare -g CATEGORY_Scanner=$"Scanner" declare -g CATEGORY_Dvb=$"TV Digital" declare -g CATEGORY_Webcam=$"Webcam" declare -g CATEGORY_Touchscreen=$"Touchscreen" declare -g CATEGORY_Sound=$"Som" #OLD declare -g CATEGORY_Other=$"Outros" #Desativado declare -g SEARCH=$"Pesquisar Driver ou Firmware" declare -g SEARCH_Result=$"Resultado da pesquisa" declare -g TITLE=$"Big-Driver-Manager" declare -g CLOSE=$"Fechar" declare -g OPEN=$"Abrir" declare -g WELCOME=$"Instalar ou Remover Drivers e Firmwares" #declare -g WELCOME_DESC=$"O BigLinux inclui milhares de drivers e firmwares por padrão, porém ainda pode ser necessário instalar mais alguns." } function sh_checkdir { [[ ! -d "$user_drivers" ]] && mkdir -p "$user_drivers" } function sh_init { # Open terminal and install driver ################################# if [ "$install_video_now" != "" ]; then ACTION="install_video_now" DRIVER="$install_video_now" WINDOW_ID="$(xprop -root '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)" urxvt +sb -internalBorder 1 -borderColor rgb:00/22/40 -depth 32 -fg rgb:00/ff/ff -bg rgb:00/22/40 -fn "xft:Ubuntu Mono:pixelsize=18" -embed $(xprop -root '\t$0' _NET_ACTIVE_WINDOW | cut -f 2) -sr -bc -e ./install_terminal.sh fi if [ "$remove_video_now" != "" ]; then ACTION="remove_video_now" DRIVER="$remove_video_now" WINDOW_ID="$(xprop -root '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)" urxvt +sb -internalBorder 1 -borderColor rgb:00/22/40 -depth 32 -fg rgb:00/ff/ff -bg rgb:00/22/40 -fn "xft:Ubuntu Mono:pixelsize=18" -embed $(xprop -root '\t$0' _NET_ACTIVE_WINDOW | cut -f 2) -sr -bc -e ./install_terminal.sh fi if [ "$install_pkg_pamac" != "" ]; then ACTION="install_pkg_pamac" DRIVER="$install_pkg_pamac" WINDOW_ID="$(xprop -root '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)" ./installpkg.sh kdialog --msgbox $"Geralmente é preciso reiniciar o computador para o driver ou firmware ser aplicado." --title $"Driver ou firmware" fi if [ "$remove_pkg_pamac" != "" ]; then ACTION="remove_pkg_pamac" DRIVER="$remove_pkg_pamac" WINDOW_ID="$(xprop -root '\t$0' _NET_ACTIVE_WINDOW | cut -f 2)" ./installpkg.sh fi cat <<-EOF
EOF # Change background when open terminal ###################################### echo "
" echo "
" echo '
' # Loading echo '
' echo '
' cat <<-EOF
EOF echo $"Aplicando - Aguarde" echo $'...' echo '
' echo '
' echo '
' sh_getbgcolor cat <<-EOF
EOF if [ "$(echo $LANG | grep ^he)" != "" ]; then echo '
' else echo '
' fi cat <<-EOF

### $WELCOME

### $CATEGORY_Star_Tit

#### $CATEGORY_Star_Desc

$CATEGORY_Gpu
$CATEGORY_Wifi
$CATEGORY_Ethernet
$CATEGORY_Bluetooth
$CATEGORY_Printer
$CATEGORY_Printer3D
$CATEGORY_Scanner
$CATEGORY_Dvb
$CATEGORY_Webcam
$CATEGORY_Touchscreen
$CATEGORY_Sound
$CATEGORY_Other
EOF OIFS=$IFS IFS=$'\n' ######################### # # Change to "Principais" in start # ######################### echo "
" ./driver-mhwd.sh & rm -f $HOME/.config/bigcontrolcenter-drivers/cache_module_*.html rm -f $HOME/.config/bigcontrolcenter-drivers/cache_firmware_*.html pacman -Qq >"$HOME/.config/bigcontrolcenter-drivers/total_pkgs" rm -f $HOME/.config/bigcontrolcenter-drivers/cache_without_verify* ./driver-without-verify.sh printer & ./driver-without-verify.sh scanner & ################################### # # MHWD import info CLOSE # ################################### SHOW_MODULE() { # $PKG # $MODULE # $NAME # $ID # $CATEGORY # $MODULE_COMPATIBLE # $MODULE_LOADED # $PKG_INSTALLED if [ "$MODULE_COMPATIBLE" = "true" ]; then DRIVER_COMPATIBLE=$"Este driver parece compatível com este computador." else DRIVER_COMPATIBLE=$"" fi if [ "$PKG_INSTALLED" = "true" ]; then PKG_INSTALLED_OR_NOT=$"Remover" INSTALL_OR_REMOVE_PKG="remove_pkg_pamac" BUTTON_COLOR="remove-button" DISABLE_SIMPLE="Simple" if [ "$(echo "$PKG" | grep kernel-)" != "" ]; then INSTALL_OR_REMOVE_PKG="remove_video_now" DISABLE_SIMPLE="" PKG="$(echo "$PKG" | sed 's|kernel-|network-|g')" fi else PKG_INSTALLED_OR_NOT=$"Instalar" INSTALL_OR_REMOVE_PKG="install_pkg_pamac" BUTTON_COLOR="" DISABLE_SIMPLE="Simple" if [ "$(echo "$PKG" | grep kernel-)" != "" ]; then INSTALL_OR_REMOVE_PKG="install_video_now" DISABLE_SIMPLE="" PKG="$(echo "$PKG" | sed 's|kernel-|network-|g')" fi fi cat <<-EOF >>"$HOME/.config/bigcontrolcenter-drivers/cache_module_$PKG.html"
$MODULE
$DESC $DRIVER_COMPATIBLE
$PKG_INSTALLED_OR_NOT
EOF } ################################### # # Other modules from BigLinux Scripts, using PCI # OPEN # ################################### # PCI PCI_LIST="$(grep -Ri : device-ids/ | grep -i 'pci.ids')" # Result example from list # device-ids/r8101/pci.ids:10EC:8136 PCI_IN_PC="$(lspci -nn | cut -f2- -d" ")" PCI_LIST_MODULES="$(echo "$PCI_LIST" | cut -f2 -d/ | sort -u)" for MODULE in $PCI_LIST_MODULES; do ID_LIST="$(echo "$PCI_LIST" | grep -i "/$MODULE/" | rev | cut -f1,2 -d: | rev)" CATEGORY="$(cat device-ids/$MODULE/category)" PKG="$(cat device-ids/$MODULE/pkg)" DESC="$(cat device-ids/$MODULE/description)" MODULE_COMPATIBLE="false" for i in $ID_LIST; do if [ "$(echo "$PCI_IN_PC" | grep -i "$i")" != "" ]; then NAME="$(echo "$PCI_IN_PC" | grep -i "$ID" | cut -f2- -d" ")" MODULE_COMPATIBLE="true" CATEGORY="$CATEGORY Star" fi done if [ "$(lsmod | cut -f1 -d" " | grep -i "^$MODULE$")" != "" ]; then MODULE_LOADED="true" else MODULE_LOADED="false" fi if [ "$(grep -i ^$PKG$ $HOME/.config/bigcontrolcenter-drivers/total_pkgs)" != "" ]; then PKG_INSTALLED="true" else PKG_INSTALLED="false" fi # echo "Device: $NAME" # echo "ID: $ID" # echo "MODULE: $MODULE" # echo "PKG: $PKG" SHOW_MODULE "$PKG" "$MODULE" "$NAME" "$ID" "$CATEGORY" "$MODULE_COMPATIBLE" "$MODULE_LOADED" "$PKG_INSTALLED" "$DESC" & done ################################### # # Other modules from BigLinux Scripts, using PCI # CLOSE # ################################### ################################### # # Other modules from BigLinux Scripts, using USB # OPEN # ################################### # USB USB_LIST="$(grep -Ri : device-ids/ | grep -i 'usb.ids')" # Result example from list # device-ids/r8188eu/usb.ids:2001:331B USB_IN_PC="$(lsusb | cut -f6- -d" ")" USB_LIST_MODULES="$(echo "$USB_LIST" | cut -f2 -d/ | sort -u)" for MODULE in $USB_LIST_MODULES; do ID_USB_LIST="$(echo "$USB_LIST" | grep -i "/$MODULE/" | rev | cut -f1,2 -d: | rev)" CATEGORY="$(cat device-ids/$MODULE/category)" PKG="$(cat device-ids/$MODULE/pkg)" DESC="$(cat device-ids/$MODULE/description)" MODULE_COMPATIBLE="false" for i in $ID_USB_LIST; do if [ "$(echo "$USB_IN_PC" | grep -i "$i")" != "" ]; then NAME="$(echo "$USB_IN_PC" | grep -i "$ID" | cut -f2- -d" ")" MODULE_COMPATIBLE="true" CATEGORY="$CATEGORY Star" fi done if [ "$(lsmod | cut -f1 -d" " | grep -i "^$MODULE$")" != "" ]; then MODULE_LOADED="true" else MODULE_LOADED="false" fi if [ "$(grep -i ^$PKG$ $HOME/.config/bigcontrolcenter-drivers/total_pkgs)" != "" ]; then PKG_INSTALLED="true" else PKG_INSTALLED="false" fi SHOW_MODULE "$PKG" "$MODULE" "$NAME" "$ID" "$CATEGORY" "$MODULE_COMPATIBLE" "$MODULE_LOADED" "$PKG_INSTALLED" "$DESC" & done ################################### # # Other modules from BigLinux Scripts, using USB # CLOSE # ################################### ################################### # # Other modules from BigLinux Scripts, using SDIO # OPEN # ################################### # SDIO SDIO_LIST="$(grep -Ri : device-ids/ | grep -i 'sdio.ids')" # Result example from list # device-ids/r8188eu/sdio.ids:2001:331B rm -f /tmp/sdio_devices.txt for Sdio in $(ls /sys/bus/sdio/devices/ 2>/dev/null); do Vendor="$(cat /sys/bus/sdio/devices/$Sdio/vendor | cut -f2 -dx)" Device="$(cat /sys/bus/sdio/devices/$Sdio/device | cut -f2 -dx)" echo "$Vendor:$Device" >>/tmp/sdio_devices.txt done SDIO_IN_PC="$(cat /tmp/sdio_devices.txt)" SDIO_LIST_MODULES="$(echo "$SDIO_LIST" | cut -f2 -d/ | sort -u)" for MODULE in $SDIO_LIST_MODULES; do ID_SDIO_LIST="$(echo "$SDIO_LIST" | grep -i "/$MODULE/" | rev | cut -f1,2 -d: | rev)" CATEGORY="$(cat device-ids/$MODULE/category)" PKG="$(cat device-ids/$MODULE/pkg)" DESC="$(cat device-ids/$MODULE/description)" MODULE_COMPATIBLE="false" for i in $ID_SDIO_LIST; do if [ "$(echo "$SDIO_IN_PC" | grep -i "$i")" != "" ]; then NAME="$(echo "$SDIO_IN_PC" | grep -i "$ID" | cut -f2- -d" ")" MODULE_COMPATIBLE="true" CATEGORY="$CATEGORY Star" fi done if [ "$(lsmod | cut -f1 -d" " | grep -i "^$MODULE$")" != "" ]; then MODULE_LOADED="true" else MODULE_LOADED="false" fi if [ "$(grep -i ^$PKG$ $HOME/.config/bigcontrolcenter-drivers/total_pkgs)" != "" ]; then PKG_INSTALLED="true" else PKG_INSTALLED="false" fi SHOW_MODULE "$PKG" "$MODULE" "$NAME" "$ID" "$CATEGORY" "$MODULE_COMPATIBLE" "$MODULE_LOADED" "$PKG_INSTALLED" "$DESC" & done ################################### # # Other modules from BigLinux Scripts, using SDIO # CLOSE # ################################### SHOW_FIRMWARE() { # $MODULE_NEED_FIRMWARE # $CATEGORY # $FIRMWARE_COMPATIBLE # $PKG_INSTALLED if [ "$FIRMWARE_COMPATIBLE" = "true" ]; then FIRMWARE_COMPATIBLE_MSG=$"Este pacote fornece arquivos compatíveis com este computador." else FIRMWARE_COMPATIBLE_MSG="" fi if [ "$PKG_INSTALLED" = "true" ]; then PKG_INSTALLED_OR_NOT=$"Remover" INSTALL_OR_REMOVE_PKG="remove_pkg_pamac" BUTTON_COLOR="remove-button" else PKG_INSTALLED_OR_NOT=$"Instalar" INSTALL_OR_REMOVE_PKG="install_pkg_pamac" BUTTON_COLOR="" fi cat <<-EOF >>"$HOME/.config/bigcontrolcenter-drivers/cache_firmware_$PKG.html"
$PKG
$DESC $FIRMWARE_COMPATIBLE_MSG $LIST_FIRMWARES
$PKG_INSTALLED_OR_NOT
EOF } ################################### # # Other modules from BigLinux Scripts, using Firmware # OPEN # ################################### # Firmware # Result example from list # firmware/zd1211-firmware/zd1211-firmware:/usr/lib/firmware/zd1211/zd1211_uph FIRMWARE_MISSING="$(dmesg | grep -i firmware | grep -i error | grep -i loading | cut -f2 -d] | cut -f2,5 -d" ")" FIRMWARE_LIST_PKGS="$(ls firmware)" for PKG in $FIRMWARE_LIST_PKGS; do CATEGORY="$(cat firmware/$PKG/category)" DESC="$(cat firmware/$PKG/description)" LIST_FIRMWARES="$(sed 's|.*/|
|g' firmware/$PKG/$PKG)" FIRMWARE_COMPATIBLE="false" for i in $FIRMWARE_MISSING; do if [ "$(grep -i "$i" firmware/$PKG/$PKG)" != "" ]; then MODULE_NEED_FIRMWARE="$(echo "$FIRMWARE_MISSING" | cut -f1 -d" ")" FIRMWARE_COMPATIBLE="true" CATEGORY="$CATEGORY Star" fi done if [ "$(grep -i ^$PKG$ $HOME/.config/bigcontrolcenter-drivers/total_pkgs)" != "" ]; then PKG_INSTALLED="true" else PKG_INSTALLED="false" fi SHOW_FIRMWARE "$PKG" "$MODULE_NEED_FIRMWARE" "$ID" "$CATEGORY" "$FIRMWARE_COMPATIBLE" "$PKG_INSTALLED" "$DESC" "$LIST_FIRMWARES" & done ################################### # # Other modules from BigLinux Scripts, using Firmware # CLOSE # ################################### wait cat $HOME/.config/bigcontrolcenter-drivers/cache_video_*.html cat $HOME/.config/bigcontrolcenter-drivers/cache_module_*.html cat $HOME/.config/bigcontrolcenter-drivers/cache_firmware_*.html cat $HOME/.config/bigcontrolcenter-drivers/cache_without_verify_installed_*.html cat $HOME/.config/bigcontrolcenter-drivers/cache_without_verify_not_installed_*.html cat <<-EOF
EOF IFS=$OIFS } #sh_debug sh_config sh_checkdir sh_init