Advertisement
Guest User

whiptail no progress

a guest
Mar 8th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.53 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3.  
  4. pid=
  5. tmpd=
  6.  
  7. tidyUp()
  8. {
  9.     # Clean up when we're done
  10.     exec 3>&-
  11.     [[ -n "$tmpd" ]] && rm -rf "$tmpd"
  12. }
  13. trap 'ss=$?; tidyUp; exit $ss' 1 2 15
  14.  
  15.  
  16. updateGauge()
  17. {
  18.     local percent="$1" message="$2"
  19.     printf "XXX\n%d\n%s\nXXX\n" $percent "$message" >&3
  20. }
  21.  
  22.  
  23. # Create the FIFO for communicating with the whiptail gauge
  24. tmpd=$(mktemp --tmpdir --directory "wt.XXXXXXXXXX")
  25. mkfifo "$tmpd/fifo"
  26.  
  27. cd $tmpd
  28.  
  29. # Start up the whiptail gauge and associate FD 3 with its status
  30. whiptail --title 'Progress meter' --gauge 'Starting examples' 6 50 0 <"$tmpd/fifo" &
  31. exec 3>"$tmpd/fifo"
  32.  
  33. # Real code starts here
  34. percent=0
  35.  
  36. for example in 1 2 3
  37. do
  38.     updateGauge $percent "Getting example $example"
  39.     mkdir -p ~/.steam/compatibilitytools.d;
  40.     PROTONVERSIONNUMBER=$(curl -v --silent https://api.github.com/repos/popsUlfr/Proton/releases 2>&1 | grep "tag_name" | head -n 1 | cut -f4,4 -d"\"");
  41.     REPLACING=$(curl -v --silent https://api.github.com/repos/popsUlfr/Proton/releases 2>&1 | grep "target_commitish" | head -n 1 | cut -f4,4 -d"\"" | sed "s/[^_]\+/\L\u&/g");
  42.     PROTONVERSION=${REPLACING/_G/-6_G};
  43.     PROTONNAME=$PROTONVERSION"_"${PROTONVERSIONNUMBER##*-};
  44.         wget -q https://github.com/popsUlfr/Proton/releases/download/$PROTONVERSIONNUMBER/$PROTONNAME.tar.xz;
  45.  
  46.     percent=$((percent + 20))
  47. done
  48.  
  49. for another in 4 5
  50. do
  51.     updateGauge $percent "Doing work for another example $another"
  52.     tar xf $PROTONNAME.tar.xz -C ~/.steam/compatibilitytools.d/
  53.  
  54.     percent=$((percent + 20))
  55. done
  56.  
  57. # Done
  58. tidyUp
  59. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement