(OLD) (ARCHIVED) Puppy Linux Discussion Forum Forum Index (OLD) (ARCHIVED) Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info

This forum can also be accessed as http://oldforum.puppylinux.com
It is now read-only and serves only as archives.

Please register over the NEW forum
https://forum.puppylinux.com
and continue your work there. Thank you.

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups    
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Thu 24 Sep 2020, 12:11
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Is there another way to set wallpaper for the Rox desktop?
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies. View previous topic :: View next topic
Page 7 of 7 [104 Posts]   Goto page: Previous 1, 2, 3, 4, 5, 6, 7
Author Message
L18L


Joined: 19 Jun 2010
Posts: 3493
Location: www.eussenheim.de/

PostPosted: Mon 02 Sep 2013, 13:34    Post subject:  

some1 wrote:
.@sunburnt:Thanks
grep backdrop /root/Choices/ROX-Filer/PuppyPin | sed 's#</.*$##;s#^.*>##'
WORKS at my place.

...also at my place Very Happy
Back to top
View user's profile Send private message 
Karl Godt


Joined: 20 Jun 2010
Posts: 4208
Location: Kiel,Germany

PostPosted: Mon 02 Sep 2013, 15:54    Post subject:  

Code:
sed 's#what#ever#' /path/to/file

might not work with bash-3.2 . But should work with stock puppy bash 3.0.x
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5089
Location: Arizona, U.S.A.

PostPosted: Mon 02 Sep 2013, 22:15    Post subject:  

Karl; Explain why it might not work. Because of using # ?

Hi L18L

some1; You and technosaurus, the awk kings...

# Yeah, I was a bit surprised that sed didn`t like the escaped characters.
But that`s also my experience, inconsistent results from commands.
Back to top
View user's profile Send private message 
seaside

Joined: 11 Apr 2007
Posts: 937

PostPosted: Tue 03 Sep 2013, 18:59    Post subject:  

Some "bashing" also...(on behalf of technosaurus)

Code:
 line=`grep backdrop /root/Choices/ROX-Filer/PuppyPin`
 remove_end=${line/<\/backdrop>/}  filename=${remove_end##*>}


Probably faster than Awk but not enough to really matter.

Cheers,
s
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5089
Location: Arizona, U.S.A.

PostPosted: Tue 03 Sep 2013, 21:41    Post subject:  

seaside; Yes, I thought of that also, but it doesn`t seem to be much quicker.
I always use pure Bash when possible.

And... I don`t know why I didn`t think of this "sed all in one":
Code:
time sed '/backdrop/!d;s#</.*$##;s#^.*>##' $a

First section: "/backdrop/!d" does "grep". This does "grep -v": "sed '/backdrop/d'"
# It`s almost twice as fast as most other methods as it only calls sed once.
.
Back to top
View user's profile Send private message 
some1

Joined: 17 Jan 2013
Posts: 123

PostPosted: Wed 04 Sep 2013, 07:08    Post subject:  

Nitpicking:
Parsing for "backdrop" may not be quite prudent:
False positive:
1.NO wallpaper set -> NO wallpaper-backdrop-directive
2.a non-directive "backdrop"-string elsewhere in PuppyPin -as part of path.iconname,wjatever

Ok -in this - lets give grep the upperhand on awk:

Code:
grep -m1 '<backdrop' /root/Choices/ROX-Filer/PuppyPin



---
Apropos awk:
The nice script provided by Stu91 contains a way of
awk-fieldseperatorspecfication,which may be somewhat handy
in handling escape characters:

I tend to do something like this,trying to rember characters which need to be escaped.
Code:
 awk -F[\<\>]

a la Stu91:
Code:
 awk -F"[<,>]"

--a method which will handle most characters as field-seperators
without the need of considering escaping.
However an escape is needed in this:
Code:
awk -F"[<,>,\"]"

----
@seaside:Yeah - bashstringsops are speady .and very often ought to be used - instead of the usual filetools.in strings-handling.


Edit: Ok - it took half a day for me to correct my sloppy path to PuppyPin
Added:
Being at it,NO grep but read and bashops may very well be a speedier construct:
Code:

     #cnt=1
