#!/bin/bash
# -*- coding: utf-8 -*-
# please use "xgettext --from-code=UTF-8 -L shell -o antixcc-new.pot antixcc.sh" command to extract the translatable strings.
# please make sure to apply "msgmerge antixcc.pot -U antixcc-new.pot" to keep the developers notes for translators.
#
# File Name: controlcenter.sh
# Purpose: all-in-one control centre for antiX
# Authors: OU812 and minor modifications by anticapitalista
# Latest Change:
# 20 August 2008
# 11 January 2009 and renamed antixcc.sh
# 15 August 2009 some apps and labels altered.
# 09 March 2012 by anticapitalista. Added Live section.
# 22 March 2012 by anticapitalista. Added jwm config options and edited admin options.
# 18 April 2012 by anticapitalista. mountbox-antix opens as user not root.
# 06 October 2012 by anticapitalista. Function for ICONS. New icon theme.
# 26 October 2012 by anticapitalista. Includes gksudo and ktsuss.
# 12 May 2013 by anticapitalista. Let user set default apps.
# 05 March 2015 by BitJam: Add alsa-set-card, edit excludes, edit bootloader.  Fix indentation.
#   * Hide live tab on non-live systems.  Use echo instead of gettext.
#   * Remove unneeded doublequotes between tags.  Use $(...) instead of `...`.
# 01 May 2016 by anticapitalista: Use 1 script and use hides if nor present on antiX-base
# 11 July 2017 by BitJam:
#   * use a subroutine to greatly consolidate code
#   * use existence of executable as the key instead of documentation directory
#     perhaps I should switch to "which" or "type"
#   * move set-dpi to desktop tab
#   * enable ati driver button in hardware tab
# 18 Nov by antiX-Dave: fix edit jwm settings button to match icons with icewm and fluxbox
# 22 May 2023 by Robin-antiX: Add tooltips, add SCSI bus rescan tool; fix window header translatable; add block to prevent multiple parallel instances of acc.
# 25 Dec 2023 by Robin-antiX: Fix for equaliser entry not displayed due to .desktop file is not found by test -x; Modified equalizer_entry setup to provide either
#    ALSA equaliser or an Pipewire compatible equaliser depending whether user runs plain ALSA or additionally Pipewire sound server (in the latter case ALSA
#    equaliser doesn't have any effect on audio when it's sliders are moved until Pipewire is shut down).
# 07 Jan 2024 by Robin-antiX: Moved installer subroutine present in several entries to a subroutine so it can be used from all entries whenever it is needed to add some prerequisites. 
# 25 Jan 2024 by Robin-antiX: Added functions for adding/removing antiX startup file entries. Improved plain ALSA ./. pipewire sound server layer logic.
#    Some additional fixes. Added clipit switch incluing taking care for startup file. Merged divergent (silently changed) translatable strings from
#    antiX 23 iso version of script to original version, containing utf8 style quoting within strings, present at the git repo, to match the likewise
#    (silently) replaced transifex source template .pot
# 01 Feb 2024 by Robin-antiX: Added autosuspend entry. +Fix for startup entries containing slashes or ampersand. Improved startup file management. Sorted hardware tab.
# 05 Feb 2024 by anticapitalista. fixed typos, added Shared Folders,  added antiX cloud, added Language, put suspend-grey icon in /usr/share/pixmaps/papirus
# 26 Feb 2024 by Robin fix for user closing installer window prematurely by X in window border; added multilingual keyboard 4 level layout map
# 13/28 Jul 2024 by Robin added compositor toggle, disk usage analyser (1.2.4)
# 25 May 2025 by anti-apXos script closes instead of focusing a previous window, which simplifies installer and toggle entries
#    Also added an option to pass the starting tab number on the antixcc.sh commandline, with the Live tab moved to last to facilitate that
# 08 Jul 2025 by Robin added hostname changer, memory manager. (1.2.8)
# 09 Jul 2025 by Robin added command line help and changed command line options to tab names instead of numbers for easier handling.
# 11 Jul 2025 by anti-apXos move installer dialog into control centre window for fixing multiple-instances issue.
# 14 Jul 2025 Update translable strings to new gettext syntax.
# 02 November 2025 by anticapitalista added antix-qogir and antix-kora icons
# 05 December 2025 by anticapitalista added tab for init services
# 12 January 2926 by anticapitalista added antix-init-diversity-manager
# 01 March 2026 by Robin added entries for all management tasks crowding the antiX main menu to appropriate Control Centre Categories
#    also Icon folder cleanup
# 23 April 2026  by anticapitalista slowly move scripts from /usr/local/bin to /usr/bin
#
# Acknowledgements: Original script by KDulcimer of TinyMe. http://tinyme.mypclinuxos.com
#################################################################################################################################################

version=1.4.4

TEXTDOMAINDIR=/usr/share/locale
TEXTDOMAIN=antixcc
export TEXTDOMAINDIR TEXTDOMAIN
source gettext.sh

Lockfile="/dev/shm/acc-lock"
if [ -e $Lockfile ]; then
  if ps -p $(cat $Lockfile) >/dev/null; then
    wmctrl -F -a "$(gettext 'antiX Control Centre')"
    exit 0
  fi
else
  wmctrl -F -c "$(gettext 'antiX Control Centre')"
fi
echo "$$">"$Lockfile"

# Options

#antix-faenza=faenza icons used on antiX-17.4
#antix-moka=moka icons used on earlier releases
#antix-papirus=papirus converted to png icons
#antix-numix-bevel=numix-bevel png icons
#antix-numix-square=numix square png icons
#antix-qogir=qogir png icons
#antix-kora=kora png icons

#ICONS=/usr/share/icons/antix-moka
#ICONS=/usr/share/icons/antix-faenza
#ICONS=/usr/share/icons/antix-papirus
#ICONS=/usr/share/icons/antix-numix-bevel
#ICONS=/usr/share/icons/antix-numix-square
#ICONS=/usr/share/icons/antix-kora
ICONS=/usr/share/icons/antix-qogir

EXCLUDES_DIR=/usr/local/share/excludes 

EDITOR="geany -i"

STARTUP_FILE="$HOME/.desktop-session/startup"

AddStartup="/dev/shm/acc_tmp_01"
RemoveStartup="/dev/shm/acc_tmp_02"
debug=false # default. Override by command line option.
s=0  # default shift for tabs >6 (live)
windowheader="$(gettext 'antiX Control Centre')"  #translations
or="$(gettext 'or')" # translations
Desktop="$(gettext 'Desktop')" Software="$(gettext 'Software')" System="$(gettext 'System')" Network="$(gettext 'Network')" # translations

Shares="$(gettext 'Shares')" Session="$(gettext 'Session')" Live="$(gettext 'Live')" Disks="$(gettext 'Disks')" Audio="$(gettext 'Audio')" # translations

Hardware="$(gettext 'Hardware')" Drivers="$(gettext 'Drivers')" Maintenance="$(gettext 'Maintenance')" Services="$(gettext 'Services')" # translations


dpi_label=$(printf "%s DPI" "$(gettext 'Set Font Size')")
absent=" $(gettext 'Not present still, so this will install the needed packages first.')"

cleanup() {
rm -f $AddStartup >/dev/null 2>&1
rm -f $RemoveStartup >/dev/null 2>&1
rm -f "$Lockfile" >/dev/null 2>&1
}
trap cleanup EXIT

its_alive() {
    #if grep -q " /live/aufs " /proc/mounts; then  # (alternative method)
    local root_fstype=$(df -PT / | tail -n1 | awk '{print $2}')
    case $root_fstype in
        aufs|overlay) return 0 ;;
                   *) return 1 ;;
    esac
}

if its_alive; then
    ITS_ALIVE=true
    s=1 # shift for tab live
fi

# check whether we run on plain alsa or in pipewire mode, provide boolean, so not each entry needs to repeat the check individually
plain_alsa=true
wpctl status >/dev/null 2>&1 && plain_alsa=false

