rox with transmision bar ??

Using applications, configuring, problems
Message
Author
User avatar
fabrice_035
Posts: 765
Joined: Mon 28 Apr 2014, 17:54
Location: Bretagne / France

#16 Post by fabrice_035 »

Hi

This scripts show progress bar with ROX-Filer



1[EDIT] New version (1.1) now script use gtk progress bar, it's better because it uses GTK Theme
2[EDIT] no need recompile Rox, easy way : look my next message!
3[EDIT] 1.2 update script ! , better way
4[EDIT] fixed a bug with the cp command when an argument is missing :evil:
5[EDIT] My bad, I used "$1" "$2" too pass cp args, but "$@" better! update gtk_progress bar too / use rsync -ah = high speed
6[EDIT] You must have RSYNC version >= 3.1.1 (support for --info=progress2 option) and better secure off course
7[EDIT] update 2 scripts, now "--no-preserve=context,links" work, Thanks Mister Argolance for your patience.

Code: Select all

#!/bin/sh
#
# this script is called by  ROX-Filer
#--------------$1 $2 $3
#--------------args / source / destination
# version 1.4 , correctif && soluce for  --no-preserve=context,links args
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# you need rename /bin/cp as /bin/cp_original
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# copy this script in /bin and named it cp
# _______________________________________


# get pid of this script
p="$$"

cleanup () {
[ -f "/tmp/rsync.log" ] && rm /tmp/rsync.log
[ -f "/tmp/rsync_.log" ] && rm /tmp/rsync_.log
[ -f "/tmp/rsync_ok.log" ] && rm /tmp/rsync_ok.log
[ -f "/tmp/numeric" ] && rm /tmp/numeric
}
export -f cleanup

_term() {  
# abort copy in ROX
cleanup
}
trap _term SIGTERM


# to be sure that it is ROX who calls
# get string name of process parent
proc=$(ps -p  `ps -o ppid= -p $p`  -o comm=)

# if it's ROX-filer caller 
if   [ "$proc" = "ROX-Filer" ] ; then

#check file size

[ -f "$3" ] && fz=$(du "$3" | awk -F " " '{print $1}' ) ||  fz=$(du "$2" | awk -F " " '{print $1}' ) 
# set limit = 70M, otherwise use standart cp binarie
limit="70000"

if [[ "$fz" -lt "$limit" ]] ; then
/bin/cp_original "$@"
exit 0
fi

if [ -f  "/tmp/start_gtkbar" ] ; then
#always run
:
else
# start gtk
touch /tmp/rsync.log
touch /tmp/rsync_.log
# open gtk progress bar ->
/usr/local/bin/rsync_gtk.sh "$@"  /dev/null 2>&1 &
fi
# check for '--no-preserve=context,links .... cp --args with comma ....'
if [ "$4" = "" ] ; then
rsync -ah --info=progress2 --append --inplace --partial -args --log-file="/tmp/rsync_.log" "$2" "$3"   > /tmp/rsync.log 
else
rsync -ah --info=progress2 --append --inplace --partial -args --log-file="/tmp/rsync_.log" "$3" "$4"  > /tmp/rsync.log 
fi


# force close gtk ->
echo "100%" >> /tmp/numeric
#cleanup log
cleanup

if [ -f  "/tmp/start_gtkbar" ] ; then
rm /tmp/start_gtkbar
fi

# !! not ROX-filer , call original cp command !!
else
/bin/cp_original "$@"
fi


Gtk Progress Bar, copy script in /usr/local/bin named it rsync_gtk.sh

Code: Select all

#!/bin/sh
# rsync_gtk.sh
# show a progress bar and acces log from rsync
# version 1.4 
# & just one progressbar, use GTK Theme!
# & update, kill tail from pid 
# & update, force waiting to make sure it works.
# update title bar

# prevent multiple open
touch /tmp/start_gtkbar
# source name copy for title bar
if [ "$4" = "" ] ; then
title=`basename "$2"`
else
title=`basename "$3"`
fi


# food for progressbar
echo -e "[Start Copy]\n1%" > /tmp/numeric
# force wait because sometimes rsync log and gtkdialog operations take time so progressbar is froze
sleep 1

calculat () {
if [ -s "/tmp/rsync.log" ] ; then
tr '\r' '\n' < /tmp/rsync.log > /tmp/rsync_ok.log
i=$(cat /tmp/rsync_ok.log  | tail -n 1 | awk -F " " '{print $2}' | tr -d '%')
x=$(tail -n 1 /tmp/rsync_ok.log | awk -F " " '{print "["  $3 " " $4 "]"}') 
echo -e "$x \n $i%" >> /tmp/numeric
fi
}
export -f calculat

