Linux Lite 8.0 RC1 has been released - Click here


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

Update for lite-software logic
#11

Then, this is what I have for /usr/bin/lite-software  64 BIT


Code:
#! /bin/bash
#--------------------------------------------------------------------------------------------------------
# Name: Linux Lite Additional Software Install
# Authors: Misko_2083, Jerry Bezencon, gerito1, Johnathan "ShaggyTwoDope" Jenkins, Ralphy
# Website: https://www.linuxliteos.com
#--------------------------------------------------------------------------------------------------------

# Ensure multi-language support
export LANG=C

# Kill off any package managers that may be running
if [ "$(pidof synaptic)" ]
then
   sudo killall -9 synaptic
fi

if [ ! -z "$(pgrep gdebi-gtk)" ]
then
   killall -9 gdebi-gtk
fi

# Set up log facilities
# Example output: [02/06/15 20:03:12] message input
LOGFILE=/var/log/lite-software.log
log(){
    message="$@"
    echo '['$(date +%D\ %H:%M:%S)'] '$message >>$LOGFILE
}

# Log last activities to retrieve errors
TMP_LOG=/tmp/lite-software.log

prepare(){
  # Check internet access
  if eval "sudo -u ${SUDO_USER:-$USER} curl -sk google.com/" >> /dev/null 2>&1; then
    : # pass
  else # Prompt ERROR internet connection
    (zenity --info --ok-label="Got it!" --title="No Internet connection detected..." \
           --text="\n<b>Your computer does not seem to be connected to the internet</b> \n \nYou won't be able to install applications packages needed to be downloaded from the Internet." --no-wrap)
    return
  fi
   # Check if apt-cache was built and ask to update           
  if zenity --question --width=400 --height=120 --title="     Update software sources" --text="\n<b>Would you like to update your software sources now?</b>\n\nClick 'No' to continue without updating software sources or 'Yes' to update software sources next. \n \nIt is recommended to always update software sources before installing applications."; then
      TOTALREPOS=$(cat /etc/apt/sources.list | grep '^deb' -c) # Total of repositories registered, this is approximated
      sudo apt-get update 2>&1 | awk -v total=$TOTALREPOS '/^Ign|^ Get/{count++;$1=""} FNR { if (total != 0){percentage=int (100*count/total);print (percentage < 90?percentage:90),"\n#",$0 }; fflush(stdout)}' \
      | zenity --progress --text="Updating package lists..." --title="Updating Software Sources - please wait..." --percentage=0 --auto-close --width=600
      if [ "${PIPESTATUS[0]}" -ne "0" ]; then
        zenity --error --title="          Error" --width=300 --height=90 --text="\n<b>Updating sources has failed</b>\n\nRefer to /var/log/lite-software.log for more information."
        log "ERROR: Updating sources has failed."
        next
      fi
        log "INFO: Software sources were updated."
      else
        log "INFO: The updating of packages was cancelled by the user"
        next
  fi
}

# Set app icon variable
APPICON=/usr/share/litesoftware/appicons/

#--------------------------------------------------------------------------------------------------------
# soft_list is the list of package aliases to check/install/remove
# Consist in a list describing aspect for every package
# package_alias=( "element 0" "element 1" "element 2" "element 3" "element 4" "element 5" "element 6")
# element 0: TRUE\FALSE for being selected
# element 1: The Application name ie: Google Chrome, iDevices Manager
# element 2: The category which belongs to (one only) ie:  Internet, Multimedia
# element 3: Status of the package ie: Installed, Not Installed
# element 4: Description of the package ie: "Easily locate files and folders in your computer", "Clementine is a modern music player and library organizer"
# element 5: List of packages needed to provide the application ie: "aisleriot gnome-mahjongg gnome-mines gnome-hearts"
# element 6: List of additional packages (this is optional) ie: libavformat-extra-54
#--------------------------------------------------------------------------------------------------------
soft_list=(audacity
  calibre
  cherrytree
  chromiumbr
  dropbox
  gamespack
  idevices
  imessenger
  kodi
  clementine
  passmgr
  pinta
  playonlinux
  remote
  extras
  skype
  spotify
  steam
  teamviewer
  torrent
  tor
  videoedit
  vbox
  weather
  guvcview
  wine )