vbox() {
    local text="$*"
    local len=${#text}
    #printf "vlen: %6s\n" "$len" >&2
    if [ $len -lt 20 ]; then
        echo '<vbox><hseparator></hseparator></vbox>'
    else
    echo "  <vbox>"
    local item
    for item; do
        echo "$item"
    done
    echo "  </vbox>"
    fi
}

hbox() {
    local text="$*"
    local len=${#text}
    #printf "hlen: %6s\n" "$len" >&2
    [ $len -lt 20 ] && return
    echo "<hbox>"
    local item
    for item; do
        echo "$item"
    done
    echo "</hbox>"
}

vbox_frame_hbox() {
    local text="$*"
    local len=${#text}
    #printf "flen: %6s\n" "$len" >&2
    [ $len -lt 20 ] && return
    echo "<vbox><frame><hbox>"
    local item
    for item; do
        echo "$item"
    done
    echo "</hbox></frame></vbox>"
}

entry() {
    local image="$1" action="$2" text="$3" tooltip="$4"
    [ -n "$tooltip" ] || tooltip="$(gettext '(No tooltip for now, sorry.)')"
    cat<<Entry
    <hbox>
      <button tooltip-text="$tooltip">
        <input file>$image</input>
        <height>48></height>
        <action>$action</action>
      </button>
      <text use-markup="true" width-chars="32">
        <label>$text</label>
      </text>
    </hbox>
Entry
}

prerequisites() {
    # this convenience function returns a full install dialog within a variable and expects all packages meant to be installed as positional parameters and cares for creation of an install dialog to be applied in entries which are in need of some additional helper tools not installed by default on some antiX flavours. Don't forget to set the $prerequesite_icon and $prerequisites_msg variables before calling.
    # if prerequisites is used in an entry please make sure to wait with reload of acc main window until you find this lockfile removed, so changed button functionality is processed properly at reload; also check for the pid stored within this file to continue if user has closed the installer prematurely:

    # prepare textstring for output
    text=''
    if [ $# -gt 1 ]; then
        for i in $@; do
            text="$text, $i"
        done
        text="$(sed 's/^\(.*\), \(.*\)$/\1 '$(gettext "and")' \2/' <<<"${text:2}")"
    else
        text="$1"
    fi
    # write complete install dialog to a variable
    install_dialog='yad --center --fixed --borders=10 --undecorated --window-icon="'$prerequisites_icon'" --image="'$prerequisites_icon'" --title="'"$(gettext 'Install') $text"'" --text="'$prerequisites_msg'""\n\n'"$(eval_gettext 'Please install $text packages first.')"'\n'"$(gettext 'Do you want to install the packages now?')"'\n" --button="'"$(gettext 'No thanks')"'":1 --button="'"$(gettext 'Install')"'":0; if [ $? -eq 0 ]; then urxvt -embed $(wmctrl -l | grep "'"$(gettext 'antiX Control Centre')"'" | cut -d" " -f1) -title "'"$(gettext 'Installing prerequisites...')"'" -e bash -c "if [ ! -e /var/cache/apt/pkgcache.bin ] || [ \$((\$(date +%s)-\$(LANG=C stat -c %Y /var/cache/apt/pkgcache.bin 2>/dev/null))) -gt 10800 ]; then sudo apt-get update; else true; fi && sudo apt-get install '$@'; if [ \$? -eq 0 ]; then echo; echo \"'"$(gettext 'Install completed.')"'\"; read -n1 -s -r -p \"'"$(gettext 'Press any key for returning to Control Centre.')"'\"; fi"; fi'
}

install_fail="echo \"\n"$(gettext "Install has failed.")"\n\n"$(gettext "Please check manually for what has\ngone wrong or what is still missing.")"\" | \
yad --timeout=4 --width=360 --height=120 --center --no-buttons \
    --undecorated --borders=10 --margins=20 \
    --title=\""$(gettext 'Install Error')"\" \
    --window-icon=control-centre-antix \
    --skip-taskbar --text-info \
    --back='darkred' --fore='white'"

# this convenience function adds missing entries to ~/.desktop-session/startup file in case this must be done by an entry.
# expects mandatory positionals: add_startup "<string_to_be_added>" "<comment_line_to_be_added>"
# in case the line exists, it will silently do nothing, in case the line exists but is commented out the sharp sign preceding the line will be removed.
# Additional third ad libitum positional: "<search_string>" in case the command string feed in first positional includes variable parts. Accepts regex, syntax must match sed and grep regex both.
#add_startup() {    # originally a function, but not accessible from within entries, even after exporting it; temp script files as workaround.
cat<<add_startup >"$AddStartup"
    if [ -z "\$3" ]; then teststring="\$1"; else teststring="\$3"; fi # workaround for variable arguments behind a fixed command string
    if ! grep ^[[:space:]]*"\${teststring}" "$STARTUP_FILE" >/dev/null; then
# We don't care for hard blocked entries for now, this might be a future feature.
#        if grep ^[[:space:]]*[#][#][[:space:]]*"\${teststring}" "$STARTUP_FILE" >/dev/null; then
#            # don’t touch entry if user has hard blocked it
#            yad --center --fixed --borders=10 --undecorated \\
#                --window-icon="error" \\
#                --image="error" \\
#                --title=$"Error"" ""\$1" \\
#                --text=$"Entry \${1/&/＆} is hard blocked""\n"$"by double sharp sign in config file""\n\t$STARTUP_FILE\n"$"Please uncomment it on your own.""\n" \\
#                --button=$"Got it":0
#            #echo $"Entry is hard blocked by double sharp in config file $STARTUP_FILE."" "$"Please uncomment it on your own."
#            exit 1
#            #return 1
#       elif ↓
        if grep ^[[:space:]]*[#][[:space:]]*"\${teststring}"[[:space:]]*[#]*[[:space:]]* "$STARTUP_FILE" >/dev/null; then
            teststring=\${teststring/&/\\\&} # prepare strings for yad
            replacement=\${1/&/\\\&}
            # remove sharp sign to uncomment, only on a single occurence
            sed -i "0,/\${teststring//\//\\/}/{s/^[[:space:]]*#[[:space:]]*\${teststring//\//\\/}.*$/\${replacement//\//\\/}/}" "$STARTUP_FILE"
        else
            # append entry
            echo -e "\n\$2\n\$1" >> "$STARTUP_FILE"
        fi
    fi
add_startup
#}
#export -f add_startup
chmod 755 "$AddStartup"

# counterpart of add_startup() function.
# expects mandatory positionals: disable_startup "<string_to_be_disabled_without_preceeding_sharp>" "<comment_line_to_be_added_if_entry_not_present_yet>"
#disable_startup() {
cat<<disable_startup >"$RemoveStartup"
    if grep ^[[:space:]]*"\${1}" "$STARTUP_FILE" >/dev/null; then
# We don't care for duplicate disabled entries for now, these must have been introduced by the user himself. He might have had a reason for creating these.
#        if grep ^[[:space:]]*[#][[:space:]]*"\${1}"[[:space:]]*[#]*[[:space:]]* "$STARTUP_FILE" >/dev/null || grep ^[[:space:]]*[#][#][[:space:]]*"\${1}"[[:space:]]*[#]*[[:space:]]* "$STARTUP_FILE" >/dev/null; then
#            # remove entry
#            sed -i "/^[[:space:]]*\${1//\//\\/}.*$/d" "$STARTUP_FILE"
#        else
            # add sharp sign to comment out ALL occurrences, including user created duplicates.
            sed -i "s/^[[:space:]]*\(\${1//\//\\/}.*\)$/# \1/" "$STARTUP_FILE"
#        fi
# We don't care for duplicates for now, these must have been introduced by the user himself. He might have had a reason for creating these.
#    else
#        # There is no active entry, but maybe a deactivated one is already present.
#        if ! grep ^[[:space:]]*[#][[:space:]]*"\${1}"[[:space:]]*[#]*[[:space:]]* "$STARTUP_FILE" >/dev/null || ! grep ^[[:space:]]*[#][#][[:space:]]*"\${1}"[[:space:]]*[#]*[[:space:]]* "$STARTUP_FILE" >/dev/null; then
#            # append disabled entry, preceeded by #
#            echo -e "\n\$2\n# \$1" >> "$STARTUP_FILE"
#        fi
    fi
disable_startup
#}
#export -f disable_startup
chmod 755 "$RemoveStartup"

[ -d $HOME/.fluxbox -a -e /usr/share/xsessions/fluxbox.desktop ] && fluxbox_entry=$(entry \
    "$ICONS/gnome-documents_03.png" \
    "$EDITOR $HOME/.fluxbox/overlay $HOME/.fluxbox/keys $HOME/.fluxbox/init $HOME/.fluxbox/startup $HOME/.fluxbox/apps $HOME/.fluxbox/menu &" \
    "$(gettext 'Edit Fluxbox Settings')" \
    "$(gettext 'Modify the Fluxbox window manager configuration files in a text editor')")

icewmgui_prog=/usr/local/bin/icewm-manager-gui
test -x $icewmgui_prog && icewmgui_entry=$(entry \
    $ICONS/icewmcc.png \
    "/usr/local/bin/icewm-manager-gui &" \
    "$(gettext 'IceWM Control Centre')" \
    "$(gettext 'Manage most popular IceWM window manager settings in a GUI instead of editing its control file manually')")

wallpaper_prog=/usr/local/bin/wallpaper
test -x $wallpaper_prog && wallpaper_entry=$(entry \
    $ICONS/preferences-desktop-wallpaper.png \
    "/usr/local/bin/wallpaper &" \
    "$(gettext 'Choose Wallpaper')" \
    "$(gettext 'Select the desktop background image or colour.')")
    
[ -d $HOME/.icewm -a -e /usr/share/xsessions/icewm.desktop ] && icewm_entry=$(entry \
    $ICONS/gnome-documents_01.png \
    "$EDITOR $HOME/.icewm/winoptions $HOME/.icewm/preferences $HOME/.icewm/prefoverride $HOME/.icewm/keys $HOME/.icewm/startup $HOME/.icewm/toolbar $HOME/.icewm/menu $HOME/.icewm/menu-applications $HOME/.icewm/personal &" \
    "$(gettext 'Edit IceWM Settings')" \
    "$(gettext 'Modify the IceWM window manager configuration files in a text editor')")

[ -d $HOME/.jwm -a -e /usr/share/xsessions/jwm.desktop ] && jwm_entry=$(entry \
    $ICONS/gnome-documents_02.png \
    "$EDITOR $HOME/.jwm/preferences $HOME/.jwm/keys $HOME/.jwm/tray $HOME/.jwm/startup $HOME/.jwmrc $HOME/.jwm/menu &" \
    "$(gettext 'Edit JWM Settings')" \
    "$(gettext 'Modify the JWM window manager configuration files in a text editor')")

# Edit syslinux.cfg if the device it is on is mounted read-write
grep -q " /live/boot-dev .*\<rw\>" /proc/mounts && bootloader_entry=$(entry \
    $ICONS/preferences-desktop.png \
    "gksu '$EDITOR /live/boot-dev/boot/syslinux/syslinux.cfg /live/boot-dev/boot/grub/grub.cfg' &" \
    "$(gettext 'Edit Bootloader Menu')" \
    "$(gettext 'Modify the Syslinux and Grub boot menu configuration files in a text editor')")

test -d /usr/local/share/excludes && excludes_entry=$(entry \
    $ICONS/remastersys.png \
    "gksu $EDITOR $EXCLUDES_DIR/*.list &" \
    "$(gettext 'Edit Exclude Files')" \
    "$(gettext 'This will open several list files in a text editor, allowing to define what files are NOT to be included when live-remastering, creating an ISO snapshot etc. For example, you might want to add the directories “home/*/.local/share/Trash” and/or “home/*/./cache” to the exclusions for live-remastering, which will otherwise be stored in your boot medium when running live-remaster in „personal” flavour and „storing home folder” in it.')")

if test -x /usr/sbin/synaptic; then synaptic_entry=$(entry \
    $ICONS/synaptic.png \
    "gksu synaptic &" \
    "$(gettext 'Manage Packages')" \
    "$(gettext 'Add or remove program packages using Synaptic package manager')")
fi

if test -x /usr/local/bin/cli-aptiX; then cli_aptix_entry=$(entry \
    $ICONS/cli-aptiX_01.png \
    "desktop-defaults-run -t sudo /usr/local/bin/cli-aptiX --pause &" \
    "$(gettext 'Manage Packages')" \
    "$(gettext 'Add or remove program packages using Cli-aptiX package manager')")
fi

test -x  /usr/sbin/bootrepair && bootrepair_entry=$(entry \
    $ICONS/bootrepair.png \
    "gksu bootrepair &" \
    "$(gettext 'Boot Repair')" \
    "$(gettext 'Reinstall, Fix, Backup or Restore GRUB configuration or MBR/PBR from within a GUI.')" )

rescue_scan_prog=/usr/local/bin/chroot-rescue-scan
test -x $rescue_scan_prog  && rescue_scan_entry=$(entry \
    $ICONS/rescuetime_01.png \
    "x-terminal-emulator -e sudo chroot-rescue-scan --pause &" \
    "$(gettext 'System Repair')" \
    "$(gettext 'Chroot into a Linux system in order to repair it.')")

test -x /usr/bin/connman-ui-gtk && connman_entry=$(entry \
    $ICONS/connman.png \
    "connman-ui-gtk &" \
    "$(gettext 'WiFi Connect')" \
    "$(gettext 'Change and manage the wireless connection settings using Connman.')")

test -x /usr/bin/connman-gtk && connman_entry=$(entry \
    $ICONS/connman.png \
    "connman-gtk &" \
    "$(gettext 'WiFi Connect')" \
    "$(gettext 'Change and manage the wireless connection settings using Connman.')")

test -x /usr/bin/cmst && connman_entry=$(entry \
    $ICONS/connman.png \
    "cmst &" \
    "$(gettext 'WiFi Connect')" \
    "$(gettext 'Change and manage the wireless connection settings using Connman.')")

firewall_prog=/usr/bin/gufw
test -x $firewall_prog  && firewall_entry=$(entry \
    $ICONS/gufw.png \
    "gksu gufw &" \
    "$(gettext 'Firewall Configuration')" \
    "$(gettext 'Set up the firewall for your Network connections using gufw.')")

backup_prog=/usr/bin/luckybackup
test -x $backup_prog  && backup_entry=$(entry \
    $ICONS/luckybackup.png \
    "gksu luckybackup &" \
    "$(gettext 'System Backup')" \
    "$(gettext 'Make a backup of your system using Luckybackup.')")

if ! $plain_alsa; then 
    if which easyeffects > /dev/null && which antiX-equaliser-toggle > /dev/null; then
        equalizer_entry=$(entry \
        $ICONS/com.github.wwmm.easyeffects.png \
        'easyeffects &' \
        "$(gettext 'Equaliser for Pipewire')" \
        "$(gettext 'Modify the frequency response characteristics of the audio output.')")
        eq_toggle_entry=$(entry \
        $ICONS/easyeffects-toggle.png \
        'antiX-equaliser-toggle &' \
        "$(gettext 'Toggle equaliser')" \
        "$(gettext 'A switch to immediately enable or disable PipeWire-equaliser Easyeffects and add or remove it from startup')" \
        )
    else
        prerequisites_icon="$ICONS/alsamixer-equalizer.png"
        prerequisites easyeffects lsp-plugins-lv2 antix-equaliser-toggle
        prerequisites_msg="$(gettext 'Equaliser for Pipewire not found.')"
        equalizer_entry=$(entry \
        $ICONS/com.github.wwmm.easyeffects.png \
        "$install_dialog; \
          if which easyeffects; then \
            { bash $AddStartup 'easyeffects --gapplication-service' \
            '# Start easyeffects in pseudo-daemonised mode'; }; \
            rm $Lockfile; \
            sleep .2; \
            antixcc.sh o & \
          else \
            $install_fail; \
          fi" \
        "$(gettext 'Equaliser for Pipewire') " \
        "$(gettext 'Modify the frequency response characteristics of the audio output.')"" ""$(gettext 'Equaliser for Pipewire not installed. Installs easyeffects and lsp-plugins-lv2 packages.')")
    fi
else
    equalizer_prog=/usr/share/applications/alsamixer-equalizer.desktop
    test -f $equalizer_prog  && equalizer_entry=$(entry \
        $ICONS/alsamixer-equalizer.png \
        "urxvt -e alsamixer -D equalizer &" \
        "$(gettext 'Alsamixer Equalizer')" \
        "$(gettext 'Modify the frequency response characteristics of the audio output.')")
fi

printer_prog=/usr/bin/system-config-printer
test -x $printer_prog  && printer_entry=$(entry \
    $ICONS/printer.png \
    "system-config-printer &" \
    "$(gettext 'Print Settings')" \
    "$(gettext 'Set up your printer. You need to make sure beforehand the cups service is started already.')")

livekernel_prog=/usr/bin/live-kernel-updater
test -x $livekernel_prog && livekernel_entry=$(entry \
    $ICONS/live-usb-kernel-updater.png \
    "desktop-defaults-run -t sudo /usr/bin/live-kernel-updater --pause &" \
    "$(gettext 'Live-USB Kernel Updater')" \
    "$(gettext 'Update your Live System with a new kernel. Make sure you have installed the kernel already and remastered the Live device before using the Live kernel updater.')")

systemkeyboard_prog=/usr/bin/system-keyboard-qt
test -x $systemkeyboard_prog && systemkeyboard_entry=$(entry \
    $ICONS/im-chooser.png \
    "gksu system-keyboard-qt &" \
    "$(gettext 'Set System Keyboard Layout')" \
    "$(gettext 'Add or modify keyboard layouts, e.g. Cyrillic, Chinese or Azerty, Qwertz and Qwerty in multiple variants like Typewriter, Dvorak or Sun.')")

kb_layout_prog=/usr/local/bin/antiX-current-kb-layout
tt_msg="$(gettext 'Displays current keyboard layout, as selected by locale chooser from antiX statusbar (useful if you have to type in some foreign language layouts, the proper characters not being printed on your keys). Reveals second and third level assignements as well.')"
if test -x $kb_layout_prog; then
    keyboardlayout_entry=$(entry \
    "$ICONS/antiX-current-kb-layout_01.png" \
    "antiX-current-kb-layout &" \
    "$(gettext 'Current Keyboard Layout')" \
    "$tt_msg")
else
    prerequisites_icon="$ICONS/antiX-current-kb-layout_01.png"
    prerequisites_msg="$(gettext 'antiX-current-kb-layout not found.')"
    prerequisites antix-current-kb-layout
    keyboardlayout_entry=$(entry \
    "$ICONS/antiX-current-kb-layout_02.png" \
    "$install_dialog; \
      if test -x /usr/local/bin/antiX-current-kb-layout; then \
          rm $Lockfile; \
          sleep .2; \
          antixcc.sh s & \
          ( sleep 1; antiX-current-kb-layout ) & \
      else \
          $install_fail; \
      fi" \
    "$(gettext 'Current Keyboard Layout')" \
    "$tt_msg $(gettext 'antiX-current-kb-layout not installed. Installs antiX-current-kb-layout package and shows then the current layout.')")
fi

fontman_program=/usr/bin/font-manager
tt_msg="$(gettext 'Preview, compare, manage and install fonts (from local files or open source from web); set up font family replacements.')"
if test -x $fontman_program; then
    fontman_entry=$(entry \
    $ICONS/FontManager_01.png \
    "$fontman_program &" \
    "$(gettext 'Font Manager')" \
    "$tt_msg")
else
    prerequisites_icon="$ICONS/FontManager_01.png"
    prerequisites_msg="$(gettext 'FontManager not found.')"
    prerequisites font-manager
    fontman_entry=$(entry \
    $ICONS/FontManager_02.png \
    "$install_dialog; \
      if test -x $fontman_program; then \
          rm $Lockfile; \
          sleep .2; \
          antixcc.sh s & \
          ( sleep 1; $fontman_program ) & \
      else \
          $install_fail; \
      fi" \
    "$(gettext 'Font Manager')" \
    "$tt_msg$absent")
fi

conky_prog=/usr/bin/conky
test -x $conky_prog && test -w $HOME/.conkyrc && conky_entry=$(entry \
    $ICONS/conky.png \
    "desktop-defaults-run -te $HOME/.conkyrc &" \
    "$(gettext 'Edit System Monitor')" \
    "$(gettext 'Modify the design of the Conky System monitor on the desktop.')")

lxappearance_prog=/usr/bin/lxappearance
test -x $lxappearance_prog && lxappearance_entry=$(entry \
    $ICONS/preferences-desktop-theme.png \
    "lxappearance &" \
    "$(gettext 'Customize Look and Feel')" \
    "$(gettext 'Change the design of your desktop, modify details like mouse cursor design etc. using lxappearance.')")

compositor_prog=/usr/bin/xcompmgr
if test -x $compositor_prog; then
if ! grep '^[[:space:]]*xcompmgr..*' "$STARTUP_FILE" > /dev/null; then
    compositor_entry=$(entry \
    $ICONS/Logo_compiz-48_01.png \
    "bash $AddStartup 'xcompmgr -f -F &' '## Uncomment to use compositor'; \
      if ! pidof xcompmgr; then \
          xcompmgr -f -F & \
      fi; \
      rm $Lockfile; \
      sleep .5; \
      antixcc.sh z &" \
    "$(gettext 'Activate visual effects')" \
    "$(gettext 'Starts Xcompmgr compositor, allowing shading, fading, transparency and some more visual desktop effects.')")
else
    compositor_entry=$(entry \
    $ICONS/Logo_compiz-grey-48_01.png \
    "bash $RemoveStartup 'xcompmgr..*' '## Uncomment to use compositor manager'; \
      kill -15 $(pidof xcompmgr 2>/dev/null); \
      rm $Lockfile; \
      sleep .5; \
      antixcc.sh z &" \
    "$(gettext 'Disengage visual effects')" \
    "$(gettext 'Deactivates Xcompmgr compositor, disabeling some desktop eye candys like shading, fading, tranparency etc.')")
fi
fi

prefapps_prog=/usr/local/bin/desktop-defaults-set
test -x $prefapps_prog && prefapps_entry=$(entry \
    $ICONS/gnome-settings-default-applications.png \
    "desktop-defaults-set &" \
    "$(gettext 'Preferred Applications')" \
    "$(gettext 'Select what default programs are used on your system.')")

packageinstaller_prog=/usr/bin/packageinstaller
test -x $packageinstaller_prog && packageinstaller_entry=$(entry \
    $ICONS/packageinstaller.png \
    "gksu packageinstaller &" \
    "$(gettext 'Package Installer')" \
    "$(gettext 'Install popular programs easily using Package Installer. This tool takes care of all hidden dependencies the default package managers like apt or synaptic neglect.')")

debinstaller_prog=/usr/bin/deb-installer
test -x $debinstaller_prog && debinstaller_entry=$(entry \
    $ICONS/debian-logo.png \
    "deb-installer &" \
    "$(gettext 'Debian-Package Installer')" \
    "$(gettext 'Install your locally provided debian packages using “Deb-Installer”, by selecting from a folder you have access to. Make sure to provide all needed dependency packages on same run, or you may need to be connected to the respective online repo servers and have updated your local apt database copy, in case the local packages need to install additional dependencies.')")

antixupdater_prog=/usr/local/bin/yad-updater
test -x $antixupdater_prog && antixupdater_entry=$(entry \
    $ICONS/software-sources.png \
    "/usr/local/bin/yad-updater &" \
    "$(gettext 'antiX Updater')" \
    "$(gettext 'Update antiX automatically to the most recent state of the selected repositories.')")

antixautoremove_prog=/usr/local/bin/yad-autoremove
test -x $antixautoremove_prog && antixautoremove_entry=$(entry \
    $ICONS/autoremove_cleanup_03.png \
    "/usr/local/bin/yad-autoremove &" \
    "$(gettext 'antiX program remover')" \
    "$(gettext 'Removes automatically leftover (orphaned) packages no longer needed on your system.')")

if [ "$(detect-init.sh)" == 'sysVinit' ]; then
  sysvconf_prog=/usr/sbin/sysv-rc-conf
  test -x $sysvconf_prog && sysvconf_entry=$(entry \
    $ICONS/choose-startup-services_01.png \
    "rc-conf-wrapper.sh &" \
    "$(gettext 'Choose sysVinit Startup Services')" \
    "$(gettext 'Select what system services should be started automatically when booting antiX (sysVinit).')")
fi

if [ "$(detect-init.sh)" == 'runit' ]; then
  runitconf_prog=/usr/bin/runit-service-manager.sh
  test -x $runitconf_prog && runitconf_entry=$(entry \
    $ICONS/choose-startup-services_02.png \
    "gksu runit-service-manager.sh &" \
    "$(gettext 'Choose Runit Startup Services')" \
    "$(gettext 'Select what system services should be started automatically when booting antiX (runit).')")
fi


if [ "$(detect-init.sh)" == 'dinit' ]; then
  dinitconf_prog=/usr/bin/dinit-dialogbox-manager
  test -x $dinitconf_prog && dinitconf_entry=$(entry \
    $ICONS/choose-startup-services_03.png \
    "gksu dinit-dialogbox-manager &" \
    "$(gettext 'Choose Dinit Startup Services')" \
    "$(gettext 'Select what system services should be started automatically when booting antiX (dinit).')")
fi

if [ "$(detect-init.sh)" == 's6-rc' ]; then
  s6conf_prog=/usr/bin/s6-rc-dialogbox-manager
  test -x $s6conf_prog && s6conf_entry=$(entry \
    $ICONS/choose-startup-services_04.png \
    "gksu s6-rc-dialogbox-manager &" \
    "$(gettext 'Choose s6-rc Startup Services')" \
    "$(gettext 'Select what system services should be started automatically when booting antiX (s6-rc).')")
fi

if [ "$(detect-init.sh)" == 's6-66' ]; then
  s6_66conf_prog=/usr/bin/66-rc-dialogbox-manager
  test -x $s6_66conf_prog && 66conf_entry=$(entry \
    $ICONS/choose-startup-services_05.png \
    "gksu 66-rc-dialogbox-manager &" \
    "$(gettext 'Choose s6-66 Startup Services')" \
    "$(gettext 'Select what system services should be started automatically when booting antiX (s6-66).')")
fi

initmanager_prog=/usr/bin/antix-init-diversity-manager
test -x $initmanager_prog && initmanager_entry=$(entry \
    $ICONS/grub-customizer.png \
    "gksu antix-init-diversity-manager &" \
    "$(gettext 'Boot Menu init')" \
    "$(gettext 'Select which init(s) should appear in the boot menu')")

ufwtoggle_prog=/usr/local/bin/antix_firewall_toggle
test -x $ufwtoggle_prog && ufwtoggle_entry=$(entry \
    $ICONS/gufw.png \
    "/usr/local/bin/antix_firewall_toggle &" \
    "$(gettext 'Toggle Firewall on/off')" \
    "$(gettext 'Switch the state of your network firewall on or off using ufw.')")

tzdata_prog=/usr/local/bin/set_time-and_date.sh
test -x $tzdata_prog && tzdata_entry=$(entry \
    $ICONS/time-admin.png \
    "/usr/local/bin/set_time-and_date.sh &" \
    "$(gettext 'Set Date and Time')" \
    "$(gettext 'Change and adjust date and time settings of your system.')")
    
process_management_prog=/usr/bin/htop
test -x $process_management_prog && process_entry=$(entry \
    $ICONS/sheets.png \
    "urxvt -e htop &" \
    "$(gettext 'Process Manager')" \
    "$(gettext 'View, pause, kill or nice processes in a console-gui') $(gettext 'Use mouse for all controls.')")

iomon_prog=/sbin/iotop
tt_msg="$(gettext 'Monitor disk I/O usage by processes.') $(gettext 'Press h key for help. Press Ctrl-T to toggle task_delayacct kernel setting if required.')"
if test -x $iomon_prog; then 
    iomon_entry=$(entry \
    $ICONS/iotop_01.png \
    "gksu -- roxterm -T $(gettext 'iotop I/O Monitor') --hide-menubar -z 1.25 -e iotop &" \
    "$(gettext 'I/O Monitor')" \
    "$tt_msg")
else
    prerequisites_icon="$ICONS/iotop.png_01"
    prerequisites_msg="$(gettext 'iotop not found.')"
    prerequisites iotop-c
    iomon_entry=$(entry \
    $ICONS/iotop_02.png \
    "$install_dialog; \
      if test -x $iomon_prog; then \
          rm $Lockfile; \
          sleep .2; \
          antixcc.sh s & \
          ( sleep 1; gksu -- roxterm -T $(gettext 'iotop I/O Monitor') --hide-menubar -z 1.25 -e iotop ) & \
      else \
          $install_fail; \
      fi" \
    "$(gettext 'I/O Monitor')" \
    "$tt_msg$absent")
fi

memorymanager_prog=/usr/local/bin/antiX-memory-manager
tt_msg="$(gettext 'Optimise memory economy by applying kernel memory compression. Activate, deactivate, configure zram and zswap, check usage stats.')"
if test -x $memorymanager_prog; then
    memorymanager_entry=$(entry \
    $ICONS/antiXmm_01.png \
    "urxvt -e sudo bash -c '/usr/local/bin/antiX-memory-manager &'" \
    "$(gettext 'Memory Manager')" \
    "$tt_msg")
else
    prerequisites_icon="$ICONS/antiXmm_01.png"
    prerequisites_msg="$(gettext 'antiX-memory-manager not found.')"
    prerequisites antix-memory-manager
    memorymanager_entry=$(entry \
    $ICONS/antiXmm_02.png \
    "$install_dialog; \
      if test -x $memorymanager_prog; then \
          rm $Lockfile; \
          sleep .2; \
          antixcc.sh s & \
          ( sleep 1; urxvt -e sudo bash -c '/usr/local/bin/antiX-memory-manager ) &' \
      else \
          $install_fail; \
      fi" \
    "$(gettext 'Memory Manager')" \
    "$tt_msg$absent")
fi

localisation_prog=/usr/local/bin/locale-antix
test -x $localisation_prog && localisation_entry=$(entry \
    $ICONS/preferences-desktop-locale.png \
    "gksu /usr/local/bin/locale-antix &" \
    "$(gettext 'System Language Manager')" \
    "$(gettext 'Change Language and other locale options including downloading localised LibreOffice')")

ceni_prog=/usr/sbin/ceni
test -x $ceni_prog && ceni_entry=$(entry \
    $ICONS/ceni.png \
    "desktop-defaults-run -t sudo ceni &" \
    "$(gettext 'Network Interfaces')" \
    "$(gettext 'Set up the network interfaces present on your device using Ceni.')")

wifi_prog=/usr/local/bin/antix-wifi-switch
test -x $wifi_prog && wifi_entry=$(entry \
    $ICONS/nm-device-wireless.png \
    "antix-wifi-switch &" \
    "$(gettext 'Select wifi Application')" \
    "$(gettext 'Select which wireless management program should be used.')")

connectshares_conf_prog=/usr/local/bin/connectshares-config
test -x $connectshares_conf_prog && connectshares_conf_entry=$(entry \
    $ICONS/connectshares-config.png \
    "connectshares-config &" \
    "$(gettext 'ConnectShares Configuration')" \
    "$(gettext 'Configure Connections to Windows or SAMBA shares in your LAN or WAN.')")

connectshares_prog=/usr/local/bin/connectshares
test -x $connectshares_prog && connectshares_entry=$(entry \
    $ICONS/connectshares.png \
    "connectshares &" \
    "$(gettext 'ConnectShares')" \
    "$(gettext 'Connect to preconfigured Windows or SAMBA shares in your LAN or WAN. Use „Connectshares Config” to configure initially, or edit the file ~/.config/connectshares/connectshares.conf manually.')")

disconnectshares_prog=/usr/local/bin/disconnectshares
test -x $disconnectshares_prog && disconnectshares_entry=$(entry \
    $ICONS/disconnectshares.png \
    "disconnectshares &" \
    "$(gettext ' DisconnectShares')" \
    "$(gettext 'Disconnect from all currently connected Windows or SAMBA shares. Make sure the shares are not in use by any programs before executing.')")

droopy_prog=/usr/local/bin/droopy.sh
test -x $droopy_prog && droopy_entry=$(entry \
    $ICONS/droopy.png \
    "droopy.sh &" \
    "$(gettext 'Droopy (File Sharing)')" \
    "$(gettext 'Serve files via Python web server')")

shared_prog=/usr/local/bin/antiX-samba-mgr
tt_msg="$(gettext 'Mount and share folders or printers easily in your LAN from and with other PCs running diverse OS’ (Windows, Apple, Linux, BSD etc.) in a GUI suite. antiX Samba manager guides you through shares setup and allows to mount remote shares to arbitrary empty folders within your file system and share any folder on your device.')"
if test -x $shared_prog; then
    shared_entry=$(entry \
    $ICONS/antiX-smb-mgr02.png \
    "$shared_prog &" \
    "$(gettext 'Shared Folders')" \
    "$tt_msg")
else
    prerequisites_icon="$ICONS/antiX-smb-mgr02.png"
    prerequisites_msg="$(gettext 'antiX-samba-mgr not found.')"
    prerequisites antix-samba-manager nmap
    shared_entry=$(entry \
    $ICONS/antiX-smb-mgr05.png \
    "$install_dialog; \
      if test -x $shared_prog; then \
          rm $Lockfile; \
          sleep .2; \
          antixcc.sh f & \
          ( sleep 1; $shared_prog; ) & \
      else \
          $install_fail; \
      fi" \
    "$(gettext 'Shared Folders')" \
    "$tt_msg $(gettext 'Currently antiX Samba manager package is not installed. This installs an runs it.')")
fi

cloud_prog=/usr/local/bin/antix-cloud
test -x $cloud_prog && cloud_entry=$(entry \
    $ICONS/antix-cloud_01.png \
    "/usr/local/bin/antix-cloud &" \
    "$(gettext 'Access Cloud Storage')" \
    "$(gettext 'Allows to automatically configure GoogleDrive and OneDrive, in rclone, or to manually configure (almost) any Cloud Service, and then mount it and access it in the default File Manager')")

assistant_prog=/usr/local/bin/1-to-1_assistance.sh
test -x $assistant_prog && assistant_entry=$(entry \
    $ICONS/1-to-1_assistance.png \
    "1-to-1_assistance.sh &" \
    "$(gettext '1-to-1 Assistance')" \
    "$(gettext 'A simple way to privately share the desktop of one system with another system.')")

voice_prog=/usr/local/bin/1-to-1_voice.sh
test -x $voice_prog && voice_entry=$(entry \
    $ICONS/1-to-1_voice.png \
    "1-to-1_voice.sh &" \
    "$(gettext '1-to-1 Voice')" \
    "$(gettext 'A simple way to talk privately with the user of another system.')")

sshconduit_prog=/usr/local/bin/ssh-conduit.sh
test -x $sshconduit_prog && sshconduit_entry=$(entry \
    $ICONS/ssh-conduit.png \
    "ssh-conduit.sh &" \
    "$(gettext 'SSH Conduit')" \
    "$(gettext 'Use remote resouces via an ssh encypted connection')")

gnomeppp_prog=/usr/bin/gnome-ppp
test -x $gnomeppp_prog && gnomeppp_entry=$(entry \
    $ICONS/gnome-ppp.png \
    "gnome-ppp &" \
    "$(gettext 'Dial-Up Configuaration (GNOME PPP)')" \
    "$(gettext 'Dialup connection tool')")

wpasupplicant_prog=/usr/sbin/wpa_gui
test -x $wpasupplicant_prog && wpasupplicant_entry=$(entry \
    $ICONS/wpa_gui.png \
    "/usr/sbin/wpa_gui &" \
    "$(gettext 'WPA Supplicant Configuration')" \
    "$(gettext 'Graphical user interface for wpa_supplicant')")

pppoeconf_prog=/usr/sbin/pppoeconf
test -x $pppoeconf_prog && pppoeconf_entry=$(entry \
    $ICONS/internet-telephony.png \
    "desktop-defaults-run -t /usr/sbin/pppoeconf &" \
    "$(gettext 'ADSL/PPPOE Configuration')" \
    "$(gettext 'User-friendly tool for initial configuration of a DSL (PPPoE) connection.')")

adblock_prog=/usr/local/bin/block-advert.sh
test -x $adblock_prog && adblock_entry=$(entry \
    $ICONS/advert-block.png \
    "gksu block-advert.sh &" \
    "$(gettext 'Adblock')" \
    "$(gettext 'Block adverts via /etc/hosts file')")

hostname_prog=/usr/local/bin/antiX-hostname-changer
tt_msg="$(gettext 'Changes the Computer name (hostname) in antiX for your local network. As a consequence this will change the displayed computer name in console windows. The hostname must be unique in your local network domain.')"
if test -x $hostname_prog; then
    hostname_entry=$(entry \
    $ICONS/antiXhnc_01.png \
    "urxvt -e sudo bash -c 'antiX-hostname-changer &'" \
    "$(gettext 'Hostname Changer')" \
    "$tt_msg")
else
    prerequisites_icon="$ICONS/antiXhnc_01.png"
    prerequisites_msg="$(gettext 'antiX-hostname-changer not found.')"
    prerequisites antix-hostname-changer
    hostname_entry=$(entry \
    $ICONS/antiXhnc_02.png \
    "$install_dialog; \
      if test -x $hostname_prog; then \
          rm $Lockfile; \
          sleep .2; \
          antixcc.sh n & \
          ( sleep 1; urxvt -e sudo bash -c 'antiX-hostname-changer' ) & \
      else \
          $install_fail; \
      fi" \
    "$(gettext 'Hostname Changer')" \
    "$tt_msg$absent")
fi

login_prog=/usr/local/bin/login-config-antix
test -x $login_prog && login_entry=$(entry \
    $ICONS/preferences-system-login.png \
    "gksu login-config-antix &" \
    "$(gettext 'Login Manager')" \
    "$(gettext 'Set default user, autologin, numeric keypad, login-design and -background ')")

slim_cc=/usr/local/bin/antixccslim.sh
slim_prog=/usr/bin/slim
test -x $slim_prog && test -x $slim_cc && slim_entry=$(entry \
    $ICONS/preferences-desktop-wallpaper.png \
    "gksu antixccslim.sh &" \
    "$(gettext 'Change Slim Background')" \
    "$(gettext 'This allows changing the background image of the welcome screen for the slim login manager')")

grub_prog=/usr/local/bin/antixccgrub.sh
test -x $grub_prog && grub_entry=$(entry \
    $ICONS/screensaver.png \
    "gksu antixccgrub.sh &" \
    "$(gettext 'Set Grub Boot Image')"\
    "$(gettext 'Here you can set the background image for the Grub boot menu. Only images in png format may be used.)')")

which ${EDITOR%% *} &>/dev/null && confroot_entry=$(entry \
    $ICONS/gnome-documents.png \
    "gksu $EDITOR /etc/fstab /etc/default/keyboard /etc/grub.d/* /etc/slimski.local.conf /etc/apt/sources.list.d/*.list &" \
    "$(gettext 'Edit Config Files')" \
    "$(gettext 'Manually edit the antiX startup configuration files for keyboard, grub, slimski login manager, and the package source repositories for your system.')")

which edit_antix_startup_file >/dev/null && edit_startup_entry=$(entry \
    $ICONS/panel_01.png \
    "edit_antix_startup_file &" \
    "$(gettext 'antiX autostart')" \
    "$(gettext 'Edit the antiX startup file ~/.desktop-session/startup, which resembles the “autostart” folder functionality in antiX. Make sure to have an ampersand trailing each command line.')")

arandr_prog=/usr/bin/arandr
test -x $arandr_prog && arandr_entry=$(entry \
    $ICONS/video-display.png \
    "arandr &" \
    "$(gettext 'Set Screen Resolution (ARandR)')" \
    "$(gettext 'Change resolution, orientation, aspect (format), output device (monitor, tv, svga etc.) for the primary and secondary display device.')")

gksu_prog=/usr/bin/gksu-properties
test -x $gksu_prog && gksu_entry=$(entry \
    $ICONS/gksu.png \
    "gksu-properties &" \
    "$(gettext 'Password Prompt (su/sudo)')" \
    "$(gettext 'Switch between su and sudo style of granting root access.')")

slimlogin_prog=/usr/local/bin/slim-login
test -x $slimlogin_prog && slimlogin_entry=$(entry \
    $ICONS/preferences-system-login.png \
    "gksu slim-login &" \
    "$(gettext 'Set Auto-Login')" \
    "$(gettext 'Set up or disable automatic login at system startup.')")

screenblank_prog=/usr/local/bin/set-screen-blank
test -x $screenblank_prog && screenblank_entry=$(entry \
    $ICONS/set-screen-blanking.png \
    "set-screen-blank &" \
    "$(gettext 'Set Screen Blanking')" \
    "$(gettext 'Define amount of time after which screen will blank and monitor power off, or disable screen blanking.')")

desktopsession_dir=/usr/share/doc/desktop-session-antix
test -d $desktopsession_dir  && desktopsession_entry=$(entry \
    $ICONS/preferences-system-session.png \
    "$EDITOR $HOME/.desktop-session/*.conf $HOME/.desktop-session/startup &" \
    "$(gettext 'User Desktop-Session')" \
    "$(gettext 'Manually edit the antiX desktop configuration files for startup, automount, desktop-defaults, desktop-session, mouse and wallpapers for you user account.')")

suspend_prog=/usr/local/bin/suspend_if_idle
if test -x $suspend_prog; then
  if ! grep '^[[:space:]]*suspend_if_idle' "$STARTUP_FILE" > /dev/null; then
    suspend_entry=$(entry \
    $ICONS/suspend_01.png \
    "timeout=\$(yad --on-top --center --title=\"\$(gettext \"Suspend computer if idle for...\")\" \
          --borders=20 --width=400 \
          --window-icon=$ICONS/suspend_01.png --form \
          --field=\"\$(gettext \"Select number of minutes:\") :NUM\" 15!1..600!1!0 | sed 's/.$//') & \
      wait \$!; \
      if ! test -z \$timeout; then \
          bash $AddStartup \"suspend_if_idle \$timeout &\" \
            '## Uncomment and set desired value to activate suspend timer at startup' \
            'suspend_if_idle [[:digit:]][[:digit:]]*[[:space:]][[:space:]]*&'; \
          suspend_if_idle \$timeout & \
          rm $Lockfile; \
          sleep .2; \
          antixcc.sh z & \
      fi" \
    "$(gettext 'Engage AutoSuspend')" \
    "$(gettext 'Starts suspend timeout and adds the selected amount of minutes to startup configuration.')")
  else
    CURRENT_TIMEOUT=$(grep ^[[:space:]]*suspend_if_idle $STARTUP_FILE | sed 's/^[[:space:]]*//' | cut -d' ' -f2)
    suspend_entry=$(entry \
    $ICONS/suspend_grey_01.png \
    "bash $RemoveStartup 'suspend_if_idle' '## Uncomment and set desired value to activate suspend timer at startup'; \
      if ! pidof suspend_if_idle ; then \
          suspend_if_idle 0 & \
      fi; \
      rm $Lockfile; \
      sleep .5; \
      antixcc.sh z &" \
    "$(gettext 'Disengage AutoSuspend')" \
    "$(gettext 'Stops suspend timeout and disables it in startup configuration. Currently timeout is configured to $CURRENT_TIMEOUT minutes.')")
  fi
fi

clipboard_prog=/usr/bin/clipit
if test -x $clipboard_prog; then
  if ! grep '^[[:space:]]*clipit[[:space:]]*&' "$STARTUP_FILE" > /dev/null; then
    clipit_entry=$(entry \
    $ICONS/clipit-trayicon.png \
    "bash $AddStartup 'clipit &' '## Uncomment to use clipboard manager'; \
      if ! pidof clipit; then \
          clipit & \
      fi; \
      rm $Lockfile; \
      sleep .5; \
      antixcc.sh z &" \
    "$(gettext 'Activate Clipboard manager')" \
    "$(gettext 'Starts extended clipboard functionality and puts an icon for management access to system tray')")
  else
    clipit_entry=$(entry \
    $ICONS/clipit-trayicon-offline.png \
    "bash $RemoveStartup 'clipit &' '## Uncomment to use clipboard manager'; \
      kill -15 $(pidof clipit 2>/dev/null); \
      rm $Lockfile; \
      sleep .5; \
      antixcc.sh z &" \
    "$(gettext 'Disengage Clipboard manager')" \
    "$(gettext 'Exits extended clipboard functionality and removes the icon for management access from system tray')")
  fi
fi

automount_prog=/usr/local/bin/automount-config
test -x $automount_prog && automount_entry=$(entry \
    $ICONS/mountbox.png \
    "automount-config &" \
    "$(gettext 'Configure Automount')" \
    "$(gettext 'Configure automounting and autoplay of USB- and Optical CD/DVD-devices, and the behaviour of file managers when a new medium was recognised.')")

mountbox_prog=/usr/local/bin/mountbox
test -x $mountbox_prog && mountbox_entry=$(entry \
    $ICONS/mountbox.png \
    "mountbox &" \
    "$(gettext 'Mount Connected Devices')" \
    "$(gettext 'Tool to mount devices')")

liveusb_prog_g=/usr/bin/live-usb-maker-gui-antix
liveusb_prog=/usr/bin/live-usb-maker
if test -x $liveusb_prog_g; then
liveusb_entry=$(entry \
    $ICONS/live-usb-maker.png \
    "gksu live-usb-maker-gui-antix &" \
    "$(gettext 'Live USB Maker (gui)')" \
    "$(gettext 'Create a live USB from an ISO.')")

elif test -x $liveusb_prog; then
liveusb_entry=$(entry \
    $ICONS/live-usb-maker.png \
     "desktop-defaults-run sudo &live-usb-maker &" \
     "$(gettext 'Live USB Maker (cli)')"
     "$(gettext 'Create a live USB from an ISO, console version.')")
fi

installer_prog=/usr/sbin/minstall
[ -x $installer_prog -a -n "$ITS_ALIVE" ] && installer_entry=$(entry \
    $ICONS/msystem_02.png \
    "gksu $installer_prog &" \
    "$(gettext 'Install antiX Linux')" \
    "$(gettext 'This installs antiX to your hard drive.')")

diskmanager_prog=/usr/sbin/disk-manager
test -x $diskmanager_prog && diskmanager_entry=$(entry \
    $ICONS/disk-manager.png \
    "gksu $diskmanager_prog &" \
    "$(gettext 'Disk Manager')" \
    "$(gettext 'Manage filesystem configuration')")

partimage_prog=/usr/sbin/partimage
test -x $partimage_prog && partimage_entry=$(entry \
    $ICONS/drive-harddisk-system.png \
    "desktop-defaults-run -t sudo partimage &" \
    "$(gettext 'Image a Partition')" \
    "$(gettext 'Backup partitions into a compressed image file')")

grsync_prog=/usr/bin/grsync
test -x $grsync_prog && grsync_entry=$(entry \
    $ICONS/grsync.png \
    "grsync &" \
    "$(gettext 'Synchronize Directories')" \
    "$(gettext 'A simple graphical interface for the rsync command line program.')")

gparted_prog=/usr/sbin/gparted
test -x $gparted_prog && gparted_entry=$(entry \
    $ICONS/gparted.png \
    "gksu gparted &" \
    "$(gettext 'Partition a Drive')" \
    "$(gettext 'Use gparted partitioning program to (re-)partition drives, (re-)format, check, label, resize and move partitions, manage partition flags, (re-)write partition tables MBR, GPT and some more, edit UUIDs etc.')")

drive_analysing_program=/usr/bin/baobab
tt_msg="$(gettext 'Explore in a Diagram what files eat up all the space on your partitions.')"
if test -x $drive_analysing_program; then
    drap_entry=$(entry \
    $ICONS/baobab_01.png \
    "$drive_analysing_program &" \
    "$(gettext 'Disk Usage Analyser')" \
    "$tt_msg")
else
    prerequisites_icon="$ICONS/baobab_01.png"
    prerequisites_msg="$(gettext 'Baobab not found.')"
    prerequisites baobab
    drap_entry=$(entry \
    $ICONS/baobab_02.png \
    "$install_dialog; \
      if test -x $drive_analysing_program; then \
          rm $Lockfile; \
          sleep .2; \
          antixcc.sh m & \
          ( sleep 1; $drive_analysing_program ) & \
      else \
          $install_fail; \
      fi" \
    "$(gettext 'Disk Usage Analyser')" \
    "$tt_msg$absent")
fi

setdpi_prog=/usr/local/bin/set-dpi
test -x $setdpi_prog && setdpi_entry=$(entry \
    $ICONS/fonts.png \
    "gksu set-dpi &" \
    "$dpi_label" \
    "$(gettext 'Change the size factor of screen font')")

inxi_prog=/usr/local/bin/inxi-gui
test -x $inxi_prog && inxi_entry=$(entry \
    $ICONS/info_blue.png \
    "inxi-gui &" \
    "$(gettext 'PC Information')" \
    "$(gettext 'Gather, display and store in-depth technical information about your device')")

mouse_prog=/usr/local/bin/ds-mouse
test -x $mouse_prog && mouse_entry=$(entry \
    $ICONS/input-mouse_01.png \
    "ds-mouse &" \
    "$(gettext 'Mouse Configuration')" \
    "$(gettext 'Modify the properties of your pointer device, e.g. set left hand mouse, set acceleration and threshold, double click period, pointer design and size etc. or set touchpad lockout')")

pointing_prog=/usr/local/bin/antiX-pdm
test -x $pointing_prog && pointing_entry=$(entry \
    $ICONS/input-mouse_01.png \
    "antiX-pdm &" \
    "$(gettext 'Pointing Device Manager')" \
    "$(gettext 'Configure touchpad, mouse, and other pointing input devices')")

soundcard_prog=/usr/local/bin/alsa-set-default-card
test -x $soundcard_prog && soundcard_entry=$(entry \
    $ICONS/soundcard.png \
    "alsa-set-default-card &" \
    "$(gettext 'Sound Card Chooser')" \
    "$(gettext 'Select the default soundcard device to be used.')")

# deal with the two mixer levels for pipewire an plain alsa support
mixer_prog=/usr/bin/alsamixer
pw_mixer_prog=/usr/bin/pavucontrol
if ! $plain_alsa; then 
    # entry for the aditional mixer on pipewire level
    test -x $pw_mixer_prog && pavucontrol_entry=$(entry \
    $ICONS/multimedia-volume-control.png \
    "pavucontrol &" \
    "$(gettext 'Adjust Pipewire-Layer Mixer')" \
    "$(gettext 'This provides the volume and device control for the additional PipeWire sound server layer, running on top of ALSA. Includes a tab to select the pipewire device-preset to be applied (e.g. »analog stereo duplex« or »pro-audio« etc).')")
    # set modified text and tooltip for alsa mixer entry, which is the primary level mixer as long as pipwire, using pavucontrol, is up.
    mixer_buttontext="$(gettext 'Basic System Mixer Adjustment')"
    mixer_tooltip="$(gettext 'This provides sliders on the basic ALSA level for all the available playback and recording channels of your soundcards, and switches for muting/unmuting them, as well as switches for additional functions like hardware loopback, auto-mute, dynamic loudness and the slider for the pre-amplifier.') $(gettext 'Try F6 button for managing sliders of your true hardware device(s) instead of the »pipewire« alsa device.') $(gettext 'Use mouse for all controls.') $(gettext 'Alternatively:') $(gettext 'Use right or left arrow keys ← → to scroll to sliders out of sight, use up and down arrow keys ↑↓ to increase or decrease slider setting of highlighted slider, use m key to toggle mute, and +/- keys for other switches.')"
else
    pavucontrol_entry=""
    mixer_buttontext="$(gettext 'Adjust Mixer')"
    mixer_tooltip="$(gettext 'This provides sliders for all the available playback and recording channels of your soundcards, and switches for muting/unmuting them, as well as switches for additional functions like hardware loopback, auto-mute, dynamic loudness and the slider for the pre-amplifier'). $(gettext 'Use mouse for all controls.') $(gettext 'Alternatively:') $(gettext 'Use right or left arrow keys ← → to scroll to sliders out of sight, use up and down arrow keys ↑↓ to increase or decrease slider setting of highlighted slider, use m key to toggle mute, and +/- keys for other switches.')"
fi
test -x $mixer_prog && mixer_entry=$(entry \
    $ICONS/audio-volume-high-panel.png \
    "urxvt -e alsamixer &" \
    "$mixer_buttontext" \
    "$mixer_tooltip")

ddm_prog=/usr/bin/ddm-mx
test -x $ddm_prog && nvdriver_entry=$(entry \
    $ICONS/nvidia-settings.png \
    "desktop-defaults-run -t su-to-root -c '/usr/bin/ddm-mx -i nvidia' &" \
    "$(gettext 'Nvidia Driver Installer')" \
    "$(gettext 'Install proprietary graphic device drivers for recent nvidia GPUs')")

snapshot_prog=/usr/bin/iso-snapshot
test -x $snapshot_prog && snapshot_entry=$(entry \
    $ICONS/gnome-do.png \
    "gksu iso-snapshot &" \
    "$(gettext 'ISO Snapshot')" \
    "$(gettext 'Create an ISO image of your currently running system, containing all installed programs and setup configurations.')")

soundtest_prog=/usr/bin/speaker-test
if $plain_alsa >/dev/null 2>&1; then
    soundtest_device=""
else
    #soundtest_device="-D pulse"    # for antiX 23.0
    soundtest_device="-D pipewire"  # for antiX 23.1
fi
test -x $soundtest_prog  && soundtest_entry=$(entry \
    $ICONS/preferences-desktop-sound.png \
    "desktop-defaults-run -t speaker-test $soundtest_device --channels 2 --test wav --nloops 3 &" \
    "$(gettext 'Test Sound')" \
    "$(gettext 'Check the system audio output channels.')")

pipewiretoggle_prog=/usr/local/bin/toggle_pipewire
if ! $plain_alsa >/dev/null 2>&1; then
    pipewiretoggle_icon="$ICONS/gnome-audio-red.png"
    pipewiretoggle_buttontext="$(gettext 'Disable PipeWire')"
    pipewiretoggle_tooltip="$(gettext 'Instantly disable PipeWire audio server and remove it from system startup.')"
else
    pipewiretoggle_icon="$ICONS/gnome-audio.png"
    pipewiretoggle_buttontext="$(gettext 'Enable PipeWire')"
    pipewiretoggle_tooltip="$(gettext 'Instantly enable PipeWire audio server and add it to system startup.')"
fi
test -x $pipewiretoggle_prog  && pipewiretoggle_entry=$(entry \
    $pipewiretoggle_icon \
    "bash -c 'setsid toggle_pipewire & p=\$!; wait \$p; sleep 2.5; pkill yad -g \$p; rm $Lockfile'; sleep .5; antixcc.sh o &" \
    "$pipewiretoggle_buttontext" \
    "$pipewiretoggle_tooltip")

menumanager_prog=/usr/local/bin/menu_manager.sh
test -x $menumanager_prog && menumanager_entry=$(entry \
    $ICONS/menu-editor.png \
    "sudo menu_manager.sh &" \
    "$(gettext 'Menu Editor')" \
    "$(gettext 'Activate and Deactivate entries in the Applications- and the Personal submenu of antiX System Main Menu.')")

usermanager_prog=/usr/bin/antix-user
test -x $usermanager_prog && usermanager_entry=$(entry \
    $ICONS/user-manager.png \
    "gksu antix-user &" \
    "$(gettext 'User Manager')" \
    "$(gettext 'Manage antiX system user accounts and user groups. Add or change passwords. Restore defaults')")

galternatives_prog=/usr/bin/galternatives
test -x $galternatives_prog && galternatives_entry=$(entry \
    $ICONS/galternatives.png \
    "gksu galternatives &" \
    "$(gettext 'Alternatives Configurator')" \
    "$(gettext 'Select the default programs used for specific tasks (e.g. like taking screenshots) on your antiX system.')")

codecs_prog=/usr/bin/codecs
test -x $codecs_prog && codecs_entry=$(entry \
    $ICONS/codecs.png \
    "gksu codecs &" \
    "$(gettext 'Codecs Installer')" \
    "$(gettext 'Simple install of restricted codecs')")

netassist_prog=/usr/sbin/network-assistant
test -x $netassist_prog && netassist_entry=$(entry \
    $ICONS/network-assistant_02.png \
    "gksu network-assistant &" \
    "$(gettext 'Network Assistant')" \
    "$(gettext 'Some basic networking checks in a GUI')")

repomanager_prog=/usr/bin/repo-manager
test -x $repomanager_prog && repomanager_entry=$(entry \
    $ICONS/repomanager_01.png \
    "gksu repo-manager &" \
    "$(gettext 'Repo Manager')" \
    "$(gettext 'Select the mirror for program package installation used by package management tools like apt, antiX package manager and Synaptic. Activate or deactivate preconfigured repositories.')")

which backlight-brightness &>/dev/null && [ -n "$(ls /sys/class/backlight 2>/dev/null)" ] \
    && backlight_entry=$(entry \
    $ICONS/backlight-brightness.png \
    "desktop-defaults-run -t backlight-brightness &" \
    "$(gettext 'Backlight Brightness')" \
    "$(gettext 'Adjust the brightness of the backlight from within a terminal.')")

which screenlight-menu.sh &>/dev/null \
    && screenlight_entry=$(entry \
    $ICONS/screenlight_01.png \
    "screenlight-menu.sh &" \
    "$(gettext 'Screen Brightness and Temperature')" \
    "$(gettext 'Adjust the brightness of the display from within a terminal. This doesn’t actually dim the backlight in monitors, but beclouds the screen by applying gamma and brightnes adjustment before sending screen content to the monitor.')")

tt_msg="$(gettext 'Search for and activate SCSI devices (e.g. document-scanners) powered on after system startup.')"
if which rescan-scsi-bus.sh > /dev/null; then
    scsi_rescan_entry=$(entry \
    $ICONS/SCSI-rescan_01.png \
    'urxvt -icon '$ICONS/SCSI-rescan_01.png' -title '\""$(gettext 'Scanning for SCSI devices...')"\"' -e bash -c "{ gksu -- rescan-scsi-bus.sh -a -l -w -c && sleep 4; }" &' \
    "$(gettext 'SCSI Bus rescan')" \
    "$tt_msg")
else
    prerequisites_icon="$ICONS/SCSI-rescan_01.png.png"
    prerequisites_msg="$(gettext 'SCSI-Tools not found.')"
    prerequisites sg3-utils scsitools
    scsi_rescan_entry=$(entry \
    $ICONS/SCSI-rescan_02.png \
    "$install_dialog; \
      if which rescan-scsi-bus.sh > dev/null; then \
          rm $Lockfile; \
          sleep .2; \
          antixcc.sh h & \
          ( sleep 1; rescan-scsi-bus.sh ) & \
      else \
          $install_fail; \
      fi" \
    "$(gettext 'SCSI Bus rescan')" \
    "$tt_msg"" $(gettext 'SCSI-tools not installed. Installs sg3-utils and scsitools packages.')")
fi

if which android-device-usb-connect.sh >/dev/null; then
    android_connect_entry=$(entry \
    $ICONS/a-phone_01.png \
    "android-device-usb-connect.sh &" \
    "$(gettext 'Android USB mounter')" \
    "$(gettext 'Mounts an Anroid device connected via USB. Make sure your device is set to MTP access mode and you have permissions set in its config accordingly.')")
fi

if which idevice-mounter >/dev/null; then
    imounter_entry=$(entry \
    $ICONS/i-phone_01.png \
    "idevice-mounter &" \
    "$(gettext 'I-Device mounter')" \
    "$('Mounts an Apple I-device connected via USB.')")
fi

tt_msg="$(gettext 'This initialises qsynth/fluidsynth, which can be configured for plain ALSA or Pipewire both, allowing loading high quality soundfonts into memory and providing a midi interface for other audio programs like vmpk or rosegarden to play the sounds from scores or by keying them in.')"
if which qsynth >/dev/null; then
    qsynth_entry=$(entry \
    $ICONS/qsynth_01.png \
    "(if ! [ -c /dev/snd/seq ]; then gksu modprobe snd_seq; fi; if ! wpctl status >/dev/null 2>&1; then qsynth -m alsa_seq -a alsa; else qsynth -m alsa_seq -a pulseaudio; fi) &" \
    "$(gettext 'Initialise Synthesizer')" \
    "$tt_msg")
else
    prerequisites_icon="$ICONS/qsynth_01.png"
    prerequisites_msg="$(gettext 'Qsynth/fluidsynth not found.')"
    prerequisites qsynth fluidsynth 
    qsynth_entry=$(entry \
    $ICONS/qsynth_01.png \
    "$install_dialog; \
      if test -x /usr/bin/qsynth; then \
          rm $Lockfile; \
          sleep .2; \
          antixcc.sh o & \
          ( sleep 1; if ! [ -c /dev/snd/seq ]; then gksu modprobe snd_seq; fi; if $plain_alsa; then qsynth -m alsa_seq -a alsa; else qsynth -m alsa_seq -a pulseaudio; fi) & \
      else \
          $install_fail; \
      fi" \
    "$(gettext 'Initialise Synthesizer')" \
    "$tt_msg$absent $(gettext 'You may want to install additionally a lossless soundfont.')")
fi

if which qjackctl >/dev/null; then
    qjackctl_entry=$(entry \
    $ICONS/apps/qjackctl_01.png \
    "qjackctl &" \
    "$(gettext 'Patchbay')" \
    "$(gettext 'Audio Switch field')")
fi

tt_msg="$(gettext 'A classical audio crossbar for PipeWire')"
if ! $plain_alsa; then
  if which qpwgraph >/dev/null; then
    qpwgraph_entry=$(entry \
    $ICONS/qpwgraph_08.png \
    "qpwgraph &" \
    "$(gettext 'Graphical Crossbar')" \
    "$tt_msg")
  else
    prerequisites_icon="$ICONS/qpwgraph_08.png"
    prerequisites_msg="$(gettext 'qpwgraph not found.')"
    prerequisites qpwgraph
    qpwgraph_entry=$(entry \
    $ICONS/qpwgraph_06.png \
    "$install_dialog; \
      if test -x /usr/bin/qpwgraph; then \
          rm $Lockfile; \
          sleep .2; \
          antixcc.sh o & \
          ( sleep 1; qpwgraph ) & \
      else \
          $install_fail; \
      fi" \
    "$(gettext 'Graphical Crossbar')" \
    "$tt_msg$absent")
  fi
fi

tt_msg="$(gettext 'Initialise provision of “Calf” sound manipulation plugin collection without need for any external host program.')"
if which calfjackhost >/dev/null && ( test -x /usr/bin/jackd || ! $plain_alsa ); then
    calf_entry=$(entry \
    $ICONS/calf_01.png \
    "if ! wpctl status >/dev/null 2>&1; then \
          calfjackhost ! reverb ! eq30 ! haasenhancer ! & \
    else \
          pw-jack calfjackhost ! reverb ! eq30 ! haasenhancer ! & \
    fi" \
    "$(gettext 'Audioeffekts and Filters')" \
    "$tt_msg")
else
    prerequisites_icon="$ICONS/calf_01.png"
    if $plain_alsa; then
        prerequisites_msg="$(gettext 'jackd and/or calfjackhost not found.')"
        prerequisites jackd2 calf-plugins
    else
        prerequisites_msg="$(gettext 'calfjackhost not found.')"
        prerequisites calf-plugins
    fi
    calf_entry=$(entry \
    $ICONS/calf_02.png \
    "$install_dialog; \
     if which calfjackhost >/dev/null && ( test -x /usr/bin/jackd || wpctl status >/dev/null 2>&1 ); then \
          rm $Lockfile; \
          sleep .2; \
          antixcc.sh o & \
          if ! wpctl status >/dev/null 2>&1; then \
              ( sleep 1; calfjackhost ! reverb ! eq30 ! haasenhancer ! ) & \
          else \
              ( sleep 1; pw-jack calfjackhost ! reverb ! eq30 ! haasenhancer ! ) & \
          fi; \
      else \
          $install_fail; \
      fi" \
    "$(gettext 'Audioeffekts and Filters')" \
    "$tt_msg$absent")
fi

if which blueman-manager >/dev/null; then
    bluemanman_entry=$(entry \
    $ICONS/bluetooth_01.png \
    "blueman-manager &" \
    "$(gettext 'Bluetooth Manager')" \
    "$(gettext 'Manage Bluetooth-system connections and adapters')")
fi

if which blueman-adapters >/dev/null; then
    bluemanadapters_entry=$(entry \
    $ICONS/bluetooth_01.png \
    "blueman-adapters &" \
    "$(gettext 'Bluetooth Adapters')" \
    "$(gettext 'Bluetooth-system hardware setup')")
fi

if which sakis3g >/dev/null; then
    sakis3g_entry=$(entry \
    $ICONS/plasma-mobile-phone_01.png \
    "desktop-defaults-run -t sakis3g --interactive &" \
    "$(gettext '3G Modem Manager')" \
    "$(gettext 'Set up connections to 3g-networks using sakis3g')")
fi

if which modem-manager-gui >/dev/null; then
    modemmanager_entry=$(entry \
    $ICONS/modem-manager-gui_01.png \
    "modem-manager-gui &" \
    "$(gettext 'Broadband Modem Manager')" \
    "$(gettext 'Control EDGE/3G/4G broadband modem specific functions')")
fi

if which solaar >/dev/null; then
    solaar_entry=$(entry \
    $ICONS/solaar_01.png \
    "solaar &" \
    "$(gettext 'Logitech receiver')" \
    "$(gettext 'Hardware configurator for Logitech remote device receivers')")
fi

if which onboard-settings >/dev/null; then
    onboard_entry=$(entry \
    $ICONS/onboard_01.png \
    "onboard-settings &" \
    "$(gettext 'Virtual keyboard config')" \
    "$(gettext 'Set up “Onboard” virtual keyboard')")
fi

if which firejail-ui >/dev/null; then
    firejail_entry=$(entry \
    $ICONS/firejail-tools-settings.png \
    "firejail-ui &" \
    "$(gettext 'Security Sandbox Config')" \
    "$(gettext 'Wizard for setting up firejail.')")
else
    prerequisites_icon="$ICONS/firejail-tools-settings.png"
    prerequisites_msg="$(gettext 'firejail-ui not found.')"
    prerequisites firetools
    firejail_entry=$(entry \
    $ICONS/firejail-ui.png \
    "$install_dialog; \
      if test -x /usr/bin/firejail-ui; then \
          rm $Lockfile; \
          sleep .2; \
          antixcc.sh w & \
          ( sleep 1; firejail-ui ) & \
      else \
          $install_fail; \
      fi" \
    "$(gettext 'Security Sandbox Config')" \
    "$(gettext 'Wizard for setting up firejail.') $(gettext 'Firetools are not installed. This installs the firetools package first.')")
fi

if test -x /usr/local/lib/desktop-session/desktop-session-menu-window >/dev/null; then
    odesktops_entry=$(entry \
    $ICONS/default-user-desktop_01.png \
    "/usr/local/lib/desktop-session/desktop-session-menu-window ignore-settings &" \
    "$(gettext 'Other desktops')" \
    "$(gettext 'Select from and switch on the fly to other available desktops.')")
fi

if which formatusb >/dev/null; then
    usbfmt_entry=$(entry \
    $ICONS/media-flash-memory-stick_01.png \
    "gksu formatusb &" \
    "$(gettext 'Format USB drive')" \
    "$(gettext 'Create or recreate a file system on your USB storage device.')")
fi

tt_msg="$(gettext 'Show available characters from all installed fonts and copy special characters into clipboard. Look up UTF Code Points.')"
if which gucharmap >/dev/null; then
    charmap_entry=$(entry \
    $ICONS/accessories-character-map_01.png \
    "gucharmap &" \
    "$(gettext 'Character Map')" \
    "$tt_msg")
else
    prerequisites_icon="$ICONS/accessories-character-map_01.png"
    prerequisites_msg="$(gettext 'gucharmap not found.')"
    prerequisites gucharmap
    charmap_entry=$(entry \
    $ICONS/accessories-character-map_02.png \
    "$install_dialog; \
      if test -x /usr/bin/gucharmap; then \
          rm $Lockfile; \
          sleep .2; \
          antixcc.sh s & \
          ( sleep 1; /usr/bin/gucharmap ) & \
      else \
          $install_fail; \
      fi" \
    "$(gettext 'Character Map')" \
    "$tt_msg$absent")
fi

if which qt5ct >/dev/null; then
    qt5_entry=$(entry \
    $ICONS/qtconfig-qt5_01.png \
    "qt5ct &" \
    "$(gettext 'Customise QT5 Look and Feel')" \
    "$(gettext 'Configure appearance of qt5 based programs, which don’t obey to system’s general look and feel')")
fi

if which qt6ct >/dev/null; then
    qt6_entry=$(entry \
    $ICONS/qtconfig-qt6_01.png \
    "qt6ct &" \
    "$(gettext 'Customise QT6 Look and Feel')" \
    "$(gettext 'Configure appearance of qt6 based programs, which don’t obey to system’s general look and feel')")
fi

if which add-key >/dev/null; then
    akey_entry=$(entry \
    $ICONS/preferences-desktop-keyboard-shortcuts_01.png \
    "add-key &" \
    "$(gettext 'Add Key')" \
    "$(gettext 'Add keybinds to fluxbox, jwm, icewm key files')")
fi

if which antiX-workspace-manager >/dev/null; then
    awm_entry=$(entry \
    $ICONS/antiX-workspace-count_01.png \
    "antiX-workspace-manager &" \
    "$(gettext 'antiX Workspace Manager')" \
    "$(gettext 'Manage the number and name of IceWM workspaces')")
fi

if ! $plain_alsa && which antiX-acoustic-colours >/dev/null; then
    aac_entry=$(entry \
    /usr/share/icons/antix-papirus/antiXac.png \
    "antiX-acoustic-colours &" \
    "$(gettext 'Acoustic Colours')" \
    "$(gettext 'Switch in a simple GUI between some common audio presets changing acoustic colour, like in an old-school tube radio: Bass, Treble, Solo, Orchestra, Jazz, Speech...')")
fi

[ -e /etc/live/config/save-persist -o -e /etc/live/config/persist-save.conf ]  && persist_save=$(entry \
    $ICONS/palimpsest.png \
    "gksu persist-save &" \
    "$(gettext 'Save Root Persistence')" \
    "$(gettext 'Save filesystem changes when running persistence')")

[ -e /etc/live/config/remasterable -o -e /etc/live/config/remaster-live.conf ] && live_remaster=$(entry \
    $ICONS/remastersys.png \
    "gksu live-remaster &" \
    "$(gettext 'Remaster-Customize Live')" \
    "$(gettext 'Remaster your Live USB device to your current system state. The remastered device will contain all currently installed and updated programs. Use personal to make your individual settings permanent. In order to make an installed kernel active use the antiX Live kernel updater tool once the kernel was integrated into the Live USB device by using this remaster tool. All this applies also to antiX frugal installations.')")

live_tab=$(cat<<Live_Tab
$(vbox_frame_hbox \
"$(vbox \
"$(entry "$ICONS/pref.png" "gksu persist-config &" "$(gettext 'Configure Live Persistence')" \
"$(gettext 'Set up the way how Live Persistence will save changes to the persistence container file residing in USB device on shutdown (Automatic, Semiautomatic, Manually etc.)')")" \
"$livekernel_entry" "$bootloader_entry" "$persist_save")" \
"$(vbox \
"$(entry $ICONS/persist-makefs.png "gksu persist-makefs &" "$(gettext 'Set Up Live Persistence')" "$(gettext 'Set up persistence by creating a persistence container file on the live USB device, allowing to run the live antiX system like an installed system, either for Root file system or for User’s Home folder or for both. Also resize, change device or path to container, manage deletion of formerly used persistence- or remastered linuxfs-containers.')")" \
"$excludes_entry" "$live_remaster" "$installer_entry")")
Live_Tab
)

function print_help {
    cat <<HELP

$(gettext 'antiX Control Centre')

    $(gettext 'The GUI dashboard for antiX maintenance and fine tuning.')

$(gettext 'Usage: antixcc.sh ‹option›')

    $(gettext 'Use tab name or shorthand to access a tab directly.')

$(gettext 'Valid options (tabs) :')
    $(gettext 'Desktop            ')$or a
    $(gettext 'Software           ')$or p
    $(gettext 'System             ')$or s
    $(gettext 'Network            ')$or n
    $(gettext 'Shares             ')$or f
    $(gettext 'Session            ')$or z
    $(gettext 'Live               ')$or l   ($(gettext 'Only valid if running on a live antiX.'))
    $(gettext 'Disks              ')$or m
    $(gettext 'Audio              ')$or o
    $(gettext 'Hardware           ')$or h
    $(gettext 'Drivers            ')$or t
    $(gettext 'Maintenance        ')$or w
    $(gettext 'Services           ')$or d

$(gettext 'Other valid options (command line) :')
    $(gettext 'Help')   $(gettext 'or') --help $(gettext 'or') -h   →  $(gettext 'prints this command line help text.')
    $(gettext 'Version')   $(gettext 'or') --version $(gettext 'or') -v  → $(gettext 'prints version string.')

    ($(gettext 'The shorthands are stable, while long options are translated'))

$(gettext 'Remark: If you find some tools missing in the GUI, please make sure to
    have installed all the packages listed in the package’s recommendations
    entry. See “$ apt-cache show control-centre-antix” for details.')

$(gettext 'Questions, suggestions, bug reporting:') https://www.antixforum.com

$(gettext 'License:') GPL v.3

  Copyright 2008-2026 antiX
  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the  Free Software Foundation, either  version 3  of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but  WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY  or  FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public
  License along with this program.  If not, see

	<http://www.gnu.org/licenses/>.

HELP
    exit 0
}

case $1 in
    "$(gettext 'Desktop            ' |tr -d ' ')"|a)     tab_page=0;;
    "$(gettext 'Software           ' |tr -d ' ')"|p)     tab_page=1;;
    "$(gettext 'System             ' |tr -d ' ')"|s)     tab_page=2;;
    "$(gettext 'Network            ' |tr -d ' ')"|n)     tab_page=3;;
    "$(gettext 'Shares             ' |tr -d ' ')"|f)     tab_page=4;;
    "$(gettext 'Session            ' |tr -d ' ')"|z)     tab_page=5;;
    "$(gettext 'Live               ' |tr -d ' ')"|l)     tab_page=6; if ! its_alive; then gettext 'Not running on live. Please select another tab.'; echo; exit 1; fi;;
    "$(gettext 'Disks              ' |tr -d ' ')"|m)     tab_page=$((6+s));;
    "$(gettext 'Audio              ' |tr -d ' ')"|o)     tab_page=$((7+s));;
    "$(gettext 'Hardware           ' |tr -d ' ')"|h)     tab_page=$((8+s));;
    "$(gettext 'Drivers            ' |tr -d ' ')"|t)     tab_page=$((9+s));;
    "$(gettext 'Maintenance        ' |tr -d ' ')"|w)     tab_page=$((10+s));;
    "$(gettext 'Services           ' |tr -d ' ')"|d)     tab_page=$((11+s));;
    "$(gettext 'Help')"|"--help"|"-h")  print_help;;
    "$(gettext 'Version')"|"--version"|"-v") gettext "antiX Control Centre"; echo " $version"; exit 0;;
    "-d"|"--debug") debug=true;;
    ''):;;
    *) export o="$1"; eval_gettext 'Invalid command line option »$o«. Try Help or --help or -h'; echo; exit 1;;