GTKDIALOG=gtkdialog
MAIN_DIALOG='
<window title="'$title'"  icon_name="gtk-copy" resizable="true">
 <progressbar sensitive="true">
  <input>tail -f  '"/tmp/numeric"' &  echo "$!" > /tmp/rsync_gtk_pidnum</input>
 <action function="closewindow">MAIN_DIALOG</action>
 <action function="exit">Ready</action>
</progressbar> 
<timer  milliseconds="true" visible="false" interval="1000">
 <action>calculat</action>
 </timer> 
</window>'

export MAIN_DIALOG
case $1 in
	-d | --dump) echo "$MAIN_DIALOG" ;;
	*) $GTKDIALOG --program=MAIN_DIALOG ;;
esac

# kill tail from pid
kill -9 `cat /tmp/rsync_gtk_pidnum`
rm /tmp/rsync_gtk_pidnum

[ -f  "/tmp/start_gtkbar" ] && rm /tmp/start_gtkbar
[ -f  "/tmp/rsync_gtk_pidnum" ] && rm /tmp/rsync_gtk_pidnum


...........................[ Preview ]
Image
Last edited by fabrice_035 on Thu 14 Mar 2019, 12:15, edited 14 times in total.
Bionicpup64-8.0 _ Kernel 5.4.27-64oz _ Asus Rog GL752

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#17 Post by Argolance »

Hello,
Thanks fabrice_035.
If you want the already compiled version I can put it on a server
Yes, do it please! :wink:

Cordialement.

User avatar
fabrice_035
Posts: 765
Joined: Mon 28 Apr 2014, 17:54
Location: Bretagne / France

#18 Post by fabrice_035 »

Salut Argolance,

Finally I think it is better to rename the original cp file(in /bin/) and name my script cp

For example, rename cp as cp_original (in /bin/ directory)

and replace in my cp script

Code: Select all

/bin/cp "$1" "$2" "$3" 
by

Code: Select all

/bin/cp_original "$1" "$2" "$3" 
and at end script replace

Code: Select all

# !! not ROX-filer , call original cp command !! 
else 
: 
fi 
by

Code: Select all

# !! not ROX-filer , call original cp command !! 
else 
/bin/cp_original "$1" "$2" "$3"
fi 
In the futur way i think it will be necessary to ask for a patch to add an option in the rox interface to choose if the user uses the original cp bin or use a specific script...perhaps
but now it's time, there is no need to recompile ROX Filer
But don't forget copy first my 2 scripts before rename cp :roll:
I hope I'm understandable.
So you can test what I did

Regard
Bionicpup64-8.0 _ Kernel 5.4.27-64oz _ Asus Rog GL752

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#19 Post by Argolance »

Hello camarade Breton, :)
... And what's happening when using your cp command in console or inside a script (as it is already the case in many scripts/programs)?
I copied the two scripts given above in /usr/bin and tried to use cp_ as if it was a standalone "standard" command, for example:

Code: Select all

#cp_ -r /path/to/source/folder/* /path/to/target/folder
and there was nothing going on. :roll:

Cordialement.

User avatar
fabrice_035
Posts: 765
Joined: Mon 28 Apr 2014, 17:54
Location: Bretagne / France

#20 Post by fabrice_035 »

Hey voisin 8) ,
You make a good point.
My script asks who is calling it. If it's not Rox, then he only execute

Code: Select all

/bin/cp_original "$1" "$2" "$3"
And after testing command line copy i found an error.
You can move

Code: Select all

# cleanup
rm /tmp/rsync.log
rm /tmp/rsync_.log
after

Code: Select all

 # force close gtk ->
But If your question is to make the graphical user interface appear even when you use the command line, you must delete the start control:

Code: Select all

if   [ "$proc" = "ROX-Filer" ] ; then
thank you for your attention
Bionicpup64-8.0 _ Kernel 5.4.27-64oz _ Asus Rog GL752

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#21 Post by Argolance »

...
Avec Rox, je ne suis parvenu à rien, désolé!
Attachments
190304_221734_593x378_easyshot.jpg
(27.04 KiB) Downloaded 328 times

User avatar
fabrice_035
Posts: 765
Joined: Mon 28 Apr 2014, 17:54
Location: Bretagne / France

#22 Post by fabrice_035 »

