Linux Lite Forums

Development => Linux Lite Software Development => Topic started by: Jerry on November 07, 2017, 09:20:06 PM

Title: Install Updates - Yad version
Post by: Jerry on November 07, 2017, 09:20:06 PM
This an appeal to those who would like to take part in a trial of Install Updates - the Yad version.

- Make a back up copy of /usr/scripts/updates-gui
- Copy the following contents into updates-gui

Code: [Select]
#!/bin/bash
#-----------------------------------------------------------------------------------------
# Name: Linux Lite Updates
# Description: A GUI tool to easily install Updates in Linux Lite.
# Authors: Misko_2083, Jerry Bezencon, gerito1, Ralphy
# Website: https://www.linuxliteos.com
#-----------------------------------------------------------------------------------------

_APPNAME="Linux Lite Updates"                # Application name variable
_MYUPDUSER=$(whoami)
_ICON="/usr/share/icons/Faenza/apps/scalable/synaptic.svg"     # Linux Lite icon variable
_UPDATES=$(mktemp /tmp/updateslist.XXXXXX)   # Updates log variable
_DATE=$(date +"%A-%d-%B-%Y-%T")              # Date variable
_TMPU="/tmp/_updusr"
_PLAIN="/tmp/updateslist.txt"
_LLUPDATES="/var/log/llupdates.log"
if [ ! -f "$_TMPU" ]; then echo "$_MYUPDUSER" > "$_TMPU"; chmod 600 "$_TMPU"; fi
_SVUSER=$(cat "$_TMPU")

# function remove temp files
rm_temp_files() {
rm -f $_SVUSER
rm -f $_TMPU
rm -f $_UPDATES
rm -f $_PLAIN
rm -f /tmp/updateslist.*
}

# function view, save update log
view_save_log() {
  _ANS=$(yad --center --borders=15 --question --image=logviewer --text-info --width="780" --height="400" --window-icon="$_ICON" --title=" $_APPNAME - Error log" \
                --button=gtk-cancel:1 --button="Save":0 --filename="$_LLUPDATES" 2>/dev/null); _OPT=$(echo $?)

    if [[ "$_ANS" =~ "Copy to clipboard" ]]; then
      sudo -u ${SUDO_USER:-$_SVUSER} xclip -selection c "$_LLUPDATES"
      xhost local:$_SVUSER > /dev/null 2>&1
      export DISPLAY=:0
      _NTFYICON="/usr/share/icons/Faenza/places/48/distributor-logo-ubuntu.png"
      notify-send -i "$_NTFYICON" 'Updates Log copied to clipboard' "Go to www.linuxliteos.com/forums and paste the log into a new or existing thread." -t 10000
      xhost - >/dev/null 2>&1; rm_temp_files; exit 0
    fi
    case $_OPT in
       0) szSavePath=$(yad --center --image=logviewer --borders=15 --title="    Save Updates Log" --width="600" --height="400" --file-selection --filename="/home/$_SVUSER/llupdates.log" \
                              --window-icon="$_ICON" --file-filter='*.log' --file-filter='All files | *' --save --confirm-overwrite 2>/dev/null)
           if [ "$?" -eq "0" ]; then sudo -u ${SUDO_USER:-$_SVUSER} cp "$_LLUPDATES" "$szSavePath"; rm_temp_files; else rm_temp_files; exit 0 ; fi ;;
       1) rm_temp_files; exit 0 ;;
    esac
}

# Check Internet access
if eval "curl -sk google.com" >> /dev/null 2>&1; then :; else # Prompt ERROR internet connection check failed and exit
  yad --center --borders=15 --info --width="320" --height="120" --window-icon="$_ICON" --button=gtk-ok:1 --title="$_APPNAME" \
         --text="\n<b>Your computer is not connected to the Internet.</b> \n \nLinux Lite cannot check for Updates.\nPlease check your internet connection and try again.\n" --text-align center 2>/dev/null
  rm_temp_files; exit 0
fi

# Kill off any package managers that may be running
if [ "$(pidof synaptic)" ]; then killall -9 synaptic; fi
if [ ! -z "$(pgrep gdebi-gtk)" ]; then killall -9 gdebi-gtk; fi

# start dialog - Ask for elevation, else exit
if [ $EUID -ne 0 ]; then
  yad --center --borders=15 --image=system-software-install --question --width="320" --height="120" --window-icon="$_ICON" --button=gtk-cancel:1 --button="Continue":0 --title="$_APPNAME" \
       --text="\nLinux Lite will now fetch the Updates list.\n\nClick <b>Cancel</b> to exit now or <b>Continue</b> to proceed.\n" --text-align center 2>/dev/null
   case $? in
      0) pkexec "$0"; if [ "${PIPESTATUS[@]}" -eq "126" ]; then rm_temp_files; fi; exit 0 ;;
      1) rm_temp_files; exit 0 ;;
   esac
fi