esac

# If we are on a live system then ...
if its_alive; then
    tab_labels="$Desktop|$Software|$System|$Network|$Shares|$Session|$Live|$Disks|$Audio|$Hardware|$Drivers|$Maintenance | $Services"

else
    tab_labels="$Desktop|$Software|$System|$Network|$Shares|$Session|$Disks|$Audio|$Hardware|$Drivers|$Maintenance | $Services"
    live_tab=''
fi

export ControlCenter=$(cat<<Control_Center
<window title="$windowheader" window-position="1" icon-name="control-centre-antix">
  <vbox>
<notebook tab-pos="0" labels="$tab_labels" page="$tab_page">
$(vbox_frame_hbox \
"$(vbox "$wallpaper_entry" "$icewm_entry" "$jwm_entry" "$fluxbox_entry" "$icewmgui_entry" "$akey_entry")" \
"$(vbox "$setdpi_entry" "$lxappearance_entry" "$qt5_entry" "$qt6_entry" "$conky_entry" "$prefapps_entry" "$odesktops_entry")" )

$(vbox_frame_hbox \
"$(vbox "$antixupdater_entry" "$antixautoremove_entry" "$debinstaller_entry")" \
"$(vbox "$repomanager_entry" "$packageinstaller_entry" "$cli_aptix_entry" "$synaptic_entry")" )

$(vbox_frame_hbox \
"$(vbox "$galternatives_entry" "$onboard_entry" "$localisation_entry" "$iomon_entry" "$fontman_entry" "$charmap_entry")" \
"$(vbox "$systemkeyboard_entry" "$keyboardlayout_entry" "$tzdata_entry" "$process_entry" "$memorymanager_entry")" )

$(vbox_frame_hbox \
"$(vbox "$wifi_entry $connman_entry" "$ceni_entry" "$pppoeconf_entry" "$hostname_entry")" \
"$(vbox "$gnomeppp_entry" "$wpasupplicant_entry" "$firewall_entry" "$adblock_entry" "$ufwtoggle_entry")" )

$(vbox_frame_hbox \
"$(vbox "$connectshares_conf_entry" "$droopy_entry"  "$cloud_entry" "$assistant_entry" "$voice_entry")" \
"$(vbox "$connectshares_entry" "$disconnectshares_entry" "$shared_entry" "$sshconduit_entry")" )

$(vbox_frame_hbox \
"$(vbox "$arandr_entry" "$gksu_entry" "$grub_entry" "$compositor_entry" "$awm_entry" "$suspend_entry")" \
"$(vbox "$login_entry" "$screenblank_entry" "$desktopsession_entry" "$screenlight_entry" "$clipit_entry")")

$live_tab

$(vbox_frame_hbox \
"$(vbox "$automount_entry" "$mountbox_entry" "$diskmanager_entry" "$drap_entry" "$usbfmt_entry")" \
"$(vbox "$liveusb_entry" "$partimage_entry" "$grsync_entry" "$gparted_entry")")

$(vbox_frame_hbox \
"$(vbox "$soundcard_entry" "$soundtest_entry" "$qsynth_entry" "$qpwgraph_entry" "$qjackctl_entry" "$calf_entry" "$aac_entry")" \
"$(vbox "$pipewiretoggle_entry" "$mixer_entry" "$pavucontrol_entry" "$eq_toggle_entry" "$equalizer_entry")" )

$(vbox_frame_hbox \
"$(vbox "$printer_entry" "$mouse_entry" "$pointing_entry" "$backlight_entry" "$scsi_rescan_entry" "$android_connect_entry" "$imounter_entry")" \
"$(vbox "$inxi_entry" "$solaar_entry" "$bluemanadapters_entry" "$bluemanman_entry" "$modemmanager_entry" "$sakis3g_entry")")

$(vbox_frame_hbox \
"$(vbox "$nvdriver_entry" "$ndiswrapper_entry")" \
"$(vbox "$codecs_entry")" )

$(vbox_frame_hbox \
"$(vbox "$snapshot_entry" "$backup_entry" "$edit_startup_entry" "$netassist_entry" "$firejail_entry")" \
"$(vbox "$bootrepair_entry" "$rescue_scan_entry" "$confroot_entry" "$menumanager_entry" "$usermanager_entry")" )

$(vbox_frame_hbox \
"$(vbox "$sysvconf_entry"  "$runitconf_entry" "$initmanager_entry")" \
"$(vbox "$s6conf_entry" "$dinitconf_entry")" )

</notebook>
</vbox>
</window>
Control_Center
)

if $debug; then
  echo "$ControlCenter" > ccdlg.txt
  cat -n ccdlg.txt
  exit
fi

gtkdialog --program=ControlCenter
#unset ControlCenter