audacity=("$APPICON/audacity.png" "Audacity" "Multimedia" "" "Software for recording and editing sounds" "audacity" "" )
calibre=("$APPICON/calibre.png" "Calibre" "Office" "" "A free and open source e-book library management application" "calibre" "" )
cherrytree=("$APPICON/cherrytree.png" "Cherrytree" "Accessories" "" "A hierarchical note taking application" "cherrytree" "" )
chromiumbr=("$APPICON/chromium.png" "Chromium Web Browser" "Internet" "" "Open-source alternative to the Google Chrome web browser" "chromium-browser" "" )
dropbox=("$APPICON/dropbox.png" "Dropbox" "Internet" "" "A popular cloud storage application" "dropbox thunar-dropbox-plugin" "" )
gamespack=("$APPICON/gamespack.png" "Games Pack" "Games" "" "Provides with Solitaire, Mahjongg, Mines and Hearts games" "aisleriot gnome-mahjongg gnome-mines gnome-hearts" "" )
idevices=("$APPICON/gtkpod.png" "iDevices Manager" "Multimedia" "" "Manage your iDevices with Gtkpod" "gtkpod" "" )
imessenger=("$APPICON/pidgin.png" "Instant Messenger" "Internet" "" "Pidgin, a multi-protocol Instant Messenging client" "pidgin" "" )
kodi=("$APPICON/kodi.png" "Kodi" "Multimedia" "" "The Kodi Media Center (formerly known as XBMC)" "kodi" "" )
clementine=("$APPICON/clementine.png" "Music Player" "Multimedia" "" "Clementine is a modern music player and library organizer" "clementine" "")
passmgr=("$APPICON/keepassx.png" "Password Manager" "Accessories" "" "KeePassX, an excellent password manager" "keepassx" "" )
pinta=("$APPICON/pinta.png" "Pinta" "Graphics" "" "An easy to use drawing program similar to Paint.Net" "pinta" "" )
playonlinux=("$APPICON/playonlinux.png" "PlayOnLinux" "Cross Platform" "" "Use numerous games and apps designed to run with Windows" "playonlinux" "" )
remote=("$APPICON/remmina.png" "Remote Desktop Software" "Internet" "" "Remmina Remote Desktop Client for Windows (RDP) and VNC Servers" "remmina" "" )
extras=("$APPICON/extras.png" "Restricted Extras" "Multimedia" "" "Additional codecs and useful file formats" "ubuntu-restricted-extras" "libavcodec-extra" )
skype=("$APPICON/skype.png" "Skype" "Internet" "" "A popular audio and video chat application" "skype-bin" "skype" )
spotify=("$APPICON/spotify.png" "Spotify" "Multimedia" "" "Spotify is a digital music service" "spotify-client" "" )
steam=("$APPICON/steam.png" "Steam" "Games" "" "Steam is a cross platform gaming client" "steam-launcher" "" )
teamviewer=("$APPICON/teamviewer.png" "Teamviewer" "Internet" "" "Teamviewer Remote Desktop Support software" "teamviewer:i386" "" )
torrent=("$APPICON/deluge.png" "Torrent Software" "Internet" "" "Deluge Torrent client software" "deluge deluge-common" "" )
tor=("$APPICON/tor.png" "Tor Web Browser" "Internet" "" "Tor Web Browser a privacy respecting web browser" "tor-web-browser" "" )
videoedit=("$APPICON/openshot.png" "Video Editing Software" "Multimedia" "" "Openshot, a simple to use yet powerful video editor for linux" "openshot blender imagemagick" "")
vbox=("$APPICON/virtualbox.png" "VirtualBox" "System" "" "Install other operating systems like Windows from within Linux Lite" "virtualbox" "" )
weather=("$APPICON/weather.png" "Weather Monitor" "System Tray" "" "A Weather Monitor Plugin for your tray" "xfce4-weather-plugin" "" )
guvcview=("$APPICON/guvcview.png" "Webcam Software" "Internet" "" "Guvcview, webcam software for your computer" "guvcview" "" )
wine=("$APPICON/wine.png" "Wine" "Cross Platform" "" "Install and run some Windows programs and games on Linux Lite" "wine1.8" "")

get_pkg_status(){
  result="Installed"
  for PKG in  $@
  do
    TEST_PKG=(`apt-cache policy $PKG | grep "Installed:"`)
    if [ "${TEST_PKG[1]}" == "(none)" ];then
      result="Not Installed"
      break
    fi
  done
  read ${2} <<< $result
  unset result
  unset TEST_PKG
}

# Check for installed packages
check_installed(){
  for element in ${soft_list[*]}
  do
    current_pkg=$element[5]
    status=$element[3]
    get_pkg_status "${!current_pkg}" status # Get the status of the main package
    read ${element}"[3]" <<< $status        # Write the status in the package status
  done
}

