The time now is Mon 20 May 2013, 15:06
All times are UTC - 4 |
| Author |
Message |
rhadon

Joined: 27 Mar 2008 Posts: 1228 Location: Germany
|
Posted: Fri 18 Jan 2013, 05:39 Post subject:
Problems to edit PuppyPin with bash[SOLVED] |
|
Hi
I've written a small script to swich all desktop icons on and off by moving the mouse cursor to the left side of the desktop. For this reason I copied PuppyPin and deleted all icon lines. It works fine as long as I don't change the wallpaper (this is what I do often). So how can I delete all lines starting with "<icon" in PuppyPin with a script? I tried it for several hours but all examples I found doesn't work right for me. I'm not even able to copy PuppyPin line by line correct to PuppyPin.temp, e.g. using
for i in `cat PuppyPin`; do
echo $i >> PuppyPin.temp ;
done
Can anybody help me please?
Rolf
_________________ Ich verwende "frugal", und das ist gut so.
Raspberry Pi without Puppy? No, thanks.
Last edited by rhadon on Sat 19 Jan 2013, 14:35; edited 1 time in total
|
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 570
|
Posted: Fri 18 Jan 2013, 07:03 Post subject:
Re: Problems to edit PuppyPin with bash |
|
| rhadon wrote: | for i in `cat PuppyPin`; do
echo $i >> PuppyPin.temp ;
done |
This one should work properly:
| Code: | | while IFS='' read -r LINE; do echo "$LINE" >> PuppyPin.temp; done < PuppyPin |
(it also preserves code indentation)
As for switching icons, could you describe the method you're using or post some code snippets?
And what exactly happens when the wallpaper is being changed?
Greetings!
_________________ [O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
|
|
Back to top
|
|
 |
rhadon

Joined: 27 Mar 2008 Posts: 1228 Location: Germany
|
Posted: Fri 18 Jan 2013, 08:01 Post subject:
|
|
| SFR wrote: | This one should work properly:
| Code: | | while IFS='' read -r LINE; do echo "$LINE" >> PuppyPin.temp; done < PuppyPin |
| No, it doesn't . I think it has to do with XML, or that space is interpreted as a new line.
Using this snippet I get
| Code: | <?xml
version="1.0"?>
<pinboard>
<backdrop
style="Stretched">/usr/local/wallrefresh/pictures/current.jpg</backdrop>
<icon
x="288"
y="704"
label="sda6"
... |
Although I wanted to post my script later, when it's more bullet proofed, here it is:
A file named icons_yesno in /usr/local/IconsYesNo:
| Code: | #!/bin/sh
[ ! -s /root/Choices/ROX-Filer/ppin_stat ] && echo -e -n 'STAT="original"' > /root/Choices/ROX-Filer/ppin_stat
cp /root/Choices/ROX-Filer/PuppyPin /root/Choices/ROX-Filer/PuppyPin.original
while :;
do
#Get cursor position
MOUSELOC=$(echo $(xdotool getmouselocation))
XEND=$(echo `expr index "$MOUSELOC" y`)
let "C = $XEND - 4"
X=$(echo ${MOUSELOC:2:$C})
if [ $X = 1023 ] ; then # left side of my screen, 1024x768
/usr/local/IconsYesNo/ppin-change
fi
done |
A 2nd file named ppin_change in /usr/local/IconsYesNo:
| Code: | #!/bin/sh
. /root/Choices/ROX-Filer/ppin_stat
if [ $STAT = "original" ] ; then
cp /root/Choices/ROX-Filer/PuppyPin.striped /root/Choices/ROX-Filer/PuppyPin
STAT="striped"
echo -e -n 'STAT="striped"' > /root/Choices/ROX-Filer/ppin_stat
else
cp /root/Choices/ROX-Filer/PuppyPin.original /root/Choices/ROX-Filer/PuppyPin
STAT="original"
echo -e -n 'STAT="original"' > /root/Choices/ROX-Filer/ppin_stat
fi
rox --pinboard=/root/Choices/ROX-Filer/PuppyPin
|
3rd, in /root/Choices/ROX-Filer/ a copy of PuppyPin named PuppyPin.striped, where all lines beginning with <icon are deleted.
I hope, you enjoy it , and thanks for trying to help,
Rolf
_________________ Ich verwende "frugal", und das ist gut so.
Raspberry Pi without Puppy? No, thanks.
|
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 570
|
Posted: Fri 18 Jan 2013, 09:15 Post subject:
|
|
| Quote: | | I think it has to do with XML, or that space is interpreted as a new line. |
That's correct.
Strange why it works fine for me then...
I tried your scripts (I just added 'sleep 1' after line that calls .../ppinchange) and everything seems to work, except the wallpaper is not being preserved after change.
Is this the problem you have mentioned?
BTW, since xdotool is not included in most of Puppies, you can also use getcurpos:
| Code: | | read X Y <<< `getcurpos`; echo $X $Y |
HTH
Greetings!
_________________ [O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
|
|
Back to top
|
|
 |
L18L
Joined: 19 Jun 2010 Posts: 1706 Location: Burghaslach, Germany
|
Posted: Fri 18 Jan 2013, 09:52 Post subject:
Problems to edit PuppyPin with bash |
|
As a fan of stream editor I have been trying making comments with
| Quote: | sed -i '#\<icons #\<!--\<icons #' /root/Choices/Rox-Filer/PuppyPin
sed -i '#</icons>#</icons>--\>-#' $HOME/Choices/Rox-Filer/PuppyPin |
but
| console wrote: | | sed: can't read /root/Choices/Rox-Filer/PuppyPin: Datei oder Verzeichnis nicht gefunden |
Anyway this is working (back up your PuppyPin before )
| Code: | #!/bin/sh
aFILE=$HOME/Choices/ROX-Filer/PuppyPin
mv $aFILE $aFILE.old
while read LINE; do
case $LINE in
\<icon*) LINE="<!--${LINE}-->" # icons commented
esac
echo "$LINE" >> $aFILE
done < $aFILE.old
rox --pinboard=$aFILE # refresh desktop
|
|
|
Back to top
|
|
 |
rhadon

Joined: 27 Mar 2008 Posts: 1228 Location: Germany
|
Posted: Fri 18 Jan 2013, 10:47 Post subject:
|
|
| SFR wrote: | | Strange why it works fine for me then... |
OK, this problem is solved, it was caused by my save file . I don't know why, but using pfix=ram, your code snipped works as expected (also my attempts, I guess). Stupid fault .
| Quote: | | Code: | | read X Y <<< `getcurpos`; echo $X $Y |
|
Will test it later, maybe it's a better solution .
| Quote: | ... except the wallpaper is not being preserved after change.
Is this the problem you have mentioned? | Yes. Because I use a manually striped PuppyPin (with included name of the wallpaper at this time). After changing I get this wrong wallpaper first.
@L18L
Great, your post comes just in time . Will test now...
Thanks,
Rolf
_________________ Ich verwende "frugal", und das ist gut so.
Raspberry Pi without Puppy? No, thanks.
|
|
Back to top
|
|
 |
seaside
Joined: 11 Apr 2007 Posts: 832
|
Posted: Fri 18 Jan 2013, 10:55 Post subject:
|
|
rhadon, This copies my PuppyPin --
| Code: | | while read line;do echo $line >>PuppyPin.temp;done <PuppyPin |
Cheers,
s
(Note: this only works if last line is blank, which it usually is)
EDIT: forgot to add that you can also make it work if there are no blank lines by doing this | Code: | | while read line || [ "$line" ];do echo $line >>PuppyPin.temp;done <PuppyPin |
|
|
Back to top
|
|
 |
rhadon

Joined: 27 Mar 2008 Posts: 1228 Location: Germany
|
Posted: Fri 18 Jan 2013, 18:02 Post subject:
|
|
@L18L
your code snipped works like a charm . And commenting out the icon lines I like more than simlpy deleting them. Thanks very much.
I added it to ppin-change and it works really fine, also if I change the wallpaper. A little bit polishing and a lot of testing under different conditions, and I'll add it to Wallrefresh. If there is interest, I can also build a standalone pet.
@SFR
For me it's OK without sleep1, but I've only an old laptop for testing. Is it too sensitive for you, without the sleep command?
If you like to test the new ppin-change, here it is:
| Code: | #!/bin/sh
. /root/Choices/ROX-Filer/ppin_stat
if [ $STAT = "original" ] ; then
aFILE=$HOME/Choices/ROX-Filer/PuppyPin
mv $aFILE $aFILE.old
while read LINE; do
case $LINE in
\<icon*) LINE="<!--${LINE}-->" # icons commented
esac
echo "$LINE" >> $aFILE
done < $aFILE.old
STAT="striped"
echo -e -n 'STAT="striped"' > /root/Choices/ROX-Filer/ppin_stat
else
cp /root/Choices/ROX-Filer/PuppyPin.old /root/Choices/ROX-Filer/PuppyPin
STAT="original"
echo -e -n 'STAT="original"' > /root/Choices/ROX-Filer/ppin_stat
fi
rox --pinboard=/root/Choices/ROX-Filer/PuppyPin
|
In icons_yesno I only deleted line #4, cp /root/... .
@seaside
This part of the problem was caused by my save file and my ignorance about this possibility , but thanks anyway
Cheers,
Rolf
_________________ Ich verwende "frugal", und das ist gut so.
Raspberry Pi without Puppy? No, thanks.
|
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 570
|
Posted: Sat 19 Jan 2013, 08:32 Post subject:
|
|
Hey Rolf
Now we're talking.
| Quote: | | For me it's OK without sleep1, but I've only an old laptop for testing. Is it too sensitive for you, without the sleep command? |
Yeah, in fact it was a bit too sensitive without sleep...
A couple of other things I have changed for my personal convenience, but maybe you'll find them useful too:
1. 'while...done' loop in yesno script takes a lot of CPU res.
'sleep 0.1' right before 'done' doesn't affect functionality but reduces CPU load significantly.
2. I have also modified yesno to clean the pinborad only if the pointer is in top-left corner, because usually when I'm moving the cursor to access bottom-left menu, I'm doing it too vigorously...and icons vanishes.
3. I don't know why, but replacing/refreshing the pinboard always kills conky (it's general issue, not your script's), so I've added the following line at the end of ppinchange:
| Code: | | [ -x /root/Startup/conky* ] && /root/Startup/conky* |
Thanks for the app - it (along with Der-schutzhund's VarioMenu) reminds me some features from excellent Fences for Win (...crap, they used to have a freeware version too ).
Greetings!
_________________ [O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
|
|
Back to top
|
|
 |
rhadon

Joined: 27 Mar 2008 Posts: 1228 Location: Germany
|
Posted: Sat 19 Jan 2013, 14:32 Post subject:
|
|
Hi SFR,
I really appreciate your ideas and help .
After trying the whole day to integrate the scripts in WallRefresh, I decided to let it separate.
I was aware that it uses 3%-6% CPU with my laptop, but never thought about something like sleep 0.1. Now it's ~1%. Great .
My inspiration came from Ripple, in 2008/2009 the most amazing Puppy (my point of view). It came with built in Compiz Fusion and used it not with a window manager but instead of. With Compiz it was possible to associate events to all sides of the screen and all corners. It shouldn't be a big problem to use more than one side or one corner . Maybe a GUI? We'll see.
I mark this thread as solved, but if you have other ideas or hints ...
Thanks again and cheers,
Rolf
_________________ Ich verwende "frugal", und das ist gut so.
Raspberry Pi without Puppy? No, thanks.
|
|
Back to top
|
|
 |
some1
Joined: 17 Jan 2013 Posts: 7
|
Posted: Sun 24 Feb 2013, 22:39 Post subject:
walk the awk |
|
Hi
| Code: | mypth='/root/Choices/ROX-Filer/PuppyPin'
if [ -f "$mypth"_old ]
then
mv "$mypth"_old "$mypth"
else
cp "$mypth" "$mypth"_old
echo "$(awk '!/<icon/&&!/<\/icon>/{print}' "$mypth"_old)">"$mypth"
fi
rox --pinboard="$mypth"
|
Print lines which have NEITHER <icon NOR </icon>
the exclamationmark "!" is a NEGATION
| Code: | !/<icon/&&!/<\/icon>/
|
Edit: if [ -f "$mypth" ] && [ -f "$mypth"_old ]
replaced by | Code: | | if [ -f "$mypth"_old ] |
-silly me.Hopefully that wont bother you.
Cheers
|
|
Back to top
|
|
 |
|
|
|
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
|