Delete attachement, copy yourself the scripts
Last edited by fabrice_035 on Wed 06 Mar 2019, 20:38, edited 2 times in total.
Bionicpup64-8.0 _ Kernel 5.4.27-64oz _ Asus Rog GL752

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#23 Post by Argolance »

Thanks.
your screenshot shows that you modified the script in a bad way
I copied/pasted the scripts given above as they are, then tested them with Rox but without success. Only after that, I modified the scripts following your advise to test cp in command line.This is what the picture shows.

So if I use the scripts you sent as compressed file above, I copy cp to /bin (where is the original cp, but what do I do with it? Rename as cp_original?), and rsync_gtk.sh to /usr/local/bin?

I will test this tomorow.
Good night.

User avatar
fabrice_035
Posts: 765
Joined: Mon 28 Apr 2014, 17:54
Location: Bretagne / France

#24 Post by fabrice_035 »

Argolance wrote:Thanks.
So if I use the scripts you sent as compressed file above, I copy cp to /bin (where is the original cp, but what do I do with it? Rename as cp_original?), and rsync_gtk.sh to /usr/local/bin?
Yeah that's right! So i you want test cp script without Rox, make this change in cp script

BEFORE

Code: Select all

# if it's ROX-filer caller
if   [ "$proc" = "ROX-Filer" ] ; then 
AFTER

Code: Select all

# if it's ROX-filer caller
proc="ROX-Filer"
if   [ "$proc" = "ROX-Filer" ] ; then 
Bionicpup64-8.0 _ Kernel 5.4.27-64oz _ Asus Rog GL752

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#25 Post by Argolance »

Bonjour et merci,
So if I use the scripts you sent as compressed file above, I copy cp to /bin (where is the original cp, but what do I do with it? Rename as cp_original?), and rsync_gtk.sh to /usr/local/bin?
fabrice_035 wrote:Yeah that's right!
Not quite Mate...
  • - Your script calls "ori_cp", and not "cp_original"
    - As soon as cp is renamed (even as "ori_cp"), it is not possible anymore to (use the command cp to) copy rshync_gtk.sh to /usr/local/bin!
As simple user who tries to help and test your work, I was wondering if you might not give a more detailed and precise protocol to do it properly.
Why not a pet package with pinstall.sh and puninstall.sh files?

Furthermore, you were right: the modifications I previously made to get cp script work without Rox were wrong. Besides, even if I follow the letter, something goes wrong, with or without...

Cordialement.
Attachments
190306_114948_516x228_easyshot.jpg
(14.84 KiB) Downloaded 280 times

User avatar
fabrice_035
Posts: 765
Joined: Mon 28 Apr 2014, 17:54
Location: Bretagne / France

#26 Post by fabrice_035 »

Hello,

I modified the scripts yesterday, everything is up to date and consistent with the file names, sorry for the inconvenience. 8)
Regard
Bionicpup64-8.0 _ Kernel 5.4.27-64oz _ Asus Rog GL752

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#27 Post by Argolance »

Hello,
I copied/pasted the scripts given above (v1.2 - 20190306) as /bin/cp_ (temporarily) and as /usr/local/bin/rsync_gtk.sh, gave them permissions, renamed /bin/cp to /bin/cp_original then /bin/cp_ as /bin/cp.
So far so good? :roll:
Then, I opened an existing directory somewhere in my documents containing files, created a "Newdir", dragged and dropped some files from that directory to this subdirectory.
Rox window "Copy" opened.
***That's when things got complicated.*** 8)
Nothing happened.
Waited some time, tried to close the rebellious window... without success!
Tried the copy manipulation from beginning again.
And again... to be sure!
Mouse cursor began to have very curious behavior.
Memory overflowed so I could not do anything else than roughly shutdown computer, restart it.
Ô dear, not possible to restart.:shock:
Tried again... to be sure!
...
So I ran another session, checked my pupsave which was "clean", had the idea to edit it, deleted /bin/cp and renamed /bin/cp_original to /bin/cp and my computer started again.

Here I am, mate: hot as hell! :D

So what about the original cp command when used by other processes than Rox (question I already asked at the beginning of this thread)?
It would seem to be a problem at least...

Cordialement.

User avatar
fabrice_035
Posts: 765
Joined: Mon 28 Apr 2014, 17:54
Location: Bretagne / France

#28 Post by fabrice_035 »

