#!/bin/bash
#
# PiKISS (Pi Keeping simple, stupid!)
#
# Author  : Jose Cerrejon Gonzalez
# Mail    : ulysess@gmail_dot_com
# Version : Check VERSION variable
#
# shellcheck source=./scripts/helper.sh
. ./scripts/helper.sh || . ../helper.sh || . ./helper.sh || wget -q 'https://github.com/jmcerrejon/PiKISS/raw/master/scripts/helper.sh'
clear
check_board || { echo "Missing file helper.sh. I've tried to download it for you. Try to run the script again." && exit 1; }

VERSION="v.1.13.0"
IP=$(get_ip)
PI_VERSION_NUMBER=$(get_pi_version_number)
ARCHITECTURE=$(getconf LONG_BIT)
CPU_FREQUENCY=$(get_cpu_frequency)
TITLE="PiKISS (Pi Keeping It Simple, Stupid!) ${VERSION} | ${ARCHITECTURE} Bits | ${IP} | ${MODEL} ${PI_VERSION_NUMBER} (${CPU_FREQUENCY} Mhz)"
CHK_UPDATE=0
CHK_PIKISS_UPDATE=0
NOINTERNETCHECK=0
wHEIGHT=20
wWIDTH=90
check_board
check_temperature
make_desktop_entry
remove_unneeded_helper

usage() {
    echo -e "$TITLE\n\nScript designed to config or install apps on Raspberry Pi easier for everyone.\n"
    echo -e "Usage: ./piKiss.sh [Arguments]\n\nArguments:\n"
    echo "-h   | --help             : This help."
    echo "-nu  | --no-update        : No check if repositories are updated."
    echo "-nup | --no-update-pikiss : No check if PiKISS are updated."
    echo "-ni  | --noinet           : No check if internet connection is available."
    echo
    echo "For trouble, ideas or technical support please visit https://github.com/jmcerrejon/PiKISS"
}

#
# Initial checks
#

# Arguments
while [ "$1" != "" ]; do
    case $1 in
    -nu | --no_update)
        export CHK_UPDATE=1
        ;;
    -nup | --no_update-pikiss)
        export CHK_PIKISS_UPDATE=1
        ;;
    -ni | --noinet)
        export NOINTERNETCHECK=1
        ;;
    -h | --help)
        usage
        exit
        ;;
    *)
        usage
        exit 1
        ;;
    esac
    shift
done

is_missing_dialog_pkg
check_internet_available
check_update_pikiss

#
# Menus
#

smInfo() {
    cmd=(dialog --clear --backtitle "$TITLE" --title "[ Info ]" --menu "Select an option from the list:" "$wHEIGHT" "$wWIDTH" "$wHEIGHT")

    options=(
        Back "Back to main menu"
        Weather "Weather info from your country"
        Chkimg "Check some distros images to know if they are updated"
        Webmin "Monitoring tool"
        Bmark "Benchmark RPi (CPU, MEM, SD Card...)"
        Lynis "Lynis is a security auditing tool."
        TestInet "Test Internet bandwidth"
        WebMonitor "Web monitor to your RPi"
    )

    choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)

    for choice in $choices; do
        case $choice in
        Back) break ;;
        Chkimg) ./scripts/info/check_lastmod_img.sh ;;
        Webmin) ./scripts/info/webmin.sh ;;
        Weather) ./scripts/info/weather.sh ;;
        Bmark) ./scripts/info/bmark.sh ;;
        Lynis) ./scripts/info/lynis.sh ;;
        TestInet) ./scripts/info/test_inet.sh ;;
        WebMonitor) ./scripts/info/web_monitor.sh ;;
        esac
    done
}