install_pkgs(){
  declare -a pkg_arr=("${!1}")

  log "INFO: Installation of packages initiated: ${pkg_arr[@]}"
  sudo apt-get install -f --show-progress ${pkg_arr[@]} --force-yes -y 2>&1 | tee $TMP_LOG | awk ' BEGIN { FS=" "; total=1;end_download=0} /upgraded/ {total= $1 + $3;FS="[ :]" } /^Get:[[:digit:]]+/ {printf "#Downloading %s %s %s\n",$7,$(NF-1),$NF;print int(($2 - 1) * 100 / total); fflush(stdout)} /^\(Reading / {if (end_download==0){print 100;fflush(stdout);end_download=1}} /^(Preparing|Unpacking|Selecting|Processing|Setting|Download)/ {print "#", $0; fflush(stdout)}  /^Progress/ {print  match($0, /([0-9]+)/, arr); if(arr[1] != "") print arr[1] ; fflush(stdout)}' \
   | ( zenity --window-icon=$ic --progress --width=600 --text="Downloading package(s)...\nThis may take a while." --title="Downloading - please wait..." --percentage=0 --auto-close ; zenity --progress --window-icon=$ic --width=600 --text="Installing and configuring packages...\nThis may take a while." --title="Installing - please wait..." --auto-close )
  if [ "${PIPESTATUS[0]}" -ne "0" ]; then
    err_msg=$(awk '/^E:/{$1=""; print $0}' $TMP_LOG | tail -n 1)
    log "ERROR:$err_msg"
    zenity --error --title="Error" --text="Error\n$err_msg"
    return
  else
    zenity --info --width=240 --height=80 --title="          Installation Info" --text="\nInstallation successfully completed!"
    log "INFO: Installation was a success."
  fi
}

remove_pkgs(){
  declare -a pkg_arr=("${!1}")

  log "INFO: Removal of packages initiated: ${pkg_arr[@]}"
  sudo apt-get remove -f ${pkg_arr[@]} --force-yes -y 2>&1 | tee $TMP_LOG | awk ' BEGIN { FS=" "; total=0; pkg=0}  /upgraded/ {total=$6 } /^Removing/ {print "#", $0;pkg+=1;print int((pkg - 1) * 100 / total); fflush(stdout)}' \
    | zenity --progress --window-icon=$ic --width=600 --text="Removing package(s)...\nThis may take a while." --title="Removing Software - please wait..." --percentage=0 --auto-close
  if [ "${PIPESTATUS[0]}" -ne "0" ]; then
    err_msg=$(awk '/^E:/{$1=""; print $0}' $TMP_LOG | tail -n 1)
    log "ERROR:$err_msg"
    zenity --error --title="Error" --text="Error\n$err_msg"
    return
  else
    zenity --info --width=240 --height=80 --title="          Removal Info" --text="\nRemoval successfully completed!"
    log "INFO: Removal was a success."
  fi
}