if [ "$?" -eq "0" ];then
  # xclip check/ install
  if [ -z  "$(dpkg -l | grep -E '^ii' | grep xclip)" ]; then
    apt-get install xclip -y | yad --center --borders=15 --image=system-software-install --progress --pulsate --window-icon="$_ICON" --auto-close --no-cancel --width="320" --height="80" --title="$_APPNAME" \
                                       --text="Preparing... please wait...\n" --text-align center --no-buttons --skip-taskbar 2>/dev/null
  fi

# Repositories registered
_SLIST=$(grep '^deb ' -c /etc/apt/sources.list)
_SLISTD=$(grep -R --exclude="*.save" '^deb ' -c /etc/apt/sources.list.d/ | grep -c /)
APTUPDATE=$(($_SLIST + $_SLISTD)) # Total of repositories registered, this is approximated
apt-get update 2>&1 | tee "$_LLUPDATES" |
awk -v total=$APTUPDATE '/^Ign|^ Get/{count++;$1=""} FNR { if (total != 0){percentage=int (1000*count/total);print (percentage < 90?percentage:99),"\n#",substr($0, 0, 128) }; fflush(stdout)}' \
| yad --center --undecorated --borders=35 --progress --width="600" --text="Updating package lists...\n" --text-align center --window-icon="$_ICON" --title="Updating Software Sources - please wait..." --percentage="0" --no-buttons --skip-taskbar --pulsate --auto-close 2>/dev/null
    if [ "${PIPESTATUS[0]}" -ne "0" ]; then
        unset APTUPDATE; rm_temp_files; unset _UPDATES
        sed -i '1 i\===========================\
Install Updates Error Log\
===========================\
\
Install Updates could not fetch the package cache information lists.\
Go to https://www.linuxliteos.com/forums/ and paste the log below into\na new or existing thread for assistance.\n\
============ Log ===========\n' "$_LLUPDATES"
        sleep 4 | yad --center --borders=15 --image=error --progress --pulsate --window-icon="error" --auto-close --no-cancel --width="380" --height="80" --title="$_APPNAME - Error" \
                         --text="Errors occurred while fetching packages cache information lists.\n\n✔ Retrieving error log, please wait...\n" --no-buttons --skip-taskbar --text-align center 2>/dev/null
        view_save_log; exit 1
    fi
  unset APTUPDATE

  # Creates a list in /tmp/updateslist
  apt-get --just-print dist-upgrade 2>&1 | perl -ne 'if (/Inst\s([\w,\-,\d,\.,~,:,\+]+)\s\[([\w,\-,\d,\.,~,:,\+]+)\]\s\(([\w,\-,\d,\.,~,:,\+]+)\)? /i) {print "Name: $1 INSTALLED: $2 AVAILABLE: $3\n"}' |
  awk '{print NR,":\t"$0}' > $_PLAIN
  sed '
  s:$::
  ' $_PLAIN >> $_UPDATES


  # Check for available updates; if none then remove /tmp/updateslist.XXXXXX and display up-to-date dialog
      if [  -z "$(cat $_PLAIN)"  ]; then
        rm_temp_files; unset _UPDATES
        yad --center --borders=15 --image=gtk-info --info --window-icon="$_ICON"  --width="260" --height="60" --title="  $_APPNAME" \
               --text="\nYour system is up to date.\n"  --text-align center 2>/dev/null
        exit 0
      fi

# Erase existing available info
dpkg --clear-avail
else
  rm_temp_files; unset _UPDATES; exit 0
fi

# Call the yad dialog to show update list
yad --center --borders=15 --image=system-software-install --text-info --back=#eff1f4 --window-icon="$_ICON" --button=gtk-cancel:1 --button="Update Now":0 --title="  $_APPNAME" --width="760" --height="400" --fontname="Droid regular 10" --filename="$_UPDATES" 2>/dev/null
      if [ "$?" -eq "0" ];then
        # Continue script if no halt, remove tmp file and unset variables
        rm $_UPDATES; unset _UPDATES

#Begin upgrade
DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade -y  2>&1 | tee "$_LLUPDATES" |
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 "#", substr($0, 0, 128); fflush(stdout)}' \
  | ( yad --center --undecorated --borders=35 --progress --width="600" --window-icon="$_ICON" --percentage="0" --auto-close --text="Downloading package(s)...\nThis may take a while.\n" --text-align center --no-buttons --skip-taskbar  2>/dev/null;
      yad --center --undecorated --borders=35 --progress --window-icon="$_ICON" --width="600" --text="Installing and configuring package(s)...\nThis may take a while.\n" --text-align center --no-buttons --skip-taskbar --pulsate --auto-close 2>/dev/null)

    if [ "${PIPESTATUS[0]}" -ne "0" ]; then
      sed -i '1 i\===========================\
Install Updates Error log\
===========================\
Install Updates could not successfully download and install available updates.\
Go to https://www.linuxliteos.com/forums/ and paste the log below into a new or existing thread for assistance.\n\
============ Log ===========\n' "$_LLUPDATES"
      sleep 4 | yad --center --borders=15 --image=error --progress --pulsate --window-icon="error" --auto-close --no-cancel --width="320" --height="80" --title="$_APPNAME - Error" \
                       --text="Errors occurred while updating. \n\n✔ Retrieving errors log. Please wait...\n" --text-align center --no-buttons --skip-taskbar 2>/dev/null
      view_save_log; exit 0
    fi

    # Halt updates script if user selects Cancel
    else
       rm_temp_files; unset _UPDATES
       yad --center --borders=15 --image=info --info --width="300" --button=gtk-ok:1 --timeout="6" --window-icon="$_ICON" --title="   $_APPNAME" --text="\nUpdates have been canceled.\n" --text-align center 2>/dev/null
       exit 0
    fi