smTweaks() {
    cmd=(dialog --clear --backtitle "$TITLE" --title "[ Tweaks ]" --menu "Select a tweak from the list:" "$wHEIGHT" "$wWIDTH" "$wHEIGHT")

    options=(
        Back "Back to main menu"
        Others "CPU performance, disable Ethernet and so on"
        Packages "Programs you don't use (maybe) to free space"
        Daemons "Disable useless services"
        ZRAM "Enable/Disable ZRAM"
    )

    choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)

    for choice in $choices; do
        case $choice in
        Back) break ;;
        Others) ./scripts/tweaks/others.sh ;;
        Packages) ./scripts/tweaks/removepkg.sh ;;
        Daemons) ./scripts/tweaks/services.sh ;;
        ZRAM) ./scripts/tweaks/zram.sh ;;
        esac
    done
}

smGames() {
    if is_userspace_64_bits; then
        show_dialog_only_32_bits "2Ship2Harkinian, Abbaye, AVP, Arx, Blood, Blake Stone, Captain S, Carmageddon, Doom_engine, Dominatrix (Sin), DX-Rebirth, Dune2, Diablo, EDuke32, Fallout 2, GTA, GemRB, Half Life, Hexen 2, OpenClaw, OpenFodder, Portal, Quake I-II-III, RVGL (Re-Volt), SMario64, Serious Sam, SpaceCadetPinball, OpenXCom, Unreal Tournament, VVVVVV, WipeOut"
    fi
    cmd=(dialog --clear --backtitle "$TITLE" --title "[ Games ]" --menu "Select game from the list:" "$wHEIGHT" "$wWIDTH" "$wHEIGHT")

    options=(
        Back "Back to main menu"
        2Ship2Harkinian "Free port of The Legend of Z3lda: Ocarina of Time."
        Abbaye "L’Abbaye des Morts is a retro puzzle platformer by Locomalito"
        AVP "Aliens versus Predator is a 1999 SF fps published by Fox Interactive"
        Arx "Arx Fatalis is a fps RPG set on a world whose sun has failed"
        Blood "Blood is a fps game developed by Monolith Productions"
        BStone "Robert W. Stone III, AKA Blake Stone must eliminate Dr. Pyrus Goldfire"
        CaptainS "Save Seville from the evil Torrebruno"
        Carmageddon "Carmageddon is a vehicular combat game"
        Doom_engine "Crispy engine to play Doom, Heretic, Hexen..."
        Dominatrix "Dominatrix is the open-source game Sin Gold Edition"
        DX-Rebirth "Descent I/II improved engine"
        Dune2 "Dune 2 Legacy"
        Diablo "Take control of a lone hero battling to rid the world of Diablo"
        Diablo2 "Diablo 2 Lord of Destruction"
        Eduke32 "Duke Nukem 3D is a fps game developed by 3D Realms"
        Fallout2 "Fallout 2 is a post-apocalyptic RPG"
        GTA "GTA III/Vice City are open worlds video games part of the GTA franchise"
        GemRB "Engine for games like Baldur's Gate"
        HalfLife "Gordon Freeman must exit Black Mesa after it's invaded by aliens"
        Heroes2 "Free implementation of Heroes of Might and Magic II engine"
        Heroes3 "Open-source engine for Heroes of Might and Magic III"
        Hexen2 "Hexen II is a dark fantasy 1st shooter and RPG"
        Hurrican "Jump and shoot game based on the Turrican game series"
        Morrowind "The Elder Scrolls III: Morrowind is an open-world RPG"
        OpenBor "OpenBOR is the open source continuation of Beats of Rage"
        OpenClaw "Platform 2D Captain Claw (1997) reimplementation"
        OpenFodder "OpenFodder is a free reimplementation of Cannon Fodder games."
        OpenJK "Engine for Star Wars Jedi Knight: Jedi Academy (SP & MP)"
        OpenRCT2 "Open Source re-implementation of RollerCoaster Tycoon 2"
        OpenSPlex "OpenSupaplex reimplementation of the original 90's game"
        OpenXCom "Open-source clone of UFO: Enemy Unknown"
        Prince "port/conversion of the DOS game Prince of Persia"
        Portal "Players must solve puzzles by opening portals and moving objects"
        Quake "Enhanced clients for ID Software's Quake saga"
        ReturnC "The dark reich's closing in. The time to act is now"
        RVGL "Re-Volt is a radio control car racing themed video game"
        SWarrior "FPS developed by 3D Realms and released on 1997 by GT Interactive"
        SMario64 "Super Mario 64 EX native OpenGL ES"
        SMarioWar "The game centers on players fighting each other"
        Space3D "Space Cadet 3D Pinball is a re-implementation of the original game"
        SpelunkyHD "Spelunky is a cave exploration/treasure-hunting game"
        Sqrxz4 "Sqrxz 4: Difficult platform game"
        Srb2 "3D platformer fangame based on the Sonic the Hedgehog series"
        SSam12 "Serious Sam I & II. Kill all walking monster"
        StarCraft "Expansion pack for the real-time strategy video game StarCraft"
        StepMania "StepMania is a free dance and rhythm game"
        Temptations "Platform game made exclusively for MSX computers"
        UT99 "Unreal Tournament 99 is a fps using Unreal Engine"
        VVVVVV "Minimalist platformer: instead of jumping, you need to reverse gravity"
        WipeOut "re-implementation of the 1995 PSX game wipEout"
        Xump "Xump: Simple multi-platform puzzler"
    )

    choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)

    for choice in $choices; do
        case $choice in
        Back) break ;;
        2Ship2Harkinian) ./scripts/games/2Ship2Harkinian.sh ;;
        Abbaye) ./scripts/games/abbaye.sh ;;
        AVP) ./scripts/games/avp.sh ;;
        Arx) ./scripts/games/arx.sh ;;
        Blood) ./scripts/games/blood.sh ;;
        BStone) ./scripts/games/bstone.sh ;;
        CaptainS) ./scripts/games/captains.sh ;;
        Carmageddon) ./scripts/games/carmageddon.sh ;;
        Doom_engine) ./scripts/games/cdoom.sh ;;
        Dominatrix) ./scripts/games/dominatrix.sh ;;
        DX-Rebirth) ./scripts/games/descent.sh ;;
        Dune2) ./scripts/games/dune2.sh ;;
        Diablo) ./scripts/games/diablo.sh ;;
        Diablo2) ./scripts/games/diablo2.sh ;;
        Eduke32) ./scripts/games/eduke32.sh ;;
        Fallout2) ./scripts/games/fallout.sh ;;
        GTA) ./scripts/games/gta.sh ;;
        GemRB) ./scripts/games/gemrb.sh ;;
        HalfLife) ./scripts/games/half-life.sh ;;
        Heroes2) ./scripts/games/heroes2.sh ;;
        Heroes3) ./scripts/games/heroes3.sh ;;
        Hexen2) ./scripts/games/hexen2.sh ;;
        Hurrican) ./scripts/games/hurrican.sh ;;
        Morrowind) ./scripts/games/openmw.sh ;;
        OpenBor) ./scripts/games/openbor.sh ;;
        OpenClaw) ./scripts/games/openclaw.sh ;;
        OpenFodder) ./scripts/games/openfodder.sh ;;
        OpenJK) ./scripts/games/openjk.sh ;;
        OpenRCT2) ./scripts/games/openrct2.sh ;;
        OpenSPlex) ./scripts/games/supaplex.sh ;;
        OpenXCom) ./scripts/games/openxcom.sh ;;
        Prince) ./scripts/games/princeofp.sh ;;
        Portal) ./scripts/games/portal.sh ;;
        Quake) ./scripts/games/quake.sh ;;
        ReturnC) ./scripts/games/rwolf.sh ;;
        RVGL) ./scripts/games/rvgl.sh ;;
        SWarrior) ./scripts/games/swarrior.sh ;;
        SMario64) ./scripts/games/smario64.sh ;;
        SMarioWar) ./scripts/games/smariowar.sh ;;
        Space3D) ./scripts/games/space_cadet.sh ;;
        SpelunkyHD) ./scripts/games/spelunky.sh ;;
        Sqrxz4) ./scripts/games/sqrxz4.sh ;;
        Srb2) ./scripts/games/srb2.sh ;;
        SSam12) ./scripts/games/ssam.sh ;;
        StarCraft) ./scripts/games/starcraft.sh ;;
        StepMania) ./scripts/games/stepmania.sh ;;
        Temptations) ./scripts/games/temptations.sh ;;
        UT99) ./scripts/games/unrealt.sh ;;
        VVVVVV) ./scripts/games/vvvvvv.sh ;;
        WipeOut) ./scripts/games/wipeout.sh ;;
        Xump) ./scripts/games/xump.sh ;;
        esac
    done
}