# The installation menu
install_menu(){
  check_installed
  ic="/usr/share/icons/zenity-llcc.png"
  selection=$(for element in ${soft_list[*]}
    do
      row=$element[@]                          #grab the whole row
      printf  '%s\n' "${!row}"                 #print every element in the row separated with a newline
    done | zenity --window-icon="$ic" --list --imagelist --multiple --width=920 --height=760 --print-column=2,6,7 --separator="| " --column="Select" --column="Name" --column="Category" --column="Status" \
      --column="Description" --column="Packages" --column="Optional Packages" --text="Select the program you wish to install, then click the Install button. \n\n- <b>Sort</b> columns by clicking on column headers. \n- <b>Ctrl key</b> - allows you to click and select multiple applications that are <b>anywhere</b> on the list, not necessarily next to each other. \n- <b>Shift key</b> - allows you to select a group of applications that are <b>contiguous</b> (next to each other) by clicking one application, then holding <b>Shift</b> \n  and clicking the last application you want from the list, all the applications in between will be selected.\n " \
      --title="Install Additional Software" --ok-label="Install" --hide-column=6,7 )

  # If Cancel is clicked then return to main loop
  if [ "${PIPESTATUS[0]}" -ne "0" ]; then
    return
  fi
 
  # Check if anything is selected
  echo $selection | grep '[a-zA-Z0-9]'
  if [ "${PIPESTATUS[1]}" -ne "0" ]; then
    zenity --info  --width=280 --title='     Install Additional Software' --text='\nNo application was selected for installation.'
    return
  fi

  # Split selection
  OIFS=$IFS
  IFS='|'
  selection_array=($selection)
  PKGS_NAMES=""
  PKGS=""
  for ((i=0; i<${#selection_array[@]}; ++i));
  do
    if (( i % 3 == 0 )); then
      PKGS_NAMES=$PKGS_NAMES${selection_array[$i]}"\n"
      continue
    fi
    PKGS=$PKGS${selection_array[$i]}" "
  done
  IFS=$OIFS

  zenity --question  --width=360 --title="          Install Software" --window-icon="${ic}" --text="\n<b>The following software has been selected</b>:\n\n $PKGS_NAMES \nDo you want to proceed with the installation?"
  if [ "$?" -eq "0" ]; then
    install_pkgs PKGS[@]
  else
    return
  fi
}

# The installation menu
remove_menu(){

  check_installed
  ic="/usr/share/icons/zenity-llcc.png"

  selection=$(for element in ${soft_list[*]}
    do
      pkg_status=$element[3]
      #Only list Installed applications
      if [ "${!pkg_status}" == "Not Installed" ]; then
        continue;
      fi
      row=$element[@]                          #grab the whole row
      printf  '%s\n' "${!row}"                 #print every element in the row separated with a newline
    done | zenity --window-icon="$ic" --list --imagelist --multiple --width=920 --height=760 --print-column=2,6 --separator="| " --column="Select" --column="Name" --column="Category" --column="Status" \
      --column="Description" --column="Packages" --column="Optional Packages" --text="Select the program you wish to remove, then click the Remove button. \n\n- <b>Sort</b> columns by clicking on column headers. \n- <b>Ctrl key</b> - allows you to click and select multiple applications that are <b>anywhere</b> on the list, not necessarily next to each other. \n- <b>Shift key</b> - allows you to select a group of applications that are <b>contiguous</b> (next to each other) by clicking one application, then holding <b>Shift</b> \n  and clicking the last application you want from the list, all the applications in between will be selected." \
      --title="Remove Additional Software" --ok-label="Remove" --hide-column=6,7 )

  # If Cancel is clicked then return to main loop
  if [ "${PIPESTATUS[0]}" -ne "0" ]; then
    return
  fi

  # Check if anything is selected
  echo $selection | grep '[a-zA-Z0-9]'
  if [ "${PIPESTATUS[1]}" -ne "0" ]; then
    zenity --info --width=260 --title='          Remove Software' --text='\nNo application was selected for removal.'
    return
  fi

  # Split selection
  OIFS=$IFS
  IFS='|'
  selection_array=($selection)
  PKGS_NAMES=""
  PKGS=""
  for ((i=0; i<${#selection_array[@]}; ++i));
  do
    if (( i % 2 == 0 )); then
      PKGS_NAMES=$PKGS_NAMES${selection_array[$i]}"\n"
      continue
    fi
    PKGS=$PKGS${selection_array[$i]}" "
  done
  IFS=$OIFS
  zenity --question --width=360 --title="          Remove Software" --window-icon="${ic}" --text="\n<b>The following software has been selected</b>:\n\n $PKGS_NAMES \n Do you want to proceed  with the removal?"
  if [ "$?" -eq "0" ]; then
    remove_pkgs PKGS[@]
  else
    return
  fi
}

# We begin here
prepare
pkg_manager_check
# The main loop
while (true); do
  ic="/usr/share/icons/zenity-llcc.png"
  TASK=$(zenity --width=280 --height=160 --list --radiolist --window-icon=$ic --text="Select a task:" \
    --title="          Lite Software" --column="Select" --column="Task" --column="Code Task" --hide-column=3 \
    --print-column=3 --cancel-label="Quit" TRUE "Install Software" 1 FALSE "Remove Software" 2)
  if [ "${PIPESTATUS[0]}" -ne "0" ]; then
    exit 0
  elif [ -n "${TASK}" ];then
    case $TASK in
      "1")
        install_menu
        ;;
      "2")
        remove_menu
        ;;
      "3")
        exit 0
        ;;
    esac
  fi
done
exit 0

https://unlockforus.com

Sorry for seeming stupid and preferring Linux - I just don't know any better.

[Image: AGxgqJ6.png]
Reply
#12

And this is what I have on /usr/bin/lite-software  32 BIT

Code:
#! /bin/bash
#--------------------------------------------------------------------------------------------------------
# Name: Linux Lite Additional Software Install
# Authors: Misko_2083, Jerry Bezencon, gerito1, Johnathan "ShaggyTwoDope" Jenkins, Ralphy
# Website: https://www.linuxliteos.com
#--------------------------------------------------------------------------------------------------------

# Ensure multi-language support
export LANG=C

# Kill off any package managers that may be running
if [ "$(pidof synaptic)" ]
then
   sudo killall -9 synaptic
fi

if [ ! -z "$(pgrep gdebi-gtk)" ]
then
   killall -9 gdebi-gtk
fi

# Set up log facilities
# Example output: [02/06/15 20:03:12] message input
LOGFILE=/var/log/lite-software.log
log(){
    message="$@"
    echo '['$(date +%D\ %H:%M:%S)'] '$message >>$LOGFILE
}

# Log last activities to retrieve errors
TMP_LOG=/tmp/lite-software.log

prepare(){
  # Check internet access
  if eval "sudo -u ${SUDO_USER:-$USER} curl -sk https://www.linuxliteos.com/" >> /dev/null 2>&1; then
    : # pass
  else # Prompt ERROR internet connection
    (zenity --info --ok-label="Got it!" --title="No Internet connection detected..." \
           --text="\n<b>Your computer does not seem to be connected to the internet</b> \n \nYou won't be able to install applications packages needed to be downloaded from the Internet." --no-wrap)
    return
  fi
   # Check if apt-cache was built and ask to update           
  if zenity --question --width=400 --height=120 --title="     Update software sources" --window-icon=$ic --text="\n<b>Would you like to update your software sources now?</b>\n\nClick 'No' to continue without updating software sources or 'Yes' to update software sources next. \n \nIt is recommended to always update software sources before installing applications."; then
      TOTALREPOS=$(cat /etc/apt/sources.list | grep '^deb' -c) # Total of repositories registered, this is approximated
      sudo apt-get update 2>&1 | awk -v total=$TOTALREPOS '/^Ign|^ Get/{count++;$1=""} FNR { if (total != 0){percentage=int (100*count/total);print (percentage < 90?percentage:90),"\n#",$0 }; fflush(stdout)}' \
      | zenity --progress --text="Updating package lists..." --window-icon=$ic --title="Updating Software Sources - please wait..." --percentage=0 --auto-close --width=600
      if [ "${PIPESTATUS[0]}" -ne "0" ]; then
        zenity --error --title="          Error" --width=300 --height=90 --text="\n<b>Updating sources has failed</b>\n\nRefer to /var/log/lite-software.log for more information."
        log "ERROR: Updating sources has failed."
        next
      fi
        log "INFO: Software sources were updated."
      else
        log "INFO: The updating of packages was cancelled by the user"
        next
  fi
}

# Set app icon variable
APPICON=/usr/share/litesoftware/appicons/

#--------------------------------------------------------------------------------------------------------
# soft_list is the list of package aliases to check/install/remove
# Consist in a list describing aspect for every package
# package_alias=( "element 0" "element 1" "element 2" "element 3" "element 4" "element 5" "element 6")
# element 0: TRUE\FALSE for being selected
# element 1: The Application name ie: Google Chrome, iDevices Manager
# element 2: The category which belongs to (one only) ie:  Internet, Multimedia
# element 3: Status of the package ie: Installed, Not Installed
# element 4: Description of the package ie: "Easily locate files and folders in your computer", "Clementine is a modern music player and library organizer"
# element 5: List of packages needed to provide the application ie: "aisleriot gnome-mahjongg gnome-mines gnome-hearts"
# element 6: List of additional packages (this is optional) ie: libavformat-extra-54
#--------------------------------------------------------------------------------------------------------
soft_list=(audacity
  calibre
  cherrytree
  chromiumbr
  dropbox
  gamespack
  idevices
  imessenger
  kodi
  clementine
  passmgr
  pinta
  playonlinux
  remote
  extras
  skype
  spotify
  steam
  teamviewer
  torrent
  tor
  videoedit
  vbox
  weather
  guvcview
  wine )

audacity=("$APPICON/audacity.png" "Audacity" "Multimedia" "" "Software for recording and editing sounds" "audacity" "" )
calibre=("$APPICON/calibre.png" "Calibre" "Office" "" "A free and open source e-book library management application" "calibre" "" )
cherrytree=("$APPICON/cherrytree.png" "Cherrytree" "Accessories" "" "A hierarchical note taking application" "cherrytree" "" )
chromiumbr=("$APPICON/chromium.png" "Chromium Web Browser" "Internet" "" "Open-source alternative to the Google Chrome web browser" "chromium-browser" "" )
dropbox=("$APPICON/dropbox.png" "Dropbox" "Internet" "" "A popular cloud storage application" "dropbox thunar-dropbox-plugin" "" )
gamespack=("$APPICON/gamespack.png" "Games Pack" "Games" "" "Provides with Solitaire, Mahjongg, Mines and Hearts games" "aisleriot gnome-mahjongg gnome-mines gnome-hearts" "" )
idevices=("$APPICON/gtkpod.png" "iDevices Manager" "Multimedia" "" "Manage your iDevices with Gtkpod" "gtkpod" "" )
imessenger=("$APPICON/pidgin.png" "Instant Messenger" "Internet" "" "Pidgin, a multi-protocol Instant Messenging client" "pidgin" "" )
kodi=("$APPICON/kodi.png" "Kodi" "Multimedia" "" "The Kodi Media Center (formerly known as XBMC)" "kodi" "" )
clementine=("$APPICON/clementine.png" "Music Player" "Multimedia" "" "Clementine is a modern music player and library organizer" "clementine" "")
passmgr=("$APPICON/keepassx.png" "Password Manager" "Accessories" "" "KeePassX, an excellent password manager" "keepassx" "" )
pinta=("$APPICON/pinta.png" "Pinta" "Graphics" "" "An easy to use drawing program similar to Paint.Net" "pinta" "" )
playonlinux=("$APPICON/playonlinux.png" "PlayOnLinux" "Cross Platform" "" "Use numerous games and apps designed to run with Windows" "playonlinux" "" )
remote=("$APPICON/remmina.png" "Remote Desktop Software" "Internet" "" "Remmina Remote Desktop Client for Windows (RDP) and VNC Servers" "remmina" "" )
extras=("$APPICON/extras.png" "Restricted Extras" "Multimedia" "" "Additional codecs and useful file formats" "ubuntu-restricted-extras" "libavcodec-extra" )
skype=("$APPICON/skype.png" "Skype" "Internet" "" "A popular audio and video chat application" "skype-bin" "skype" )
spotify=("$APPICON/spotify.png" "Spotify" "Multimedia" "" "Spotify is a digital music service" "spotify-client" "" )
steam=("$APPICON/steam.png" "Steam" "Games" "" "Steam is a cross platform gaming client" "steam-launcher" "" )
teamviewer=("$APPICON/teamviewer.png" "Teamviewer" "Internet" "" "Teamviewer Remote Desktop Support software" "teamviewer" "" )
torrent=("$APPICON/deluge.png" "Torrent Software" "Internet" "" "Deluge Torrent client software" "deluge deluge-common" "" )
tor=("$APPICON/tor.png" "Tor Web Browser" "Internet" "" "Tor Web Browser a privacy respecting web browser" "tor-web-browser" "" )
videoedit=("$APPICON/openshot.png" "Video Editing Software" "Multimedia" "" "Openshot, a simple to use yet powerful video editor for linux" "openshot blender imagemagick" "")
vbox=("$APPICON/virtualbox.png" "VirtualBox" "System" "" "Install other operating systems like Windows from within Linux Lite" "virtualbox" "" )
weather=("$APPICON/weather.png" "Weather Monitor" "System Tray" "" "A Weather Monitor Plugin for your tray" "xfce4-weather-plugin" "" )
guvcview=("$APPICON/guvcview.png" "Webcam Software" "Internet" "" "Guvcview, webcam software for your computer" "guvcview" "" )
wine=("$APPICON/wine.png" "Wine" "Cross Platform" "" "Install and run some Windows programs and games on Linux Lite" "wine1.8" "")

get_pkg_status(){
  result="Installed"
  for PKG in  $@
  do
    TEST_PKG=(`apt-cache policy $PKG | grep "Installed:"`)
    if [ "${TEST_PKG[1]}" == "(none)" ];then
      result="Not Installed"
      break
    fi
  done
  read ${2} <<< $result
  unset result
  unset TEST_PKG
}

# Check for installed packages
check_installed(){
  for element in ${soft_list[*]}
  do
    current_pkg=$element[5]
    status=$element[3]
    get_pkg_status "${!current_pkg}" status # Get the status of the main package
    read ${element}"[3]" <<< $status        # Write the status in the package status
  done
}

install_pkgs(){
  declare -a pkg_arr=("${!1}")

  log "INFO: Installation of packages initiated: ${pkg_arr[@]}"
  sudo apt-get install -f --show-progress ${pkg_arr[@]} --force-yes -y 2>&1 | tee $TMP_LOG | awk ' BEGIN { FS=" "; total=1;end_download=0} /upgraded/ {total= $1 + $3;FS="[ :]" } /^Get:[[:digit:]]+/ {printf "#Downloading %s %s %s\n",$7,$(NF-1),$NF;print int(($2 - 1) * 100 / total); fflush(stdout)} /^\(Reading / {if (end_download==0){print 100;fflush(stdout);end_download=1}} /^(Preparing|Unpacking|Selecting|Processing|Setting|Download)/ {print "#", $0; fflush(stdout)}  /^Progress/ {print  match($0, /([0-9]+)/, arr); if(arr[1] != "") print arr[1] ; fflush(stdout)}' \
   | ( zenity --window-icon=$ic --progress --width=600 --text="Downloading package(s)...\nThis may take a while." --title="Downloading - please wait..." --percentage=0 --auto-close ; zenity --progress --window-icon=$ic --width=600 --text="Installing and configuring packages...\nThis may take a while." --title="Installing - please wait..." --auto-close )
  if [ "${PIPESTATUS[0]}" -ne "0" ]; then
    err_msg=$(awk '/^E:/{$1=""; print $0}' $TMP_LOG | tail -n 1)
    log "ERROR:$err_msg"
    zenity --error --title="Error" --text="Error\n$err_msg"
    return
  else
    zenity --info --width=240 --height=80 --title="          Installation Info" --text="\nInstallation successfully completed!"
    log "INFO: Installation was a success."
  fi
}

remove_pkgs(){
  declare -a pkg_arr=("${!1}")

  log "INFO: Removal of packages initiated: ${pkg_arr[@]}"
  sudo apt-get remove -f ${pkg_arr[@]} --force-yes -y 2>&1 | tee $TMP_LOG | awk ' BEGIN { FS=" "; total=0; pkg=0}  /upgraded/ {total=$6 } /^Removing/ {print "#", $0;pkg+=1;print int((pkg - 1) * 100 / total); fflush(stdout)}' \
    | zenity --progress --window-icon=$ic --width=600 --text="Removing package(s)...\nThis may take a while." --title="Removing Software - please wait..." --percentage=0 --auto-close
  if [ "${PIPESTATUS[0]}" -ne "0" ]; then
    err_msg=$(awk '/^E:/{$1=""; print $0}' $TMP_LOG | tail -n 1)
    log "ERROR:$err_msg"
    zenity --error --title="Error" --text="Error\n$err_msg"
    return
  else
    zenity --info --width=240 --height=80 --title="          Removal Info" --text="\nRemoval successfully completed!"
    log "INFO: Removal was a success."
  fi
}

# The installation menu
install_menu(){
  check_installed
  ic="/usr/share/icons/zenity-llcc.png"
  selection=$(for element in ${soft_list[*]}
    do
      row=$element[@]                          #grab the whole row
      printf  '%s\n' "${!row}"                 #print every element in the row separated with a newline
    done | zenity --window-icon="$ic" --list --imagelist --multiple --width=920 --height=760 --print-column=2,6,7 --separator="| " --column="Select" --column="Name" --column="Category" --column="Status" \
      --column="Description" --column="Packages" --column="Optional Packages" --text="Select the program you wish to install, then click the Install button. \n- Sort columns by clicking on column headers. \n- Ctrl key - allows you to click and select multiple applications that are <b>anywhere</b> on the list, not necessarily next to each other. \n- Shift key - allows you to select a group of applications that are <b>contiguous</b> (next to each other) by clicking one application, then holding Shift \n  and clicking the last application you want from the list; all the applications in between will be selected.\n " \
      --title="Install Additional Software" --ok-label="Install" --hide-column=6,7 )

  # If Cancel is clicked then return to main loop
  if [ "${PIPESTATUS[0]}" -ne "0" ]; then
    return
  fi
 
  # Check if anything is selected
  echo $selection | grep '[a-zA-Z0-9]'
  if [ "${PIPESTATUS[1]}" -ne "0" ]; then
    zenity --info  --width=280 --title='     Install Additional Software' --text='\nNo application was selected for installation.'
    return
  fi

  # Split selection
  OIFS=$IFS
  IFS='|'
  selection_array=($selection)
  PKGS_NAMES=""
  PKGS=""
  for ((i=0; i<${#selection_array[@]}; ++i));
  do
    if (( i % 3 == 0 )); then
      PKGS_NAMES=$PKGS_NAMES${selection_array[$i]}"\n"
      continue
    fi
    PKGS=$PKGS${selection_array[$i]}" "
  done
  IFS=$OIFS

  zenity --question  --width=360 --title="          Install Software" --window-icon="${ic}" --text="\n<b>The following software has been selected</b>:\n\n $PKGS_NAMES \nDo you want to proceed with the installation?"
  if [ "$?" -eq "0" ]; then
    install_pkgs PKGS[@]
  else
    return
  fi
}

# The installation menu
remove_menu(){

  check_installed
  ic="/usr/share/icons/zenity-llcc.png"

  selection=$(for element in ${soft_list[*]}
    do
      pkg_status=$element[3]

      #Only list Installed applications
      if [ "${!pkg_status}" == "Not Installed" ]; then
        continue;
      fi
      row=$element[@]                          #grab the whole row
      printf  '%s\n' "${!row}"                 #print every element in the row separated with a newline
    done | zenity --window-icon="$ic" --list --imagelist --multiple --width=920 --height=760 --print-column=2,6 --separator="| " --column="Select" --column="Name" --column="Category" --column="Status" \
      --column="Description" --column="Packages" --column="Optional Packages" --text="Select the program you wish to remove, then click the Remove button. \n- Sort columns by clicking on column headers. \n- Ctrl key - allows you to click and select multiple applications that are <b>anywhere</b> on the list, not necessarily next to each other. \n- Shift key - allows you to select a group of applications that are <b>contiguous</b> (next to each other) by clicking one application, then holding Shift \n  and clicking the last application you want from the list; all the applications in between will be selected." \
      --title="Remove Additional Software" --ok-label="Remove" --hide-column=6,7 )

  # If Cancel is clicked then return to main loop
  if [ "${PIPESTATUS[0]}" -ne "0" ]; then
    return
  fi

  # Check if anything is selected
  echo $selection | grep '[a-zA-Z0-9]'
  if [ "${PIPESTATUS[1]}" -ne "0" ]; then
    zenity --info --width=260 --title='          Remove Software' --text='\nNo application was selected for removal.'
    return
  fi

  # Split selection
  OIFS=$IFS
  IFS='|'
  selection_array=($selection)
  PKGS_NAMES=""
  PKGS=""
  for ((i=0; i<${#selection_array[@]}; ++i));
  do
    if (( i % 2 == 0 )); then
      PKGS_NAMES=$PKGS_NAMES${selection_array[$i]}"\n"
      continue
    fi
    PKGS=$PKGS${selection_array[$i]}" "
  done
  IFS=$OIFS
  zenity --question --width=360 --title="          Remove Software" --window-icon="${ic}" --text="\n<b>The following software has been selected</b>:\n\n $PKGS_NAMES \n Do you want to proceed  with the removal?"
  if [ "$?" -eq "0" ]; then
    remove_pkgs PKGS[@]
  else
    return
  fi
}

# We begin here
prepare
pkg_manager_check
# The main loop
while (true); do
  TASK=$(zenity --width=280 --height=160 --list --radiolist --text="Select a task:" \
    --title="          Lite Software" --column="Select" --column="Task" --column="Code Task" --hide-column=3 \
    --print-column=3 --cancel-label="Quit" TRUE "Install Software" 1 FALSE "Remove Software" 2)
  if [ "${PIPESTATUS[0]}" -ne "0" ]; then
    exit 0
  elif [ -n "${TASK}" ];then
    case $TASK in
      "1")
        install_menu
        ;;
      "2")
        remove_menu
        ;;
      "3")
        exit 0
        ;;
    esac
  fi
done
exit 0

https://unlockforus.com

Sorry for seeming stupid and preferring Linux - I just don't know any better.

[Image: AGxgqJ6.png]
Reply
#13

Using the above code (updates-gui), in both VM's, I'm not getting the new notification. I tried on my main rig, still not getting the notification. Bizarre.

Download your free copy of Linux Lite today.

Jerry Bezencon
Linux Lite Creator

"Do not correct a fool, or he will hate you; correct a wise man and he will appreciate you."

[Image: X5qGkCg.png]

[Image: 0op1GNe.png] [Image: LgJ2mtP.png] [Image: vLZcFUE.png] [Image: lrUHro3.jpg]
Reply
#14

FYI the google check is much faster :)

Download your free copy of Linux Lite today.

Jerry Bezencon
Linux Lite Creator

"Do not correct a fool, or he will hate you; correct a wise man and he will appreciate you."

[Image: X5qGkCg.png]

[Image: 0op1GNe.png] [Image: LgJ2mtP.png] [Image: vLZcFUE.png] [Image: lrUHro3.jpg]
Reply
#15

Do you have teamviewer so you can look around my VMs? I don't have any packages in specific installed or anything and both installs are pretty fresh.

Here, run this on your machines and tell me if you get the notification:

Code:
notify-send -t 10000 -i /usr/share/icons/Faenza/places/48/distributor-logo-ubuntu.png "Updates Available" "There are updates available for your system. Please run Lite 'Install Updates' again to update."

https://unlockforus.com

Sorry for seeming stupid and preferring Linux - I just don't know any better.

[Image: AGxgqJ6.png]
Reply
#16

I get that notification no problem. Yes, I have Teamviewer (12 via Lite Software), pm me your details.

Download your free copy of Linux Lite today.

Jerry Bezencon
Linux Lite Creator

"Do not correct a fool, or he will hate you; correct a wise man and he will appreciate you."

[Image: X5qGkCg.png]

[Image: 0op1GNe.png] [Image: LgJ2mtP.png] [Image: vLZcFUE.png] [Image: lrUHro3.jpg]
Reply
#17

(12-01-2016, 06:55 AM)Jerry link Wrote:  FYI the google check is much faster :)

Yes, it definitely is :)  Since no protocol was specified it will go to http by default and there we get a 301 response which is rather quick and there isn't anything to pull. Good catch!

https://unlockforus.com

Sorry for seeming stupid and preferring Linux - I just don't know any better.

[Image: AGxgqJ6.png]
Reply
#18

Will test the new pushes over the next few days. Got a bit on at work now. Thanks again Ralphy.

Download your free copy of Linux Lite today.

Jerry Bezencon
Linux Lite Creator

"Do not correct a fool, or he will hate you; correct a wise man and he will appreciate you."

[Image: X5qGkCg.png]

[Image: 0op1GNe.png] [Image: LgJ2mtP.png] [Image: vLZcFUE.png] [Image: lrUHro3.jpg]
Reply
#19

Testing so far, so good. Some changes on Github. Will test the new code tomorrow then hopefully put a package together soon unless you have anything else you want to add.

Download your free copy of Linux Lite today.

Jerry Bezencon
Linux Lite Creator

"Do not correct a fool, or he will hate you; correct a wise man and he will appreciate you."

[Image: X5qGkCg.png]

[Image: 0op1GNe.png] [Image: LgJ2mtP.png] [Image: vLZcFUE.png] [Image: lrUHro3.jpg]
Reply
#20

It looks pretty good for me. Texts have been updated all around which gives it a more uniform feeling. I like it so far :)

... just a couple catches:

/usr/bin/lite-software

Looks like the correct icon isn't declared everywhere it is called for:

ic="/usr/share/icons/zenity-llcc.png"

I believe it makes sense to declare the icon @ line 33-34 before the prepare(){  statement to make sure it is set everywhere where it is called down below. I also noticed that 'sudo' made it back all over again. I think I overwrote my own work last time we shared... I had removed 'sudo' from pretty much everywhere to make it a bit cleaner.

I took the latest available in GH and made the changes above mentioned in my test VMs once again but I'm afraid to pull a commit in GH while you are still testing and working on it.

Let me know when it is a good time to send you the next pull request for lite-software.

https://unlockforus.com

Sorry for seeming stupid and preferring Linux - I just don't know any better.

[Image: AGxgqJ6.png]
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)