Argolance wrote:Hello,
I copied/pasted the scripts given above (v1.2 - 20190306) as /bin/cp_ (temporarily) and as /usr/local/bin/rsync_gtk.sh, gave them permissions, renamed /bin/cp to /bin/cp_original then /bin/cp_ as/bin/ cp.
.
[edit] Argolance was right, update cp script :oops:

:wink: The first script must replace cp in /bin/ but before rename cp as cp_original
Of course many process (mostly scripts) use cp every time.
Your question: what happens when a program calls default cp command (which now is my script.) ? simply if it's not Rox-Filer which call, the script call /bin/cp_original (and passing the arguments)
On my side I don't find any problems.
Regard.
Bionicpup64-8.0 _ Kernel 5.4.27-64oz _ Asus Rog GL752

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#29 Post by Argolance »

Hello,
On my side: an image is better than long speeches... :?

Cordialement.
Attachments
190308_150830_516x407_easyshot.jpg
(43.34 KiB) Downloaded 209 times

User avatar
fabrice_035
Posts: 765
Joined: Mon 28 Apr 2014, 17:54
Location: Bretagne / France

#30 Post by fabrice_035 »

Point excellent Mister Argolance. it's harder than expected to find all the situations when you replace the command cp. Strange my rox never user "--no-preserve=context,links"
I understood where the problem was.
I'll think about that later.
Regard.
[ EDIT ] Solved, waiting for testers...
Bionicpup64-8.0 _ Kernel 5.4.27-64oz _ Asus Rog GL752

User avatar
Argolance
Posts: 3767
Joined: Sun 06 Jan 2008, 22:57
Location: PORT-BRILLET (Mayenne - France)
Contact:

#31 Post by Argolance »

Bonjour,
Version 1.4 works great!
Thank you a lot.

A quick question: the progress bar appears when you copy large file(s). Now, what about copying a huge directory containing many small files? Isn't it precisely in this kind of situation (it can take time, especially when the destination is an external drive), that a global progress bar would be really welcome?

Cordialement.

User avatar
fabrice_035
Posts: 765
Joined: Mon 28 Apr 2014, 17:54
Location: Bretagne / France

#32 Post by fabrice_035 »

Hi,

Thanks again Mister Argolance, good teamwork :D

I don't know why ROX-Filer show progressbar when we choose multiple files and copy it but nothing when it is needed copying a huge directory .

The only way to improve this is to work on the ROX-Filer source code i think.

Regard
Bionicpup64-8.0 _ Kernel 5.4.27-64oz _ Asus Rog GL752

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#33 Post by MochiMoppel »

fabrice_035 wrote:I don't know why ROX-Filer show progressbar when we choose multiple files and copy it but nothing when it is needed copying a huge directory
Because progressbar shows the no. of finished copies. When you copy 2 large files ROX-Filer will show an empty progressbar while the copy of the first file is in progress. After finishing the first file the progressbar immediately shows 50%.

I hope this explains why you don't see anything when you copy only a single file, no matter if it's big or small. ROX-Filer doesn't even bother to add a progressbar as a progressbar would jump from empty to 100%, followed by an immediate closure of the dialog.
Last edited by MochiMoppel on Thu 14 Mar 2019, 12:35, edited 1 time in total.

User avatar
fabrice_035
Posts: 765
Joined: Mon 28 Apr 2014, 17:54
Location: Bretagne / France

#34 Post by fabrice_035 »

MochiMoppel wrote:
fabrice_035 wrote:I don't know why ROX-Filer show progressbar when we choose multiple files and copy it but nothing when it is needed copying a huge directory
Because progressbar shows the no. of finished copies. When you copy 2 large files ROX-Filer will show an empty progressbar while the copy of the first file is in progress. After finishing the first file the progressbar immediately shows 50%.

I hope this explains why you don't see anything when you copy only 1 file, no matter if it's big or small.
The problem raised concerns the difference between copying multiple files and copying a folder that contains multiple files.
*In the first case : show progress bar
*second case : no progress bar visible
Bionicpup64-8.0 _ Kernel 5.4.27-64oz _ Asus Rog GL752

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#35 Post by MochiMoppel »

fabrice_035 wrote:*second case : no progress bar visible
Technically a folder is also a file. If in my example the first huge file would be a folder containing multiple files, you would see 50% progress after the folder was copied. ROX thinks of items to copy, and in this case 2 items. Doesn't matter if the items are regular files, links or folders. In order to show progress of the files contained in the folder. ROX would have to analyze folder content before starting with the copy process. No idea why this isn't done. To keep it simple? :lol:

Post Reply