#!/bin/bash do { #//////////////////////////////////// # DietPi Launcher # #//////////////////////////////////// # Created by Daniel Knight / daniel.knight@dietpi.com / dietpi.com # #//////////////////////////////////// # # Info: # - filename /DietPi/dietpi/dietpi-launcher # - Whiptail menu with list of all DietPi programs etc. # #//////////////////////////////////// #Import DietPi-Globals --------------------------------------------------------------- source /DietPi/dietpi/func/dietpi-globals G_CHECK_ROOT_USER G_CHECK_ROOTFS_RW export G_PROGRAM_NAME='DietPi-Launcher' #Import DietPi-Globals --------------------------------------------------------------- #///////////////////////////////////////////////////////////////////////////////////// # MENUS #///////////////////////////////////////////////////////////////////////////////////// setglobal PROGRAM_NAME = '"DietPi-Launcher'" setglobal CHOICE = '0' setglobal OPTION = '0' setglobal TARGETMENUID = '0' setglobal LAST_SELECTED_ITEM = '"dietpi-config'" #TARGETMENUID=0 proc Menu_Main{ var option_name = ''() set option_name = '('"" "────Install Optimized Software──────────────");sh-expr 'index++' set option_name = '('"DietPi-Software" "Install optimized software thats ready to run.");sh-expr 'index++' set option_name = '('"" "────Configuration───────────────────────────");sh-expr 'index++' set option_name = '('"DietPi-Config" "Feature rich config tool for your device.");sh-expr 'index++' if sh-expr ' $(dpkg --get-selections | grep -ci -m1 '^alsa-utils') ' { set option_name = '('"DietPi-JustBoom" "Launches EQ and MPD audio options menu") } set option_name = '('"DietPi-AutoStart" "Choose what software runs after boot.");sh-expr 'index++' #+ add dietpi-cloudshell if installed. if test -f /DietPi/dietpi/.installed && sh-expr ' $(cat /DietPi/dietpi/.installed | grep -ci -m1 'aSOFTWARE_INSTALL_STATE\[62\]=2') ' { set option_name = '('"DietPi-CloudShell" "Adjust update rate, scenes settings and more.");sh-expr 'index++' } set option_name = '('"DietPi-Cron" "Modify the start times of cron jobs.");sh-expr 'index++' set option_name = '('"DietPi-Process_Tool" "Tweak Nice, Affinity, Schedulers for programs.");sh-expr 'index++' set option_name = '('"DietPi-Drive_Manager" "Setup and control multiple external drives.");sh-expr 'index++' set option_name = '('"" "────DietPi Updates──────────────────────────");sh-expr 'index++' set option_name = '('"DietPi-Update" "Keep your DietPi system upto date.");sh-expr 'index++' set option_name = '('"" "────Backups / Sync──────────────────────────");sh-expr 'index++' set option_name = '('"DietPi-Backup" "Backup and restore your DietPi system.");sh-expr 'index++' set option_name = '('"DietPi-Sync" "Duplicate (Sync) one directory to another.");sh-expr 'index++' set option_name = '('"" "────Maintenance─────────────────────────────");sh-expr 'index++' set option_name = '('"DietPi-Cleaner" "Remove unwanted junk from your system.");sh-expr 'index++' set option_name = '('"" "────Misc────────────────────────────────────");sh-expr 'index++' set option_name = '('"DietPi-BugReport" "Found a bug? Let us know!");sh-expr 'index++' set option_name = '('"DietPi-CpuInfo" "Displays CPU Temp, frequencies, type etc.");sh-expr 'index++' set option_name = '('"DietPi-LetsEncrypt" "Frontend for Lets Encrypt, free SSL certs");sh-expr 'index++' set option_name = '('"DietPi-MorseCode" "Converts and outputs a text file to morsecode.");sh-expr 'index++' setglobal OPTION = $[whiptail --title $PROGRAM_NAME --menu "Please select a program to run:" --cancel-button "Exit" --backtitle $PROGRAM_NAME --default-item $LAST_SELECTED_ITEM 18 76 10 $(option_name[@]) !3 > !1 !1 > !2 !2 > !3] setglobal CHOICE = $Status unset option_name #Run program if sh-expr ' $CHOICE == 0 ' { if test $OPTION != "" { setglobal LAST_SELECTED_ITEM = $OPTION #convert to lowercase var command = $[echo $(OPTION,,)] #Run if test -f "/DietPi/dietpi/$command" { /DietPi/dietpi/"$command" # - different location } elif test -f "/DietPi/dietpi/misc/$command" { /DietPi/dietpi/misc/"$command" # - different location } elif test -f "/DietPi/dietpi/func/$command" { /DietPi/dietpi/func/"$command" } #+ Wait for user input. if test $command = "dietpi-cpuinfo" || test $command = "dietpi-update" || test $command = "dietpi-morsecode" { echo -e "" read -p " - Press any key to exit...." } } #Exit } else { whiptail --title "Exit $PROGRAM_NAME?" --yesno "Exit $PROGRAM_NAME?" --backtitle $PROGRAM_NAME --yes-button "Ok" --no-button "Back" --defaultno 9 55 setglobal CHOICE = $Status if sh-expr ' $CHOICE == 0 ' { setglobal TARGETMENUID = '-1' } } } #///////////////////////////////////////////////////////////////////////////////////// # Main Loop #///////////////////////////////////////////////////////////////////////////////////// #Start Menu while sh-expr ' $TARGETMENUID > -1 ' { #Clear Screen buffer clear if sh-expr ' $TARGETMENUID == 0 ' { Menu_Main } } #----------------------------------------------------------------------------------- exit #----------------------------------------------------------------------------------- }