Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sat 18 Jan 2020, 14:46
All times are UTC - 4
 Forum index » House Training » Users ( For the regulars )
rox with transmision bar ??
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 2 of 3 [41 Posts]   Goto page: Previous 1, 2, 3 Next
Author Message
fabrice_035


Joined: 28 Apr 2014
Posts: 658
Location: Bretagne / France

PostPosted: Sat 02 Mar 2019, 11:27    Post subject:  

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 or Very Mad
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:

#!/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:

#!/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 ]

_________________
xenialpup 7.5 / Linux Kernel: 4.4.95 / Window Manager: JWM v2.3.7

Last edited by fabrice_035 on Thu 14 Mar 2019, 08:15; edited 14 times in total
Back to top
View user's profile Send private message 
Argolance


Joined: 06 Jan 2008
Posts: 3732
Location: PORT-BRILLET (Mayenne - France)

PostPosted: Mon 04 Mar 2019, 04:48    Post subject:  

Hello,
Thanks fabrice_035.
Quote:
If you want the already compiled version I can put it on a server

Yes, do it please! Wink

Cordialement.

_________________

A second life for your PCs...
Back to top
View user's profile Send private message Visit poster's website 
fabrice_035


Joined: 28 Apr 2014
Posts: 658
Location: Bretagne / France

PostPosted: Mon 04 Mar 2019, 07:56    Post subject:  

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:
/bin/cp "$1" "$2" "$3"


by

Code:
/bin/cp_original "$1" "$2" "$3"


and at end script replace

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


by

Code:
# !! 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 Rolling Eyes
I hope I'm understandable.
So you can test what I did

Regard

_________________
xenialpup 7.5 / Linux Kernel: 4.4.95 / Window Manager: JWM v2.3.7
Back to top
View user's profile Send private message 
Argolance


Joined: 06 Jan 2008
Posts: 3732
Location: PORT-BRILLET (Mayenne - France)

PostPosted: Mon 04 Mar 2019, 12:56    Post subject:  

Hello camarade Breton, Smile
... 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:
#cp_ -r /path/to/source/folder/* /path/to/target/folder

and there was nothing going on. Rolling Eyes

Cordialement.

_________________

A second life for your PCs...
Back to top
View user's profile Send private message Visit poster's website 
fabrice_035


Joined: 28 Apr 2014
Posts: 658
Location: Bretagne / France

PostPosted: Mon 04 Mar 2019, 14:07    Post subject:  

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

Code:

/bin/cp_original "$1" "$2" "$3"


And after testing command line copy i found an error.
You can move

Code:

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


after
Code:
 # 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:
if   [ "$proc" = "ROX-Filer" ] ; then


thank you for your attention

_________________
xenialpup 7.5 / Linux Kernel: 4.4.95 / Window Manager: JWM v2.3.7
Back to top
View user's profile Send private message 
Argolance


Joined: 06 Jan 2008
Posts: 3732
Location: PORT-BRILLET (Mayenne - France)

PostPosted: Mon 04 Mar 2019, 17:20    Post subject:  

...
Avec Rox, je ne suis parvenu à rien, désolé!
190304_221734_593x378_easyshot.jpg
 Description   
 Filesize   27.04 KB
 Viewed   311 Time(s)

190304_221734_593x378_easyshot.jpg


_________________

A second life for your PCs...
Back to top
View user's profile Send private message Visit poster's website 
fabrice_035


Joined: 28 Apr 2014
Posts: 658
Location: Bretagne / France

PostPosted: Mon 04 Mar 2019, 17:57    Post subject:  

Delete attachement, copy yourself the scripts
_________________
xenialpup 7.5 / Linux Kernel: 4.4.95 / Window Manager: JWM v2.3.7

Last edited by fabrice_035 on Wed 06 Mar 2019, 16:38; edited 2 times in total
Back to top
View user's profile Send private message 
Argolance


Joined: 06 Jan 2008
Posts: 3732
Location: PORT-BRILLET (Mayenne - France)

PostPosted: Mon 04 Mar 2019, 19:26    Post subject:  

Thanks.
Quote:
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.

_________________

A second life for your PCs...
Back to top
View user's profile Send private message Visit poster's website 
fabrice_035


Joined: 28 Apr 2014
Posts: 658
Location: Bretagne / France

PostPosted: Tue 05 Mar 2019, 02:28    Post subject:  

[quote="Argolance"]Thanks.
Quote:

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:

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


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

Code:

_________________
xenialpup 7.5 / Linux Kernel: 4.4.95 / Window Manager: JWM v2.3.7
Back to top
View user's profile Send private message 
Argolance


Joined: 06 Jan 2008
Posts: 3732
Location: PORT-BRILLET (Mayenne - France)

PostPosted: Wed 06 Mar 2019, 07:20    Post subject:  

Bonjour et merci,
Quote:
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.
190306_114948_516x228_easyshot.jpg
 Description   
 Filesize   14.84 KB
 Viewed   265 Time(s)

190306_114948_516x228_easyshot.jpg


_________________

A second life for your PCs...
Back to top
View user's profile Send private message Visit poster's website 
fabrice_035


Joined: 28 Apr 2014
Posts: 658
Location: Bretagne / France

PostPosted: Wed 06 Mar 2019, 09:28    Post subject:  

Hello,

I modified the scripts yesterday, everything is up to date and consistent with the file names, sorry for the inconvenience. Cool
Regard

_________________
xenialpup 7.5 / Linux Kernel: 4.4.95 / Window Manager: JWM v2.3.7
Back to top
View user's profile Send private message 
Argolance


Joined: 06 Jan 2008
Posts: 3732
Location: PORT-BRILLET (Mayenne - France)

PostPosted: Wed 06 Mar 2019, 12:58    Post subject:  

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? Rolling Eyes
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.*** Cool
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.Shocked
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! Very Happy

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.

_________________

A second life for your PCs...
Back to top
View user's profile Send private message Visit poster's website 
fabrice_035


Joined: 28 Apr 2014
Posts: 658
Location: Bretagne / France

PostPosted: Wed 06 Mar 2019, 13:48    Post subject:  

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 Embarassed

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.

_________________
xenialpup 7.5 / Linux Kernel: 4.4.95 / Window Manager: JWM v2.3.7
Back to top
View user's profile Send private message 
Argolance


Joined: 06 Jan 2008
Posts: 3732
Location: PORT-BRILLET (Mayenne - France)

PostPosted: Fri 08 Mar 2019, 10:12    Post subject:  

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

Cordialement.
190308_150830_516x407_easyshot.jpg
 Description   
 Filesize   43.34 KB
 Viewed   195 Time(s)

190308_150830_516x407_easyshot.jpg


_________________

A second life for your PCs...
Back to top
View user's profile Send private message Visit poster's website 
fabrice_035


Joined: 28 Apr 2014
Posts: 658
Location: Bretagne / France

PostPosted: Fri 08 Mar 2019, 15:06    Post subject:  

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...

_________________
xenialpup 7.5 / Linux Kernel: 4.4.95 / Window Manager: JWM v2.3.7
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 2 of 3 [41 Posts]   Goto page: Previous 1, 2, 3 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » Users ( For the regulars )
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1095s ][ Queries: 12 (0.0204s) ][ GZIP on ]