smEmulators() {
    if is_userspace_64_bits; then
        show_dialog_only_32_bits "Amiga, Amstrad, Box86/64, Dolphin, Flycast, DOSBox, Mame, mGBA, Picodrive (Genesis), PCem, PS1, PS2, PSP, RetroArch, Redream, ScummVM, USP (Spectrum), VICE"
    fi
    cmd=(dialog --clear --backtitle "$TITLE" --title "[ Emulators ]" --menu "Select emulator from the list:" "$wHEIGHT" "$wWIDTH" "$wHEIGHT")

    options=(
        Back "Back to main menu"
        Amiga "Amiberry is the best Amiga emulator"
        Amstrad "Caprice32 is an Amstrad CPC emulator"
        Box86-64 "Let's you run x86/64 Linux programs on non-x86/64 Linux"
        Dolphin "Dolphin is a Wii & Gamecube emulator"
        DOSBox "DOSBox-X is a DOS emulator with GUI"
        Flycast "Sega Dreamcast,Naomi,Naomi 2 and Atomiswave emu"
        mGBA "Gameboy Advance (mgba)"
        Genesis "Genesis Megadrive Emulator (picodrive)"
        Mednafen "Portable multi-system emulator (Mednafen)"
        Mame "MAME is a multi-system emulator"
        MSX "OpenMSX"
        NES "Nestopia UE is an accurate NES emulator"
        Pifba "Emulates old arcade games using CPS1, CPS2,..."
        PCem "PCem is an emulator for old XT/AT-class PCs"
        PS1 "DuckStation - PlayStation 1, aka. PSX Emulator"
        PS2 "AetherSX2 is an emulator of the PS Two console"
        PSP "PPSSPP can run your PSP games on your RPi in full HD resolution"
        ResidualVM "Cross-platform 3D game interpreter to play some games"
        RetroArch "Open source frontend for emulators & game/video engines"
        Redream "Redream is a Dreamcast emulator"
        ScummVM "Allow gamers to play point-and-click adventure games"
        Snes "SNES Emulator Snes9X or Bsnes"
        VICE "Commodore 64 emulator"
        USP "Speccy (USP) is a ZX-Spectrum emulator"
    )

    choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)

    for choice in $choices; do
        case $choice in
        Back) break ;;
        Amiga) ./scripts/emus/amiga.sh ;;
        Box86-64) ./scripts/emus/box86_64.sh ;;
        Amstrad) ./scripts/emus/amstrad.sh ;;
        Dolphin) ./scripts/emus/dolphin.sh ;;
        Flycast) ./scripts/emus/flycast.sh ;;
        DOSBox) ./scripts/emus/msdos.sh ;;
        mGBA) ./scripts/emus/gba.sh ;;
        Genesis) ./scripts/emus/genesis.sh ;;
        Mednafen) ./scripts/emus/mednafen.sh ;;
        Mame) ./scripts/emus/mame.sh ;;
        MSX) ./scripts/emus/openmsx.sh ;;
        NES) ./scripts/emus/nes.sh ;;
        PS1) ./scripts/emus/psx.sh ;;
        PS2) ./scripts/emus/ps2.sh ;;
        PSP) ./scripts/emus/psp.sh ;;
        Pifba) ./scripts/emus/pifba.sh ;;
        PCem) ./scripts/emus/pcem.sh ;;
        ResidualVM) ./scripts/emus/residual.sh ;;
        RetroArch) ./scripts/emus/retroarch.sh ;;
        Redream) ./scripts/emus/redream.sh ;;
        ScummVM) ./scripts/emus/scummvm.sh ;;
        Snes) ./scripts/emus/snes.sh ;;
        USP) ./scripts/emus/speccy.sh ;;
        VICE) ./scripts/emus/commodore.sh ;;
        esac
    done
}