# If Ubuntu base package has been upgraded during Install Updates, /usr/share/plymouth/themes/ubuntu-text/ubuntu-text.plymouth
llverprnt=$(awk '{print}' /etc/llver)
checkdefplym="/usr/share/plymouth/themes/ubuntu-text/ubuntu-text.plymouth"

if grep -q 0x988592 "$checkdefplym"; then
  sed -i "s/^title=Ubuntu.*$/title=$llverprnt/g" /usr/share/plymouth/themes/ubuntu-text/ubuntu-text.plymouth ;
  sed -i "s/black=0x2c001e/black=0x000000/g" /usr/share/plymouth/themes/ubuntu-text/ubuntu-text.plymouth ;
  sed -i "s/white=0xffffff/white=0xffffff/g" /usr/share/plymouth/themes/ubuntu-text/ubuntu-text.plymouth ;
  sed -i "s/brown=0xff4012/brown=0xffff00/g" /usr/share/plymouth/themes/ubuntu-text/ubuntu-text.plymouth ;
  sed -i "s/blue=0x988592/blue=0x000000/g" /usr/share/plymouth/themes/ubuntu-text/ubuntu-text.plymouth && update-initramfs -u |
  yad --center --undecorated --borders=35 --progress --width=600 --auto-close --pulsate --text="Updating boot configuration please wait...\n" --text-align center --no-buttons --skip-taskbar
else
    echo " "
fi

    PROCEED=$(yad --center --borders=15 --question --image=logviewer --width="300" --height="80" --window-icon="$_ICON" --title="  $_APPNAME" --text-align center --window-icon="$_ICON" --button="No":1 --button="Yes":0 --text="\n$_APPNAME completed successfully.\n\nWould you like to view the\n$_APPNAME log?\n" 2>/dev/null ; echo $?)
    if [ ${PROCEED} -eq 1 ]; then rm_temp_files; :; else
      yad --center --borders=15 --question --image=logviewer --text-info --width="750" --height="400" --button="Close":1 --button="Save":0 --title="  $_APPNAME - Log" --filename="$_LLUPDATES" 2>/dev/null
        if [ $? -eq 0 ]; then
          # Save report
          szSavePath=$(yad --center --image=logviewer --borders=15 --width="600" --height="400" --window-icon="$_ICON" --title=" Save Updates log" --file-selection --filename=/home/$_SVUSER/llupdates-"${_DATE}".txt --file-filter='*.txt' \
                              --file-filter='All files | *' --save --confirm-overwrite 2>/dev/null)
          sudo -u ${SUDO_USER:-$_SVUSER} cp "$_LLUPDATES" "$szSavePath"; rm_temp_files; else rm_temp_files; :
        fi
    fi
    if [ -s /var/run/reboot-required ]; then
        yad --center --question --image=gtk-info --borders=15 --width="300" --height="100" --window-icon="$_ICON" --button="Continue using my computer:"1 --button="Restart Now":0 --title="  Linux Lite Updates" --text-align center \
               --text="These updates require the system to be restarted\nfor the changes to take effect.\n\nWould you like to restart now?\n" 2>/dev/null
        if [ "$?" -eq "0" ]; then reboot; else exit 0 ; fi
    fi

exit 0

