Problems to edit PuppyPin with bash[SOLVED]
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
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
Last edited by rhadon on Sat 19 Jan 2013, 18:35, edited 1 time in total.
Ich verwende "frugal", und das ist gut so. :wink:
Raspberry Pi without Puppy? No, thanks.
Raspberry Pi without Puppy? No, thanks.
Re: Problems to edit PuppyPin with bash
This one should work properly:rhadon wrote:for i in `cat PuppyPin`; do
echo $i >> PuppyPin.temp ;
done
Code: Select all
while IFS='' read -r LINE; do echo "$LINE" >> PuppyPin.temp; done < PuppyPin
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!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]
[b][color=green]Omnia mea mecum porto.[/color][/b]
No, it doesn't . I think it has to do with XML, or that space is interpreted as a new line.SFR wrote:This one should work properly:Code: Select all
while IFS='' read -r LINE; do echo "$LINE" >> PuppyPin.temp; done < PuppyPin
Using this snippet I get
Code: Select all
<?xml
version="1.0"?>
<pinboard>
<backdrop
style="Stretched">/usr/local/wallrefresh/pictures/current.jpg</backdrop>
<icon
x="288"
y="704"
label="sda6"
...
A file named icons_yesno in /usr/local/IconsYesNo:
Code: Select all
#!/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
Code: Select all
#!/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
I hope, you enjoy it , and thanks for trying to help,
Rolf
Ich verwende "frugal", und das ist gut so. :wink:
Raspberry Pi without Puppy? No, thanks.
Raspberry Pi without Puppy? No, thanks.
That's correct.I think it has to do with XML, or that space is interpreted as a new line.
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: Select all
read X Y <<< `getcurpos`; echo $X $Y
Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]
[b][color=green]Omnia mea mecum porto.[/color][/b]
- L18L
- Posts: 3479
- Joined: Sat 19 Jun 2010, 18:56
- Location: www.eussenheim.de/
Problems to edit PuppyPin with bash
As a fan of stream editor I have been trying making comments with
Anyway this is working (back up your PuppyPin before )
butsed -i '#\<icons #\<!--\<icons #' /root/Choices/Rox-Filer/PuppyPin
sed -i '#</icons>#</icons>--\>-#' $HOME/Choices/Rox-Filer/PuppyPin
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: Select all
#!/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
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 .SFR wrote:Strange why it works fine for me then...
Will test it later, maybe it's a better solution .Code: Select all
read X Y <<< `getcurpos`; echo $X $Y
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.... except the wallpaper is not being preserved after change.
Is this the problem you have mentioned?
@L18L
Great, your post comes just in time . Will test now...
Thanks,
Rolf
Ich verwende "frugal", und das ist gut so. :wink:
Raspberry Pi without Puppy? No, thanks.
Raspberry Pi without Puppy? No, thanks.
rhadon, This copies my 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: Select all
while read line;do echo $line >>PuppyPin.temp;done <PuppyPin
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: Select all
while read line || [ "$line" ];do echo $line >>PuppyPin.temp;done <PuppyPin
@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:
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
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: Select all
#!/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
@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. :wink:
Raspberry Pi without Puppy? No, thanks.
Raspberry Pi without Puppy? No, thanks.
Hey Rolf
Now we're talking.
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:
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!
Now we're talking.
Yeah, in fact it was a bit too sensitive without sleep...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?
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: Select all
[ -x /root/Startup/conky* ] && /root/Startup/conky*
Greetings!
[color=red][size=75][O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource[/size][/color]
[b][color=green]Omnia mea mecum porto.[/color][/b]
[b][color=green]Omnia mea mecum porto.[/color][/b]
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
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. :wink:
Raspberry Pi without Puppy? No, thanks.
Raspberry Pi without Puppy? No, thanks.
walk the awk
Hi
Print lines which have NEITHER <icon NOR </icon>
the exclamationmark "!" is a NEGATION
Edit: if [ -f "$mypth" ] && [ -f "$mypth"_old ]
replaced by
-silly me.Hopefully that wont bother you.
Cheers
Code: Select all
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"
the exclamationmark "!" is a NEGATION
Code: Select all
!/<icon/&&!/<\/icon>/
replaced by
Code: Select all
if [ -f "$mypth"_old ]
-silly me.Hopefully that wont bother you.
Cheers
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
- L18L
- Posts: 3479
- Joined: Sat 19 Jun 2010, 18:56
- Location: www.eussenheim.de/
SwapIcons
I was having fun, too
moved to /usr/local/apps
added 1 parameter and 1 never hidden desktop icon
hope you like it
moved to /usr/local/apps
added 1 parameter and 1 never hidden desktop icon
hope you like it
- Attachments
-
- SwapIcons-1.1.png
- (31.2 KiB) Downloaded 397 times
-
- SwapIcons-1.1.pet
- (2.4 KiB) Downloaded 460 times
Hey, that's the way I like it .
I'm more for 'all or nothing' (icons related) but it's always good to have a choice or more.
I'll try to add another choice (mouse movement + button), hopefully this weekend. Will post it in the thread about SwapIcon.
Never before I used this 'Apps' part. Well, someting more to learn
Thanks L18L,
Rolf
I'm more for 'all or nothing' (icons related) but it's always good to have a choice or more.
I'll try to add another choice (mouse movement + button), hopefully this weekend. Will post it in the thread about SwapIcon.
Never before I used this 'Apps' part. Well, someting more to learn
Thanks L18L,
Rolf
Ich verwende "frugal", und das ist gut so. :wink:
Raspberry Pi without Puppy? No, thanks.
Raspberry Pi without Puppy? No, thanks.