smMultimedia() {
    if is_userspace_64_bits; then
        show_dialog_only_32_bits "OBS"
    fi
    cmd=(dialog --clear --backtitle "$TITLE" --title "[ Multimedia ]" --menu "Select a script from the list:" "$wHEIGHT" "$wWIDTH" "$wHEIGHT")

    options=(
        Back "Back to main menu"
        JELLYFIN "Stream media to any device from your own server"
        Kodi "Kodi is a free media player that is designed to look great on your TV but is just as home on a small screen."
        Kiosk "Image slideshow"
        Moonlight "Moonlight PC is an open source implementation of NVIDIA's GameStream"
        Spotube "Spotify clone"
        TV "CLI TV Player: Spain and International"
        OBS "Free & open source software 4 video recording and streaming"
    )

    choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)

    for choice in $choices; do
        case $choice in
        Back) break ;;
        JELLYFIN) ./scripts/mmedia/jellyfin.sh ;;
        Kodi) ./scripts/mmedia/xbmc.sh ;;
        Kiosk) ./scripts/mmedia/kiosk.sh ;;
        Moonlight) ./scripts/mmedia/moonlight-qt.sh ;;
        Spotube) ./scripts/mmedia/spotube.sh ;;
        TV) ./scripts/mmedia/tvplayer.sh ;;
        OBS) ./scripts/mmedia/obs.sh ;;
        esac
    done
}