(https://i.imgur.com/GLZZJMw.png)

(https://i.imgur.com/2Cr2jhs.png)

(https://i.imgur.com/ZUwdYzK.png)

(https://i.imgur.com/JFyzxAw.png)

(https://i.imgur.com/PFbrxtY.png)

(https://i.imgur.com/YK7j3el.png)

(https://i.imgur.com/Kv7MTxV.png)

(https://i.imgur.com/wIIW4qn.png)

(https://i.imgur.com/xnS50lu.png)

My thoughts:

- I think the progress windows look a lot nicer.
- Dialogues automatically adjust according to what text is inside aiding in readability.
- Yad allows for much more scripting options which translates to more features for our applications.

Trial will last as long as you are happy to run this version of Install Updates.

Looking forward to your feedback and opinion. :)
Title: Re: Install Updates - Yad version
Post by: Artim on November 08, 2017, 04:56:48 AM
Wonderful!  Thank you @misko_2083, @Jerry, @gerito1, and @ralphy!
Title: Re: Install Updates - Yad version
Post by: trinidad on November 08, 2017, 08:57:38 AM
Installed the YAD script and ran it this morning. Worked flawlessly. I would slow the blue sliding progress bar down a bit. It goes back and forth so fast on my machine that it's almost annoying, and given LL is aimed at Windows converts who are used to slower moving things involving such processes I think it moves a bit too fast. I do think it meets the criteria of some recent user requests here on forum involving updates. Looks good.

It fits to XFCE well. The best looking GUI for updates progress I've ever seen is the Debian 8/9 Gnome DE. It shows each package seperately and the progress of each each package during download and installation. As I said already this is well suited for an XFCE distro though, and Windows converts.

TC
Title: Re: Install Updates - Yad version
Post by: Jerry on November 08, 2017, 12:01:48 PM
Thank you TC, unfortunately there's no way to slow down the blue sliding progress bar. We could however look at changing it from pulsating to progress, but that's extremely tricky and hard to get right.
Title: Re: Install Updates - Yad version
Post by: DenW on November 09, 2017, 08:05:59 PM
Thank you Jerry and the other contributors to the Yad version of the Updater.

I am one of those LL users who have been experiencing the Blank update window using the Zenity version of Updater.  Yesterday all seemed OK but today I got another blank update window and cancelling and  trying a second time did not solve the blank window problem (even though I could open the updates.txt file in /tmp folder and see the updates available both times!).

So this evening I followed Jerry's instructions above and everything worked exactly as shown in the pictures above.  I would also make the same comment as Trinidad about the blue bar which seemed somewhat jerky on my older machine but still moved fast.  I wonder whether you even need the blue bar at all as the letters were always changing quickly during the whole process (except at the beginning of the download phase when there is usually a pause of 2-3 seconds and the blue bar was absent anyway).

Anyway I am going to keep the Yad Updater on my LL 3.6 until the next version of LL and will report back if any problem arises.

Thanks again.
Title: Re: Install Updates - Yad version
Post by: Jerry on November 09, 2017, 10:26:53 PM
Thanks @DenW. Much appreciated :)
Title: Re: Install Updates - Yad version
Post by: Vera on November 11, 2017, 04:17:46 PM
I did what you said about setting up the Yad version. I did it on one machine and not the other, so I could have a direct comparison of the end effect.

OK, here are my notes - it's a mixed bag because some things I feel are a big improvement and others could use a little work. I made these notes as the updates happened so they are in order of what happens first in the process to what happens last.

1. The first progress bar on "checking for updates" is too fast and flashy, making it too distracting. I prefer the old progress bar in that regard. An alternative fix would be a rotating icon or something else that would show that "something is happening" without distracting the user too much.

2. Going to the Linux Lite updates window (the list of the names of what packages will be updated) - the window opens in the top left of the screen. It's fine there, but I had expected it to be in the middle of the screen. However, top left is good if you're in the middle of working since it doesn't get covered up behind your work. So, initially I was surprised by this change but upon reflection I think it is a good choice on your part.

3. The "downloading packages" progress bar is nice. It's much better than the old version as it has a more modern look. And since it's a continuous progress bar and not a flashy back-and-forth one, it's also not distracting like the first progress bar in point 1.

4. At the "installing and configuring packages" stage, we have the same issue as in point 1 (bar flashing fast left to right). I love the look of the status text inside of the progress bar though - it's a nice touch.

OK, that was my feedback. Overall, I like it, the only thing I didn't like was flashing back-and-forth progress bars which I feel could be better served with something like a rotating icon. That's just my personal opinion though and is a matter of personal taste - different people may feel differently about that. I do very much like the overall look, and I appreciate the time and effort that's gone into making the new update process look a) modern in style and b) cohesive to the rest of the system.
Title: Re: Install Updates - Yad version
Post by: Jerry on November 11, 2017, 08:45:29 PM
Thank you for your feedback Vera, much appreciated.

2. - the window opens in the top left of the screen.

The Yad version is not set up to do this. Please run this a few more times when updates become available to verify.
Title: Re: Install Updates - Yad version
Post by: DenW on November 12, 2017, 08:57:46 AM
Hi Vera/Jerry:  I believe the "problem" of the updates window opening in the top left of the screen is related to the XFCE Setting >Windows Manager Tweaks>Placement where a slider determines the window size for smart placement.  The updates window is usually much larger than the other windows that open during the updates process and would trigger the observed placement unless the slider is say 2/3rds over to the right where I usually put it - I prefer all my windows to open in the center.
Title: Re: Install Updates - Yad version
Post by: Jerry on November 12, 2017, 09:05:32 AM
I can tell Yad to center all windows. I'll place an update soon.
Title: Re: Install Updates - Yad version
Post by: Vera on November 14, 2017, 07:51:52 PM
There's been a few cycles of updates, so I was able to try what both of you suggested. @Jerry  -  I confirm it opened again in the top left. Next I tried what DenW suggested, and the reason for the top left positioning turned out to be exactly for the reason that @DenW put forward - a huge THANK YOU Den.  I just went to the setting that you mentioned, and sure enough my slider bar was toward the left instead of the right. I put it 2/3 to the right as you suggested, and then when I tried it on the next batch of updates the window was centered! Cool!

Also you solved another issue DenW: the machine is my laptop, and I've had it behave a little oddly with window positioning during Lite Tweaks Kernel remover. I wasn't able to click on the 'ok' button to confirm the list of kernels to be removed, as the button was down below the bottom of the screen and it wouldn't let me resize the window to make it fit on screen. I had to use the 'enter' button on the keyboard to say ok. But now that I have the new slider setting, I tried out Lite Tweaks Kernel Remover just now to remove an old kernel, and the window was normal!! Thanks so much! Who knew that the one slider setting would help so much!
Title: Re: Install Updates - Yad version
Post by: Jerry on November 15, 2017, 12:40:31 AM
Code updated. Please copy new code from original post.

Change - all windows will now center screen regardless.

Cheers.
Title: Re: Install Updates - Yad version
Post by: Jerry on November 15, 2017, 05:58:56 AM
What if there were no progress bars, just simple text output during:

- Updating packages
- Installing packages

and only a progress bar during Downloading of packages?
Title: Re: Install Updates - Yad version
Post by: Jerry on November 15, 2017, 06:23:01 AM
Code for above post:

Code: [Select]
#!/bin/bash
#-----------------------------------------------------------------------------------------
# Name: Linux Lite Updates
# Description: A GUI tool to easily install Updates in Linux Lite.
# Authors: Misko_2083, Jerry Bezencon, gerito1, Ralphy
# Website: https://www.linuxliteos.com
#-----------------------------------------------------------------------------------------

_APPNAME="Linux Lite Updates"                # Application name variable
_MYUPDUSER=$(whoami)
_ICON="/usr/share/icons/Faenza/apps/scalable/synaptic.svg"     # Linux Lite icon variable
_UPDATES=$(mktemp /tmp/updateslist.XXXXXX)   # Updates log variable
_DATE=$(date +"%A-%d-%B-%Y-%T")              # Date variable
_TMPU="/tmp/_updusr"
_PLAIN="/tmp/updateslist.txt"
_LLUPDATES="/var/log/llupdates.log"
if [ ! -f "$_TMPU" ]; then echo "$_MYUPDUSER" > "$_TMPU"; chmod 600 "$_TMPU"; fi
_SVUSER=$(cat "$_TMPU")

# function remove temp files
rm_temp_files() {
rm -f $_SVUSER
rm -f $_TMPU
rm -f $_UPDATES
rm -f $_PLAIN
rm -f /tmp/updateslist.*
}

# function view, save update log
view_save_log() {
  _ANS=$(yad --center --borders=15 --question --image=logviewer --text-info --width="780" --height="400" --window-icon="$_ICON" --title=" $_APPNAME Error log" \
                --button=gtk-cancel:1 --button="Save":0 --filename="$_LLUPDATES" 2>/dev/null); _OPT=$(echo $?)

    if [[ "$_ANS" =~ "Copy to clipboard" ]]; then
      sudo -u ${SUDO_USER:-$_SVUSER} xclip -selection c "$_LLUPDATES"
      xhost local:$_SVUSER > /dev/null 2>&1
      export DISPLAY=:0
      _NTFYICON="/usr/share/icons/Faenza/places/48/distributor-logo-ubuntu.png"
      notify-send -i "$_NTFYICON" 'Updates Log copied to clipboard' "Go to www.linuxliteos.com/forums and paste the log into a new or existing thread." -t 10000
      xhost - >/dev/null 2>&1; rm_temp_files; exit 0
    fi
    case $_OPT in
       0) szSavePath=$(yad --center --image=logviewer --borders=15 --title="    Save Updates Log" --width="600" --height="400" --file-selection --filename="/home/$_SVUSER/llupdates.log" \
                              --window-icon="$_ICON" --file-filter='*.log' --file-filter='All files | *' --save --confirm-overwrite 2>/dev/null)
           if [ "$?" -eq "0" ]; then sudo -u ${SUDO_USER:-$_SVUSER} cp "$_LLUPDATES" "$szSavePath"; rm_temp_files; else rm_temp_files; exit 0 ; fi ;;
       1) rm_temp_files; exit 0 ;;
    esac
}

# Check Internet access
if eval "curl -sk google.com" >> /dev/null 2>&1; then :; else # Prompt ERROR internet connection check failed and exit
  yad --center --borders=15 --info --width="320" --height="120" --window-icon="$_ICON" --button=gtk-ok:1 --title="$_APPNAME" \
         --text="\n<b>Your computer is not connected to the Internet.</b> \n \nLinux Lite cannot check for Updates.\nPlease check your internet connection and try again.\n" --text-align center 2>/dev/null
  rm_temp_files; exit 0
fi

# Kill off any package managers that may be running
if [ "$(pidof synaptic)" ]; then killall -9 synaptic; fi
if [ ! -z "$(pgrep gdebi-gtk)" ]; then killall -9 gdebi-gtk; fi

# start dialog - Ask for elevation, else exit
if [ $EUID -ne 0 ]; then
  yad --center --borders=15 --image=system-software-install --question --width="320" --height="120" --window-icon="$_ICON" --button=gtk-cancel:1 --button="Continue":0 --title="$_APPNAME" \
       --text="\nLinux Lite will now fetch the Updates list.\n\nClick <b>Cancel</b> to exit now or <b>Continue</b> to proceed.\n" --text-align center 2>/dev/null
   case $? in
      0) pkexec "$0"; if [ "${PIPESTATUS[@]}" -eq "126" ]; then rm_temp_files; fi; exit 0 ;;
      1) rm_temp_files; exit 0 ;;
   esac
fi

if [ "$?" -eq "0" ];then
  # xclip check/ install
  if [ -z  "$(dpkg -l | grep -E '^ii' | grep xclip)" ]; then
    apt-get install xclip -y | yad --center --borders=15 --image=system-software-install --progress --pulsate --window-icon="$_ICON" --auto-close --no-cancel --width="320" --height="80" --title="$_APPNAME" \
                                       --text="Preparing... please wait...\n" --text-align center --no-buttons --skip-taskbar 2>/dev/null
  fi

# Repositories registered
_SLIST=$(grep '^deb ' -c /etc/apt/sources.list)
_SLISTD=$(grep -R --exclude="*.save" '^deb ' -c /etc/apt/sources.list.d/ | grep -c /)
APTUPDATE=$(($_SLIST + $_SLISTD)) # Total of repositories registered, this is approximated
apt-get update 2>&1 | tee "$_LLUPDATES" |
awk -v total=$APTUPDATE '/^Ign|^ Get/{count++;$1=""} FNR { if (total != 0){percentage=int (1000*count/total);print (percentage > 100),"\n#",substr($0, 0, 128) }; fflush(stdout)}' \
| yad --center --undecorated --borders=35 --progress --text="Updating package lists...\n" --text-align center --window-icon="$_ICON" --title="Updating Software Sources - please wait..." --no-buttons --skip-taskbar --auto-close 2>/dev/null
    if [ "${PIPESTATUS[0]}" -ne "0" ]; then
        unset APTUPDATE; rm_temp_files; unset _UPDATES
        sed -i '1 i\===========================\
Install Updates Error Log\
===========================\
\
Install Updates could not fetch the package cache information lists.\
Go to https://www.linuxliteos.com/forums/ and paste the log below into\na new or existing thread for assistance.\n\
============ Log ===========\n' "$_LLUPDATES"
        sleep 4 | yad --center --borders=15 --image=error --progress --pulsate --window-icon="error" --auto-close --no-cancel --width="380" --height="80" --title="$_APPNAME - Error" \
                         --text="Errors occurred while fetching packages cache information lists.\n\n✔ Retrieving error log, please wait...\n" --no-buttons --skip-taskbar --text-align center 2>/dev/null
        view_save_log; exit 1
    fi
  unset APTUPDATE

  # Creates a list in /tmp/updateslist
  apt-get --just-print dist-upgrade 2>&1 | perl -ne 'if (/Inst\s([\w,\-,\d,\.,~,:,\+]+)\s\[([\w,\-,\d,\.,~,:,\+]+)\]\s\(([\w,\-,\d,\.,~,:,\+]+)\)? /i) {print "Name: $1 INSTALLED: $2 AVAILABLE: $3\n"}' |
  awk '{print NR,":\t"$0}' > $_PLAIN
  sed '
  s:$::
  ' $_PLAIN >> $_UPDATES


  # Check for available updates; if none then remove /tmp/updateslist.XXXXXX and display up-to-date dialog
      if [  -z "$(cat $_PLAIN)"  ]; then
        rm_temp_files; unset _UPDATES
        yad --center --borders=15 --image=gtk-info --info --window-icon="$_ICON"  --width="260" --height="60" --title="  $_APPNAME" \
               --text="\nYour system is up to date.\n"  --text-align center 2>/dev/null
        exit 0
      fi

# Erase existing available info
dpkg --clear-avail
else
  rm_temp_files; unset _UPDATES; exit 0
fi

# Call the yad dialog to show update list
yad --center --borders=15 --image=system-software-install --text-info --back=#eff1f4 --window-icon="$_ICON" --button=gtk-cancel:1 --button="Update Now":0 --title="Available Updates" --width="760" --height="400" --fontname="Droid regular 10" --filename="$_UPDATES" 2>/dev/null
      if [ "$?" -eq "0" ];then
        # Continue script if no halt, remove tmp file and unset variables
        rm $_UPDATES; unset _UPDATES

#Begin upgrade
DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade -y  2>&1 | tee "$_LLUPDATES" |
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 "#", substr($0, 0, 128); fflush(stdout)}' \
  | ( yad --center --undecorated --borders=35 --progress --window-icon="$_ICON" --percentage="0" --auto-close --text="Downloading package(s)...\nThis may take a while.\n" --text-align center --no-buttons --skip-taskbar  2>/dev/null;
      yad --center --undecorated --borders=35 --progress --window-icon="$_ICON" --percentage="0" --auto-close --text="Installing and configuring package(s)...\nThis may take a while.\n" --text-align center --no-buttons --skip-taskbar 2>/dev/null)

    if [ "${PIPESTATUS[0]}" -ne "0" ]; then
      sed -i '1 i\===========================\
Install Updates Error log\
===========================\
Install Updates could not successfully download and install available updates.\
Go to https://www.linuxliteos.com/forums/ and paste the log below into a new or existing thread for assistance.\n\
============ Log ===========\n' "$_LLUPDATES"
      sleep 4 | yad --center --borders=15 --image=error --progress --pulsate --window-icon="error" --auto-close --no-cancel --width="320" --height="80" --title="$_APPNAME - Error" \
                       --text="Errors occurred while updating. \n\n✔ Retrieving errors log. Please wait...\n" --text-align center --no-buttons --skip-taskbar 2>/dev/null
      view_save_log; exit 0
    fi

    # Halt updates script if user selects Cancel
    else
       rm_temp_files; unset _UPDATES
       yad --center --borders=15 --image=info --info --width="300" --button=gtk-ok:1 --timeout="6" --window-icon="$_ICON" --title="   $_APPNAME" --text="\nUpdates have been canceled.\n" --text-align center 2>/dev/null
       exit 0
    fi

# If Ubuntu base package has been upgraded during Install Updates, /usr/share/plymouth/themes/ubuntu-text/ubuntu-text.plymouth
llverprnt=$(awk '{print}' /etc/llver)
checkdefplym="/usr/share/plymouth/themes/ubuntu-text/ubuntu-text.plymouth"

if grep -q 0x988592 "$checkdefplym"; then
  sed -i "s/^title=Ubuntu.*$/title=$llverprnt/g" /usr/share/plymouth/themes/ubuntu-text/ubuntu-text.plymouth ;
  sed -i "s/black=0x2c001e/black=0x000000/g" /usr/share/plymouth/themes/ubuntu-text/ubuntu-text.plymouth ;
  sed -i "s/white=0xffffff/white=0xffffff/g" /usr/share/plymouth/themes/ubuntu-text/ubuntu-text.plymouth ;
  sed -i "s/brown=0xff4012/brown=0xffff00/g" /usr/share/plymouth/themes/ubuntu-text/ubuntu-text.plymouth ;
  sed -i "s/blue=0x988592/blue=0x000000/g" /usr/share/plymouth/themes/ubuntu-text/ubuntu-text.plymouth && update-initramfs -u |
  yad --center --undecorated --borders=35 --progress --auto-close --pulsate --text="Updating boot configuration please wait...\n" --text-align center --no-buttons --skip-taskbar
else
echo " "
fi

    PROCEED=$(yad --center --borders=15 --question --image=logviewer --width="300" --height="80" --window-icon="$_ICON" --title="  $_APPNAME" --text-align center --window-icon="$_ICON" --button="No":1 --button="Yes":0 --text="\n$_APPNAME completed successfully.\n\nWould you like to view the\n$_APPNAME log?\n" 2>/dev/null ; echo $?)
    if [ ${PROCEED} -eq 1 ]; then rm_temp_files; :; else
      yad --center --borders=15 --question --image=logviewer --text-info --width="750" --height="400" --button="Close":1 --button="Save":0 --title="  $_APPNAME Log" --filename="$_LLUPDATES" 2>/dev/null
        if [ $? -eq 0 ]; then
          # Save report
          szSavePath=$(yad --center --image=logviewer --borders=15 --width="600" --height="400" --window-icon="$_ICON" --title=" Save Updates Log" --file-selection --filename=/home/$_SVUSER/llupdates-"${_DATE}".txt --file-filter='*.txt' \
                              --file-filter='All files | *' --save --confirm-overwrite 2>/dev/null)
          sudo -u ${SUDO_USER:-$_SVUSER} cp "$_LLUPDATES" "$szSavePath"; rm_temp_files; else rm_temp_files; :
        fi
    fi
    if [ -s /var/run/reboot-required ]; then
        yad --center --question --image=gtk-info --borders=15 --width="300" --height="100" --window-icon="$_ICON" --button="Continue using my computer:"1 --button="Restart Now":0 --title="  Linux Lite Updates" --text-align center \
               --text="These updates require the system to be restarted\nfor the changes to take effect.\n\nWould you like to restart now?\n" 2>/dev/null
        if [ "$?" -eq "0" ]; then reboot; else exit 0 ; fi
    fi

exit 0
Title: Re: Install Updates - Yad version
Post by: DenW on November 15, 2017, 04:22:40 PM
Hi Vera/Jerry:  Thanks Vera for your kind words and good to know moving slider solved problems for you.

Jerry, I just copied the code from your original post (I think - because I did not see your latest post!) and installed in my updates-gui.  To be sure that it would be your code was doing the centering I moved my Window Placement slider to far left (small) and then ran Install Updates.  Worked perfectly with all windows centered but I did notice no blue bar except during download (thats why I wonder if I got your latest version anyway).
I know I commented in a previous post elsewhere about getting rid of the blue bar but I think I was premature because the updates at that time were small.  During a kernel update yesterday, and even with todays updates, I did notice significant pauses in the text changes during all phases of the update.  Even though it clearly states "this may take some time" I found I missed the reassurance of the moving blue bar as the text was sometimes sitting there for 20-30 seconds or more, which can seem like an eternity!  Does anyone else have a preference?
Title: Re: Install Updates - Yad version
Post by: Vera on November 16, 2017, 05:50:08 AM
I did the same as DenW yesterday (I used the first block of code but with my window slider setting moved back to the left to check for window centering). Windows were now centered during the update process! Yay!

However, I still got the moving blue bar. So that part sounds different to what DenW was seeing. I'm not sure why it was different for each of us.

I did this before Jerry posted the new block of code, so I'm not sure if the timing had an effect (did we maybe get different versions of the old code, DenW?) That part is confusing to me but I definitely got the blue bar. I remember it because I was contemplating whether the moving of the blue bar seemed slower or faster than it was before (ultimately neither one, as the rate seemed to vary during the process).

My next step is to try Jerry's second block of code. I will post again after I try it.
Title: Re: Install Updates - Yad version
Post by: Jerry on November 16, 2017, 05:52:41 AM
Yes, it's the second block of code.
Title: Re: Install Updates - Yad version
Post by: DenW on November 16, 2017, 10:47:10 AM
Hi Vera/Jerry:  Just did another small update and only got slow moving bar in Downloads (in fact it only seems to move when download item changes - is this really useful?), so I presume I have the latest version as all other blue bars have gone away.  Will leave it like this for future as available Updates window is so far always populated, which was the original problem.  Should this thread be marked as SOLVED?
Title: Re: Install Updates - Yad version
Post by: Vera on November 16, 2017, 01:17:56 PM
OK, I tried the new code. I'm going to divide up the process into 4 parts:

1. The first progress window when it finds what needs to be updated. This experience was great. I thought it was a big improvement to have a status bar instead of a flashy blue progress bar. Since things typically progress quickly here, it was very clear to the user what is happening. Perfect.
2. The list of things to be updated. Perfect. Nice, clear-looking list, fonts etc are easier to see than the old standard way.
3. Downloading the updates. This looked fine to me on this first run through, but I'd like to take a better look at it a second time.
4. Installing and configuring the updates. I liked how this kept to the same overall look as step 1 above to keep with the theme, but the downside was that things here at step 4 move much slower. Therefore, as a result it can be sitting on a particular status in the status bar for awhile. In the absence of anything else to tell the user "something is happening", the user might think the process has stalled. I'd consider whether an additional rotating icon needs to be added in, OR have the background of the status be a blue bar that gradually gets filled in (like in step 3 I think? - although I need to take a better look at step 3 next time).

So, steps 1 - 3 are perfect, I didn't see anything that looked confusing, it was clear what was happening at any time. Step 4, I'd like to see something a little different because the status can sometimes take a long time to change and the user might think the process is stuck (in the absence of seeing how far along they are in a progress bar or something like that). However, it's still pretty great as is.

Thanks for all the work on this Jerry!  :)
Title: Re: Install Updates - Yad version
Post by: Jerry on November 16, 2017, 09:50:46 PM
Folks, you are providing excellent feedback. Thank you all.

