Is there another way to set wallpaper for the Rox desktop?

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
User avatar
recobayu
Posts: 387
Joined: Wed 15 Sep 2010, 22:48
Location: indonesia

#81 Post by recobayu »

hi all, i want to asking a question. when i use nathan wallpaper setter, i can see my current background in /root/.config/wallpaper/bg_img. but now, i use precise 571 and there is a new pwallpaper setter v1.2. i'm confusing, where is the location of my background's file (because, after choosing a picture and apply that, the file bg_img disappear). anyone know where is the file bg_img or something comfiguration like that?
fyi, i want to change the background in a session by gtkdialog and then when i close that gtkdialog, it's come back to the background before.
thanks.

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#82 Post by sunburnt »

Hi recobayu; Nathan`s very nice Wallpaper app. has been taken out of a lot of the Puppy versions.
pwallpaper is pretty sad isn`t it?

It sounds like you may need to write your own wallpaper setter to do what you want.

musher0
Posts: 14629
Joined: Mon 05 Jan 2009, 00:54
Location: Gatineau (Qc), Canada

#83 Post by musher0 »

sunburnt wrote:Hi recobayu; Nathan`s very nice Wallpaper app. has been taken out of a lot of the Puppy versions.
pwallpaper is pretty sad isn`t it?

It sounds like you may need to write your own wallpaper setter to do what you want.
Well, for the time being, Nathan's wallpaper version 0.6.3 is still available here:
http://distro.ibiblio.org/puppylinux/pe ... -0.6.3.pet
and here:
http://ftp.nluug.nl/os/Linux/distr/pupp ... -0.6.3.pet

Works fine on my wary 5.5, too.

BFN.
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

User avatar
recobayu
Posts: 387
Joined: Wed 15 Sep 2010, 22:48
Location: indonesia

#84 Post by recobayu »

I found it!

Code: Select all

cat /root/Choices/ROX-Filer/PuppyPin | grep backdrop | cut -d '>' -f2 | cut -d '<' -f1
and we get our current wallpaper background. Ok, thanks. :D

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#85 Post by sunburnt »

Or...

Code: Select all

grep backdrop /root/Choices/ROX-Filer/PuppyPin | sed 's#\</.*$##;s#^.*\>##'
The sed command has 2 parts, and it`s best to do the last part of the string first.
Also grep can read a file by itself, so the cat command is unneeded and wastes cpu cycles.

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

faster

#86 Post by L18L »

sunburnt wrote:Or...

Code: Select all

grep backdrop /root/Choices/ROX-Filer/PuppyPin | sed 's#\</.*$##;s#^.*\>##'
Really :roll:

It is faster (only 0.024 seconds instead of 0.046 seconds on my computer)...
... but it is false :wink:

some1
Posts: 117
Joined: Thu 17 Jan 2013, 11:07

#87 Post by some1 »

Hi
I copy,pasted the snippets into a terminal.
The sed-code does not work as expected -
so sunburnt may want to explain,correct...
I do not know much about sed-but generally
act on the rox-files using awk.
But for now - whats wrong in the screenshot/the sed-code?


Cheers

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#88 Post by Karl Godt »

Gnu and Linux are a worse piece of shit, worse than MicrobesWeak ..

Probably replace # by %

:roll:
«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 :P

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#89 Post by sunburnt »

Really odd, I`ve used this code dozens of times, even the end only doesn`t work.

Code: Select all

grep backdrop /root/Choices/ROX-Filer/PuppyPin |sed 's#\</.*$##'
  <backdrop style="Stretched">/mnt/sda3/docs/pics/EndlessBlue_1680.jpg</backdrop>
And I know this should work... Should take the last tag off the line.
Grep is pulling the line, but sed is doing absolutely nothing with it.!

### ODDLY; Escaping the <> is not being accepted by sed.
# This works:

Code: Select all

grep backdrop /root/Choices/ROX-Filer/PuppyPin | sed 's#</.*$##;s#^.*>##'

some1
Posts: 117
Joined: Thu 17 Jan 2013, 11:07

#90 Post by some1 »

--meanwhile
parsing this:
# <backdrop style="Stretched">/usr/share/backgrounds/kandinsky_gugg_0910_24.jpg</backdrop>

Code: Select all

awk -F[\>\<] '/backdrop/{print $3}' /root/Choices/ROX-Filer/PuppyPin
Fieldseparators -literal/escaped:<>
print field 3 -the pathtowallpaper

@L18L may want to time this simple awk-command
By comparative reasoning about the snippets,cpu-cycles?:
: cat,grep,cut,cut
grep,sed
awk
Count the bytecode - in this case awk will be smallest.


ASSUME that we want the contents of the third-last field

Code: Select all

awk -F[\>\<] '/backdrop/{u=NF-2;print $u}' /root/Choices/ROX-Filer/PuppyPin
ASSUME we want BOTH the style and the pathtowallpaper

Code: Select all

read -r style pic <<<$(awk -F[\>\<\"] '/backdrop/{printf "%s\n%s",$3,$5}' /root/Choices/ROX-Filer/PuppyPin)
echo "$style"
echo "$pic"
(Its probably faster/smaller bytecode to do something like ar=($(awk.......)),and echo the wanted array-elements in production-code - instead of calling read)
Note:style-output will be unquoted f.x Stretched
To grab the style WITH quotes try this awk-command:

Code: Select all

awk -F[\>\<\=] '/backdrop/{printf "%s\n%s",$3,$4}' /root/Choices/ROX-Filer/PuppyPin
Note: Using \n in the printf formatting works like a sort of output-delimiter,
allowing us to extract path with spaces and other unwieldy stuff.

Awk can be used in various ways to maul,rewrite,calculate and move things around in the PuppyPin.
----
sorry guys -
life seems to pass me by while I try to post

but thanks for the attention to the sed-issue.

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

Cheers

User avatar
L18L
Posts: 3479
Joined: Sat 19 Jun 2010, 18:56
Location: www.eussenheim.de/

#91 Post by L18L »

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

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#92 Post by Karl Godt »

Code: Select all

sed 's#what#ever#' /path/to/file 
might not work with bash-3.2 . But should work with stock puppy bash 3.0.x

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#93 Post by sunburnt »

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.

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#94 Post by seaside »

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

Code: Select all

 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

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#95 Post by sunburnt »

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: Select all

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

some1
Posts: 117
Joined: Thu 17 Jan 2013, 11:07

#96 Post by some1 »

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: Select all

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: Select all

 awk -F[\<\>]
a la Stu91:

Code: Select all

 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: Select all

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: Select all

     #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

seaside
Posts: 934
Joined: Thu 12 Apr 2007, 00:19

#97 Post by seaside »

Being at it,NO grep but read and bashops may very well be a speedier construct:
More no grep no sed-

Code: Select all

 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

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#98 Post by technosaurus »

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: Select all

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 [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
sunburnt
Posts: 5090
Joined: Wed 08 Jun 2005, 23:11
Location: Arizona, U.S.A.

#99 Post by sunburnt »

technosarus;

Code: Select all

# 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: Select all

time while read line; do [ "${line/<backdrop/}" == "${line}" ]&& continue; remove_end=${line%</*}; echo ${remove_end#>}; done </root/Choices/ROX-Filer/PuppyPin

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

grep and busybox grep

#100 Post by Karl Godt »

Code: Select all

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: Select all

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
# 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 .
Karl; Explain why it might not work. Because of using # ?
Yes .

Post Reply