smConfigure() {
    cmd=(dialog --clear --backtitle "$TITLE" --title "[ Configure ]" --menu "Select to configure your distro:" "$wHEIGHT" "$wWIDTH" "$wHEIGHT")

    options=(
        Back "Back to main menu"
        Vulkan "Compile/update Vulkan Mesa driver"
        SSIDCfg "Configure SSID (WPA/WPA2 with PSK)"
        Joypad "Configure WII, XBox360 controller"
        Backup "Simple backup dir to run daily"
        # Applekeyb "Bluetooth keyboard"
        Netcfg "Configure static IP"
        Monitorcfg "Configure your TV resolution"
    )

    choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)

    for choice in $choices; do
        case $choice in
        Back) break ;;
        Vulkan) ./scripts/config/vulkan.sh ;;
        SSIDCfg) ./scripts/config/ssidcfg.sh ;;
        Joypad) ./scripts/config/jpad.sh ;;
        Backup) ./scripts/config/backup.sh ;;
        Applekeyb) ./scripts/config/applekeyb.sh ;;
        Netcfg) ./scripts/config/netconfig.sh ;;
        Monitorcfg) ./scripts/config/monitorcfg.sh ;;
        esac
    done
}

smInternet() {
    cmd=(dialog --clear --backtitle "$TITLE" --title "[ Internet ]" --menu "Select an option from the list:" "$wHEIGHT" "$wWIDTH" "$wHEIGHT")

    options=(
        Back "Back to main menu"
        Plowshare "Direct download from hosters like uploaded,..."
        SyncTERM "BBS terminal program"
        nChat "Use WhatsApp/Telegram on Terminal"
        Zoom "i386 version of software platform used for teleconferencing using Box86"
    )

    choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)

    for choice in $choices; do
        case $choice in
        Back) break ;;
        Plowshare) ./scripts/inet/ddown.sh ;;
        SyncTERM) ./scripts/inet/syncterm.sh ;;
        nChat) ./scripts/inet/nchat.sh ;;
        Zoom) ./scripts/inet/zoom.sh ;;
        esac
    done
}