Sent from my Mobile phone using Tapatalk

Title: Re: Install Updates - Yad version
Post by: trinidad on December 03, 2017, 10:48:18 AM
What is the little green thing? Wine bottle? Flask of chemicals? Witches brew? Never noticed it before.

https://imgur.com/a/reIb2

TC
Title: Re: Install Updates - Yad version
Post by: Jerry on December 03, 2017, 10:55:18 AM
What icon theme?
Title: Re: Install Updates - Yad version
Post by: trinidad on December 03, 2017, 11:00:31 AM
Duh! Sorry Jerry another elderly moment. I switched icons to tango a few days ago and forgot about it.

TC
Title: Re: Install Updates - Yad version
Post by: Jerry on December 03, 2017, 11:02:53 AM
Np TC. From now on can you please embed your images in the Forum, rather thank linked to an external url? Thank you.
Title: Re: Install Updates - Yad version
Post by: Jerry on December 03, 2017, 11:03:52 AM
The icon is hard-linked to /usr/share/icons/Faenza/apps/scalable/synaptic.svg
Title: Re: Install Updates - Yad version
Post by: justme2 on December 17, 2017, 10:52:21 AM
I have substituted the Yad version for Install Updates and all is well up to now. For LL3.8 release I would like to see all update functions to use one window which remains open for the duration of the process. I find it disconcerting when one window closes and there is a delay (long in some circumstances - lots of updates?). I have messed up the updating process when there is no indication on screen and have had to shut down due to time constraints (wife waiting!).


Is this possible and if so what do others think? I don't understand the update script so I have no idea. Sometimes I do update/upgrade from a terminal, all in a single window.   :)