while read -r line: do
 front=${line%'</backdrop'*}
 [ ${#line} -ne ${#front} ] && found=1 && break
     #cnt=$(($cnt+1)) && [ $cnt -eq 2 ] && break
done</root/Choices/ROX-Filer/PuppyPin
 [ $found -eq 1 ] && echo "${front##*'>'}"


Cheers
Back to top
View user's profile Send private message 
seaside

Joined: 11 Apr 2007
Posts: 937

PostPosted: Wed 04 Sep 2013, 18:57    Post subject:  

Quote:
Being at it,NO grep but read and bashops may very well be a speedier construct:

More no grep no sed-
Code:
 while read line; do
  [ "${line/<backdrop/}"  == "${line}" ] && continue
  remove_end=${line/<\/backdrop>/}  filename=${remove_end##*>}
done </root/Choices/ROX-Filer/PuppyPin 


real 0m0.003s
user 0m0.003s
sys 0m0.000s

Cheers,
s
Back to top
View user's profile Send private message 
technosaurus


Joined: 18 May 2008
Posts: 4878
Location: Blue Springs, MO

PostPosted: Wed 04 Sep 2013, 23:45    Post subject:  

seaside wrote:
... bashops may very well be a speedier construct:
I am not on Puppy right now, but this may work (not 100% on the syntax)
Code:
BG=`cat /path/to/PuppyPin`          #because $(< /path/to/file) is a bashism
BG=${BG#*<backdrop*>}           #remove everything up to the bg file
BG=${BG%</backdrop*}             #remove everything after the bg file
Note: I use /path/to instead of $HOME/Choices/... or even worse /root/... because Puppy uses deprecated paths ... we should really have it in $HOME/.config/<rox dir>/default (where <rox dir> is the name of the rox dir that I cannot recall)... also note that Iguleder's fork of rox removes CHOICESPATH and many other superfluous things that Puppy doesn't need/use.
_________________
Check out my github repositories. I may eventually get around to updating my blogspot.
Back to top
View user's profile Send private message Visit poster's website 
sunburnt


Joined: 08 Jun 2005
Posts: 5089
Location: Arizona, U.S.A.

PostPosted: Thu 05 Sep 2013, 02:31    Post subject:  

technosarus;
Code:
# time (BG=`cat /root/Choices/ROX-Filer/PuppyPin`;BG=${BG#*<backdrop*>};echo ${BG%</backdrop*} )
/mnt/sda3/docs/pics/EndlessBlue_1680.jpg

real   0m0.006s
user   0m0.003s
sys   0m0.000s
#

Averages about the same time as my sed one-liner.
I know it`s not the direct path, but this keeps the time results consistent.

seaside; Couldn`t get yours to echo the /path/image
But yours is twice as fast as technosaurus`s and mine. Odd that looping could be faster, but here you are...
This works for me:
Code:
time while read line; do [ "${line/<backdrop/}" == "${line}" ]&& continue; remove_end=${line%</*}; echo ${remove_end#>}; done </root/Choices/ROX-Filer/PuppyPin
Back to top
View user's profile Send private message 
Karl Godt


Joined: 20 Jun 2010
Posts: 4208
Location: Kiel,Germany

PostPosted: Thu 05 Sep 2013, 07:46    Post subject: grep and busybox grep  

Code:
time grep backdrop /root/Choices/ROX-Filer/PuppyPin | grep -o '>.*<'
>/usr/share/backgrounds/957C57D8B51B39C40F32FD0D0534A_h498_w598_m2.jpg<
real 0m0.007s
user 0m0.010s
sys 0m0.003s
Code:
time busybox grep backdrop /root/Choices/ROX-Filer/PuppyPin | busybox grep -o '>.*<'
>/usr/share/backgrounds/957C57D8B51B39C40F32FD0D0534A_h498_w598_m2.jpg<
real 0m0.002s
user 0m0.000s
sys 0m0.000s

Quote:
# time (BG=`cat /root/Choices/ROX-Filer/PuppyPin`;BG=${BG#*<backdrop*>};echo ${BG%</backdrop*} )
seems not to work for me to give time values, just the filename , probably as # time ./script .

Quote:
Karl; Explain why it might not work. Because of using # ?
Yes .
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5089
Location: Arizona, U.S.A.

PostPosted: Thu 05 Sep 2013, 14:12    Post subject:  

Karl; I`ve always thought that grep is probably a simpler utility than sed.
Your 2 greps are about the same speed as my one sed.

Using BusyBox on my Pentium D was slower most of the time, bounced all over, 2ms to 25ms.
But your code without BusyBox was consistently 6ms.

Using ( ) worked for me, if I use $( ) it tries to exec. it of course.
Code:
# bash -version
GNU bash, version 4.2.37(1)-release (i686-pc-linux-gnu)
Back to top
View user's profile Send private message 
Karl Godt


Joined: 20 Jun 2010
Posts: 4208
Location: Kiel,Germany

PostPosted: Thu 05 Sep 2013, 14:50    Post subject:  

I am using this busybox :

busybox extras
https://docs.google.com/file/d/0B7Meqrmt7a3GbTBDVGtFaEhManc/edit?usp=sharing&pli=1
from
http://murga-linux.com/puppy/viewtopic.php?p=709537#709537

(musl busybox)
(ash)

_________________
«Give me GUI or Death» -- I give you [[Xx]term[inal]] [[Cc]on[s][ole]] .
Macpup user since 2010 on full installations.
People who want problems with Puppy boot frugal Razz
Back to top
View user's profile Send private message 
seaside

Joined: 11 Apr 2007
Posts: 937

PostPosted: Thu 05 Sep 2013, 14:59    Post subject:  

Sunburnt, you're right. The only reason this particular looping example comes out quickly is that the target line is near the top. And, if you echo the filename (instead of just setting the variable as I did, the time is just about the same as the other examples)

It's my experience that Awk is usually much better for larger files where many pieces of data need extraction.

Karl, if only there was an option to exclude part of a regexp from the output to rid the angle brackets.
Code:
time busybox grep backdrop /root/Choices/ROX-Filer/PuppyPin | busybox grep -o '>.*<'
>/usr/share/backgrounds/957C57D8B51B39C40F32FD0D0534A_h498_w598_m2.jpg<

Perhaps -

ANCHOR1=regexpr (<backdrop.*>)
ANCHOR2=regexpr (</backdrop>)
Something like
Quote:
grep -o '$ANCHOR1, $ANCHOR2' filename
which would return all between the ANCHORs (but not including the ANCHORs) would be nice.

Regards,
s
Back to top
View user's profile Send private message 
sunburnt


Joined: 08 Jun 2005
Posts: 5089
Location: Arizona, U.S.A.

PostPosted: Thu 05 Sep 2013, 22:52    Post subject:  

Actually what would be nice is the Bashism ${var} being able to have other internal arguments.
Both exec. of commands, and nesting of the Bash statement itself.

Like this, if it worked it`d do the job in question.
Code:
echo ${${$(</root/Choices/ROX-Filer/PuppyPin)%</*}#*>}
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 7 of 7 [104 Posts]   Goto page: Previous 1, 2, 3, 4, 5, 6, 7
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies. View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
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.0966s ][ Queries: 12 (0.0431s) ][ GZIP on ]