smServer() {
    cmd=(dialog --clear --backtitle "$TITLE" --title "[ Server ]" --menu "Select to configure your distro as a server:" "$wHEIGHT" "$wWIDTH" "$wHEIGHT")

    options=(
        Back "Back to main menu"
        AdBlock "Turn Raspberry Pi into an Ad blocker with Pi-Hole"
        BlockIPs "Block access attempts to your Pi connected to the Internet"
        Cups "Printer server (cups)"
        DB "Install MariaDB"
        FTP "Simple FTP Server with vsftpd"
        FWork "WordPress, Node.js among others"
        GitServer "Use your RPi as a Git Server"
        Jenkins "Jenkins is a free and open source automation server"
        LEMP "Stack stands for Linux+NGinx+MariaDB+PHP"
        Minidlna "Install/Compile UPnP/DLNA Minidlna"
        Nagios "Nagios is a network host and service monitoring"
        OctoPrint "Control your 3D-Printer"
        RDesktop "Connect to your Raspberry Pi throught VNC,..."
        Smtp "SMTP Config to send e-mail"
        SMB "Share files with SAMBA"
        Upd "keep Debian patched with latest security updates"
        VPNServer "OpenVPN setup and config thanks to pivpn.io"
        Web "Web server"
        WebDAV "WebDAV to share local content with Apache"
    )

    choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)

    for choice in $choices; do
        case $choice in
        Back) break ;;
        AdBlock) ./scripts/server/adblock.sh ;;
        BlockIPs) sudo ./scripts/server/block-ips.sh ;;
        Cups) ./scripts/server/printer.sh ;;
        DB) ./scripts/server/db.sh ;;
        FTP) ./scripts/server/ftp.sh ;;
        FWork) ./scripts/server/fwork.sh ;;
        GitServer) ./scripts/server/gitserver.sh ;;
        Jenkins) ./scripts/server/jenkins.sh ;;
        LEMP) ./scripts/server/lemp.sh ;;
        Minidlna) ./scripts/server/mediaserver.sh ;;
        Nagios) ./scripts/server/nagios.sh ;;
        OctoPrint) ./scripts/server/octoprint.sh ;;
        RDesktop) ./scripts/server/rdesktop.sh ;;
        Smtp) ./scripts/server/smtp.sh ;;
        SMB) ./scripts/server/fileserver.sh ;;
        Upd) ./scripts/server/auto-upd.sh ;;
        VPNServer) ./scripts/server/openvpn.sh ;;
        Web) ./scripts/server/web.sh ;;
        WebDAV) ./scripts/server/webdav.sh ;;
        esac
    done
}

smDevs() {
    cmd=(dialog --clear --backtitle "$TITLE" --title "[ Developers ]" --menu "Select to configure some apps for development:" "$wHEIGHT" "$wWIDTH" "$wHEIGHT")

    options=(
        Back "Back to main menu"
        Docker "Docker use OS-level virtualization to deliver containers"
        Gemini-CLI "Brings the power of Gemini directly into your terminal"
        QT5 "Free and open-source toolkit for creating GUI cross-platform apps"
        SQLiteStudio "SQLiteStudio is a SQLite database manager"
        TIC80 "TIC-80 is a free fantasy computer for making, playing tiny games"
        VSCode/ium "Powerful source code editor developed by Microsoft"
    )

    choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)

    for choice in $choices; do
        case $choice in
        Back) break ;;
        Docker) ./scripts/devs/docker.sh ;;
        Gemini-CLI) ./scripts/devs/gemini-cli.sh ;;
        QT5) ./scripts/devs/qt5.sh ;;
        SQLiteStudio) ./scripts/devs/sqlitestudio.sh ;;
        TIC80) ./scripts/devs/tic-80.sh ;;
        VSCode/ium) ./scripts/devs/vscode.sh ;;
        esac
    done
}

