How to put a progress bar in dir2sfs? (Solved)
- rg66
- Posts: 1158
- Joined: Mon 23 Jul 2012, 05:53
- Location: Vancouver, BC Canada / Entebbe, Uganda Africa!?!
That's how the script was originally (from Saluki I think), if I remove "grep -v '\.'", it flashes 47% after it reaches 100. Can't get a working progress bar from your awk line.misko_2083 wrote:^this part has so many pipes.Code: Select all
script -q -c "stty rows 40 cols 100; mksquashfs "$t" "$z.sfs" $COMP" | while read -n 99 LINE ; do PROG=`echo $LINE | egrep '[0-9]\%' | cut -f1 -d% | awk '{print $NF}'| grep -v '\.'` echo "#$PROG%" echo $PROG done | yad --window-icon="application-x-squashfs-image" --progress --borders="10" --skip-taskbar --text="<b>Building $t.sfs</b>\n" \ --text-align="center" --width="250" --button="Stop!gtk-stop!Stop operation:1" --buttons-layout="center" --auto-close
Not sure what is invert match at the end grep -v '\.' doing.
Awk can do all of that.Code: Select all
script -q -c "stty rows 40 cols 100; mksquashfs "$t" "$z.sfs" $COMP" | awk '/\[*\]*[0-9]\%/{print "#",$NF;gsub("%","");print $NF; fflush(stdout)}' | yad --window-icon="application-x-squashfs-image" --progress --borders="10" --skip-taskbar --text="<b>Building $t.sfs</b>\n" \ --text-align="center" --width="250" --button="Stop!gtk-stop!Stop operation:1" --buttons-layout="center" --auto-close
X-slacko-5b1 - X-tahr-2.0 - X-precise-2.4
[url=http://smokey01.com/rg66/]X-series repo[/url]
[url=http://smokey01.com/rg66/]X-series repo[/url]
- misko_2083
- Posts: 114
- Joined: Tue 08 Nov 2016, 13:42
rg66 wrote:
If I add flush to the script this is working for me:
It did not flash 47% after 100, yad dialog closes because of --auto-close.
i used a different regular expression to search for strings. That could be it.
awk /\[*\]*[0-9]\%/ vs egrep '[0-9]\%'
The progress looks like this:
* script --return
-e, --return
Return the exit code of the child process. Uses the same format
as bash termination on signal termination exit code is 128+n.
Oh I see it must work without terminal.That's how the script was originally (from Saluki I think), if I remove "grep -v '\.'", it flashes 47% after it reaches 100. Can't get a working progress bar from your awk line.
If I add flush to the script this is working for me:
Code: Select all
script --return --flush --quiet --command \
"stty rows 40 cols 100; mksquashfs "$t" "$z.sfs" $COMP" |
awk '/\[*\]*[0-9]\%/{print "#",$NF;gsub("%","");print $NF; fflush(stdout)}' |
yad --window-icon="application-x-squashfs-image" --progress --borders="10" --skip-taskbar --text="<b>Building $t.sfs</b>\n" \
--text-align="center" --width="250" --button="Stop!gtk-stop!Stop operation:1" --buttons-layout="center" --auto-close
i used a different regular expression to search for strings. That could be it.
awk /\[*\]*[0-9]\%/ vs egrep '[0-9]\%'
The progress looks like this:
Code: Select all
file ..., uncompressed size 2755336 bytes
[=========\ ] 481/12359
3%
file ..., uncompressed size 726904 bytes
[==========\ ] 528/12359
4%
file ..., uncompressed size 577 bytes
[==============\ ] 719/12359
5%
-e, --return
Return the exit code of the child process. Uses the same format
as bash termination on signal termination exit code is 128+n.
Tried that, but no progress is showing for me.misko_2083 wrote:If I add flush to the script this is working for me:
Code:
script --return --flush --quiet --command \
"stty rows 40 cols 100; mksquashfs "$t" "$z.sfs" $COMP" |
awk '/\[*\]*[0-9]\%/{print "#",$NF;gsub("%","");print $NF; fflush(stdout)}' |
yad --window-icon="application-x-squashfs-image" --progress --borders="10" --skip-taskbar --text="<b>Building $t.sfs</b>\n" \
--text-align="center" --width="250" --button="Stop!gtk-stop!Stop operation:1" --buttons-layout="center" --auto-close
@rg66
Maybe you noticed also that the progress sometimes jumps back for a split second to under 10%, although not a real problem, but found that piping first to strings (or busybox strings) solves it:
Code: Select all
echo $LINE | busybox strings |egrep '[0-9]\%' | cut -f1 -d% |awk '{print $NF}'|grep -v '\.'
- rg66
- Posts: 1158
- Joined: Mon 23 Jul 2012, 05:53
- Location: Vancouver, BC Canada / Entebbe, Uganda Africa!?!
@misko_2083
Also tried your code and couldn't get a progress bar.
@fredx181
Yes, I have noticed it jumping back to 10 or whatever percent. I'll add the "busybox strings", stuff like that bugs me. I've also gone back to Xdialog, yad --auto-close closes the window before it's finished squashing where as Xdialog stays open.
Cheers!
Also tried your code and couldn't get a progress bar.
@fredx181
Yes, I have noticed it jumping back to 10 or whatever percent. I'll add the "busybox strings", stuff like that bugs me. I've also gone back to Xdialog, yad --auto-close closes the window before it's finished squashing where as Xdialog stays open.
Cheers!
X-slacko-5b1 - X-tahr-2.0 - X-precise-2.4
[url=http://smokey01.com/rg66/]X-series repo[/url]
[url=http://smokey01.com/rg66/]X-series repo[/url]
- rg66
- Posts: 1158
- Joined: Mon 23 Jul 2012, 05:53
- Location: Vancouver, BC Canada / Entebbe, Uganda Africa!?!
The strings addition really sorts things out, nice one Fred. The line can be only "echo $LINE | strings | egrep '[0-9]\%' | awk '{print $NF}'; done" and you get:
My script is now:
This also works for unsquashfs as well
Code: Select all
10%
10%
10%
14%
16%
18%
19%
20%
33%
51%
78%
100%
100%
100%
100%
100%
100%
100%
Kbytes)
bytes)
bytes)
Code: Select all
#!/bin/bash
t=`echo "$1" | sed "s/\/$//"`
z=`echo "$1" | sed "s/\/$//"`
[ ! -d "$t" ] && exit
if [ -f "$z.sfs" ];then
yad --window-icon="application-x-squashfs-image" --title="Overwrite" --text="<b>$(basename $z).sfs</b> already exists.\n Would you like to overwrite it?\n" \
--text-align="center" --borders="10" --buttons-layout="center" --button="gtk-yes:0" --button="gtk-no:1"
case $? in
0) rm -f "$z.sfs" "$z.sfs-md5.txt" ;;
*) exit ;;
esac
fi
yad --window-icon="application-x-squashfs-image" --title "Choose Compression Type" --text "Choose which algorthim to compress the sfs with.
Choosing XZ will give you a smaller sfs but may
be slower than GZIP on very lowspec machines.
XZ-HC is a higher compression XZ squashfile." --text-align="center" --borders="5" --buttons-layout="center" \
--button="GZIP:0" --button="XZ:1" --button="XZ-HC:2"
case $? in
0) COMP="-comp gzip" ;;
1) COMP="-comp xz" ;;
2) COMP="-comp xz -b 1024k -Xbcj x86" ;;
*) exit ;;
esac
(script -q -c "stty rows 40 cols 100; mksquashfs "$t" "$z.sfs" $COMP" | while read -n 99 LINE ; do
echo $LINE | strings | egrep '[0-9]\%' | awk '{print $NF}'; done
) | Xdialog --title "Building Squashfile " --gauge "Building $(basename $z).sfs\n\nPlease Wait..." 7 50 0
if [ $? -ne 0 ]; then
killall mksquashfs
rm -f typescript
exit
fi
rm -f typescript
md5sum "$z.sfs" > "$z.sfs-md5.txt"
sync
X-slacko-5b1 - X-tahr-2.0 - X-precise-2.4
[url=http://smokey01.com/rg66/]X-series repo[/url]
[url=http://smokey01.com/rg66/]X-series repo[/url]
- rg66
- Posts: 1158
- Joined: Mon 23 Jul 2012, 05:53
- Location: Vancouver, BC Canada / Entebbe, Uganda Africa!?!
OK, will change to busybox strings. I had to get script from slackware util-linux pkg as it's not included in slacko.fredx181 wrote:.I'd say that "busybox strings" would be better because not every distro has "strings"
(btw, that might go for "script" also, anyway for info: it's part of package "bsdutils" in Ubuntu and Debian)
Fred
I've also got rid of the t=, z= and just went with $1 as I don't see the point of those as the version check is gone.I must have nothing better to do than play with this script, lol.
X-slacko-5b1 - X-tahr-2.0 - X-precise-2.4
[url=http://smokey01.com/rg66/]X-series repo[/url]
[url=http://smokey01.com/rg66/]X-series repo[/url]
- rg66
- Posts: 1158
- Joined: Mon 23 Jul 2012, 05:53
- Location: Vancouver, BC Canada / Entebbe, Uganda Africa!?!
Definitely my last one. Reverting back to "read -n 50 LINE" captures a lot more lines.
Edit: I've added a pop-up warning for folders with white spaces just in case.
Code: Select all
#!/bin/bash
[ ! -d "$1" ] && exit
if [ "$(echo "$1" | wc -w)" -gt 1 ]; then
yad --window-icon="application-x-squashfs-image" --title="Rename Folder" --text="Remove blank spaces from\n<b>$(basename "$1")</b> \
and try again." --text-align="center" --borders="10" --width="220" --no-buttons --timeout="3"
exit
fi
if [ -f "$1.sfs" ];then
yad --window-icon="application-x-squashfs-image" --title="Overwrite" --text="<b>$(basename $1).sfs</b> already exists.\n Would you like to overwrite it?\n" \
--text-align="center" --borders="10" --buttons-layout="center" --button="gtk-yes:0" --button="gtk-no:1"
case $? in
0) rm -f "$1.sfs" "$1.sfs-md5.txt" ;;
*) exit ;;
esac
fi
yad --window-icon="application-x-squashfs-image" --title "Choose Compression Type" \
--text="XZ will give you a smaller sfs but may
be slower than GZIP on older machines.
XZ-HC is a higher compression XZ sfs." --text-align="center" --borders="10" --buttons-layout="center" \
--button="GZIP:0" --button="XZ:1" --button="XZ-HC:2"
case $? in
0) COMP="-comp gzip" ;;
1) COMP="-comp xz" ;;
2) COMP="-comp xz -b 1024k -Xbcj x86" ;;
*) exit ;;
esac
(script -q -c "stty rows 40 cols 100; mksquashfs "$1" "$1.sfs" $COMP" | while read -n 50 LINE ; do
echo $LINE | busybox strings | egrep '[0-9]\%' | awk '{print $NF}'; done
) | Xdialog --title "Building Squashfile " --gauge "Building $(basename $1).sfs\n\nPlease Wait..." 7 50 0
if [ $? -ne 0 ]; then
killall mksquashfs
rm -f typescript
exit
fi
rm -f typescript
md5sum "$1.sfs" > "$1.sfs-md5.txt"
sync
X-slacko-5b1 - X-tahr-2.0 - X-precise-2.4
[url=http://smokey01.com/rg66/]X-series repo[/url]
[url=http://smokey01.com/rg66/]X-series repo[/url]
rg66 wrote:Definitely my last one. Reverting back to "read -n 50 LINE" captures a lot more lines.
Edit: I've added a pop-up warning for folders with white spaces just in case.
Hi rg66,
Am in X-Slacko-4.4 now, been testing this latest iteration of the script above for the last hour. Works nice! I put it on the desktop, and every folder I've dropped onto it (from different partitions even) works & up pops the dialog box, and away she goes. Progress bar works good too. Nice job!
I just have one question: you wrote this above in an earlier message:
Code: Select all
This also works for unsquashfs as well Very Happy
Was/Is the script meant to do unsquashing too just by dropping a .sfs on it? (I don't see unsquashfs commands in the script, so was trying to figure out what you meant when you wrote "this also works for unsquashfs as well...very happy".
P.S. Just found something weird...in Micko's latest Slacko64 (700-r3), on another machine at my desk here, the script does nothing. It won't launch at all, even though it is set up the same way with the same permissions as in X-Slacko-4.4. Weird, as it should easily run in 64-bit slacko because it's only a script after all, right?
- rg66
- Posts: 1158
- Joined: Mon 23 Jul 2012, 05:53
- Location: Vancouver, BC Canada / Entebbe, Uganda Africa!?!
Sorry belham2, I meant the code will also work with the unsquashfs command.belham2 wrote:I just have one question: you wrote this above in an earlier message:
Am I misunderstanding? I dropped one of the newly created .sfs files on the script to test the unsquashfs capabilitiy, and the script does nothing.Code: Select all
This also works for unsquashfs as well Very Happy
Was/Is the script meant to do unsquashing too just by dropping a .sfs on it? (I don't see unsquashfs commands in the script, so was trying to figure out what you meant when you wrote "this also works for unsquashfs as well...very happy".
P.S. Just found something weird...in Micko's latest Slacko64 (700-r3), on another machine at my desk here, the script does nothing. It won't launch at all, even though it is set up the same way with the same permissions as in X-Slacko-4.4. Weird, as it should easily run in 64-bit slacko because it's only a script after all, right?
I've updated pac-tools with the new progress bar (attached below, just remove fake .gz and make sure it's executable) put it in /usr/bin. You can select as many sfs's as you want (as long as /tmp has enough space to extract them) and right click > repack-extract packages > extract. You can also put the new dir2sfs in /sbin and right click multiple folders > Convert to sfs. The right click options are in X-series and Carolina.
Slacko64 (700-r3) probably doesn't have yad so the script will fail. Also check if it has the script command, if not, download slackware util-linux from the repo.
Edit: pac-tools had a few typo's do to a sed accident , I've uploaded a new one, see below.
- Attachments
-
- pac-tools.gz
- remove fake .gz
- (5.16 KiB) Downloaded 257 times
Last edited by rg66 on Fri 06 Oct 2017, 05:12, edited 1 time in total.
X-slacko-5b1 - X-tahr-2.0 - X-precise-2.4
[url=http://smokey01.com/rg66/]X-series repo[/url]
[url=http://smokey01.com/rg66/]X-series repo[/url]
Hi Belham, here's sfs2dir, basically the same as the last dir2sfs from rg66, but the other way around.
Unsquashes to directory name, same as the name of .sfs (but without the .sfs extension)
Fred
Unsquashes to directory name, same as the name of .sfs (but without the .sfs extension)
Code: Select all
#!/bin/bash
[ ! -f "$1" ] && exit
DIR="${1%.*}"
if [ "$(echo "$1" | wc -w)" -gt 1 ]; then
yad --window-icon="application-x-squashfs-image" --title="Rename File" --text="Remove blank spaces from\n<b>$(basename "$1")</b> \
and try again." --text-align="center" --borders="10" --width="220" --no-buttons --timeout="3"
exit
fi
if [ -d "$DIR" ];then
yad --window-icon="application-x-squashfs-image" --title="Overwrite" --text="<b>$(basename $DIR)</b> already exists.\n Would you like to overwrite it?\n" \
--text-align="center" --borders="10" --buttons-layout="center" --button="gtk-yes:0" --button="gtk-no:1"
case $? in
0) rm -rf "$DIR" ;;
*) exit ;;
esac
fi
(script -q -c "stty rows 40 cols 100; unsquashfs -d "$DIR" "$1"" | while read -n 50 LINE ; do
echo $LINE | busybox strings | egrep '[0-9]\%' | awk '{print $NF}'; done
) | Xdialog --title "Extracting Squashfile " --gauge "Extracting $(basename $1)\n\nPlease Wait..." 7 50 0
if [ $? -ne 0 ]; then
killall unsquashfs
rm -f typescript
exit
fi
rm -f typescript
sync
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
goingnuts and I did a progress bar implementation for tar here ... could probably be adapted
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].
Hi all.
I still think you guys are foillowing the principle: "Why do simple when you can do
complicated!" A couple of lines of poetry are in order, I think:
As a reminder:
http://murga-linux.com/puppy/viewtopic. ... ost#969545
Where is the world heading?!
Merrry Christmas to all.
I still think you guys are foillowing the principle: "Why do simple when you can do
complicated!" A couple of lines of poetry are in order, I think:
Really!"As I see you guys go,
My love for console grows."
As a reminder:
http://murga-linux.com/puppy/viewtopic. ... ost#969545
Where is the world heading?!
Merrry Christmas to all.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
Hi all
This was just what I was looking for!
Up until this point the other versions didn't allow me to have several working at the same time, not sure why.
I have made some modifications and the yad version is my preferred version.
stemsee
This was just what I was looking for!
Up until this point the other versions didn't allow me to have several working at the same time, not sure why.
I have made some modifications and the yad version is my preferred version.
stemsee
- Attachments
-
- xscreenshot-20191021T200553.png
- (6.56 KiB) Downloaded 247 times
The only problem I have is that with --auto-close we don't see the progress bar reach the end. Without --auto-close we have to manually close the yad gui. either by getting focus and pressing Esc key, or using the Stop button.
It would be great to get the 100 exported so some monitoring loop could kill the yad when 100 has been detected, but I couldn't do it.
stemsee
It would be great to get the 100 exported so some monitoring loop could kill the yad when 100 has been detected, but I couldn't do it.
stemsee
- Attachments
-
- dir2sfs.gz
- rename to dir2sfs
- (1.74 KiB) Downloaded 130 times