smOthers() {
    cmd=(dialog --clear --backtitle "$TITLE" --title "[ Others ]" --menu "Another scripts uncategorized:" "$wHEIGHT" "$wWIDTH" "$wHEIGHT")

    options=(
        Back "Back to main menu"
        Aircrack "Compile Aircrack-NG suite easily"
        Alacritty "Fastest terminal emulator using GPU for rendering and Wayland compatible"
        BootLoader "Update your RPi boot loader"
        Fixes "Fix some problems with the Raspberry Pi OS"
        GL4ES "Compile GL4ES - OpenGL for GLES Hardware"
        Metasploit "The world’s most used penetration testing framework"
        Part "Check issues & fix SD corruptions"
        Scrcpy "Display and control of Android devices connected on USB"
        SDL2 "Compile SDL2 + Libraries"
        ShaderToy "Render over 100+ OpenGL ES 3.0 shaders"
        Synergy "Allow you to share keyboard and mouse to computers on LAN"
        Uninstall "Uninstall PiKISS :_("
        UxPlay "An open-source implementation of an AirPlay mirroring server"
        Wine "Wine is a compatibility layer capable of running Windows apps"
        Zsh "Install Z Shell"
    )

    choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)

    for choice in $choices; do
        case $choice in
        Back) break ;;
        Aircrack) ./scripts/others/aircrack.sh ;;
        Alacritty) ./scripts/others/alacritty.sh ;;
        BootLoader) ./scripts/others/update-bootloader.sh ;;
        Fixes) ./scripts/others/fixes.sh ;;
        GL4ES) ./scripts/others/gl4es.sh ;;
        Metasploit) ./scripts/others/metasploit.sh ;;
        Part) ./scripts/others/checkpart.sh ;;
        Scrcpy) ./scripts/others/scrcpy.sh ;;
        SDL2) ./scripts/others/sdl2.sh ;;
        ShaderToy) ./scripts/others/shadertoy.sh ;;
        Synergy) ./scripts/others/synergy.sh ;;
        Uninstall) uninstall_pikiss ;;
        UxPlay) ./scripts/others/uxplay.sh ;;
        Wine) ./scripts/others/wine86.sh ;;
        Zsh) ./scripts/others/zsh.sh ;;
        esac
    done
}

show_dialog_only_32_bits() {
    local MESSAGE="This section has partial 64-Bit support.\nScripts availables: $1."

    if [[ -z "$1" ]]; then
        MESSAGE='Apologies!. PiKISS only works on 32 Bits OS.\n64 Bits support in progress...'
    fi

    dialog --title "[ 64BIT OS DETECTED! ]" --msgbox "$MESSAGE" 15 52
}

#
# Main menu
#
while true; do
    cmd=(dialog --clear --backtitle "$TITLE" --title " [ M A I N - M E N U ] " --menu "You can use the UP/DOWN arrow keys, the first letter of the choice as a hot key, or the number keys 1-9 to choose an option:" "$wHEIGHT" "$wWIDTH" "$wHEIGHT")

    options=(
        Tweaks "Push your distro to the limit"
        Games "Install games easily"
        Emulation "Install emulators"
        Info "Info about the Pi or related"
        Multimedia "Install apps like XBMC"
        Configure "Installations are piece of cake now"
        Internet "Tweaks related to internet"
        Server "Use your distro as a server"
        Devs "Tools for making your own apps"
        Others "Scripts with others thematics"
        Exit "Exit to the shell"
    )

    choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)

    for choice in $choices; do
        case $choice in
        Tweaks) smTweaks ;;
        Games) smGames ;;
        Emulation) smEmulators ;;
        Info) smInfo ;;
        Multimedia) smMultimedia ;;
        Configure) smConfigure ;;
        Internet) smInternet ;;
        Server) smServer ;;
        Devs) smDevs ;;
        Others) smOthers ;;
        Exit) clear && exit_pikiss ;;
        1)
            echo -e "\nCancel pressed." && exit
            ;;
        255)
            echo -e "\nESC pressed." && exit
            ;;
        esac
    done
done
