Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Readers > More E-Book Readers > iRex > iRex Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 07-17-2007, 04:39 PM   #1
Adam B.
Addicted to Porting
Adam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the rough
 
Adam B.'s Avatar
 
Posts: 1,695
Karma: 7194
Join Date: Oct 2006
Location: Indianapolis, IN
Device: iRex iLiad, Nokia 770, Samsung i760
My First SED Script (modifying er_registry)

Soon (hopefully), everyone will be able to reflash their iLiad. This means that shell scripts that modify the internal configuration won't be dangerous. To that effect, adding new viewers to the registry will be useful.

I've started playing with SED in order to add new viewers to the registry. I've tested this on my PC, but I forgot my iLiad at home. It seems to work pretty well. Does anyone have any comments, suggestions, etc, for my scripts? This is literally the first exposure I've had to sed, so it may look a bit ugly.

run.sh
Code:
#!/bin/sh
export scriptdir=`/usr/bin/dirname $0`
cd $scriptdir
cp /mnt/settings/er_registry.txt /mnt/settings/er_registry.txt.orig
sed -i -f update.sed /mnt/settings/er_registry.txt
update.sed
Code:
s\uaIDList=\uaIDList=FBREADER;\g
/uaIDList=/ {
a\
[FBREADER]\
category=viewer\
arguments=<FILENAME>\
exec=/usr/local/programs/FBReader/fbreader.sh\
xResourceName=sh\
channel=14\
extensions=chm;CHM;fb2;FB2;rtf;RTF;tcr;TCR;oeb;OEB
}
/EXTENSION_INFO/ {
a\
chm=/usr/share/contentlister/Icon_books.png\
CHM=/usr/share/contentlister/Icon_books.png\
rtf=/usr/share/contentlister/Icon_books.png\
RTF=/usr/share/contentlister/Icon_books.png\
fb2=/usr/share/contentlister/Icon_books.png\
FB2=/usr/share/contentlister/Icon_books.png\
tcr=/usr/share/contentlister/Icon_books.png\
TCR=/usr/share/contentlister/Icon_books.png\
oeb=/usr/share/contentlister/Icon_books.png\
OEB=/usr/share/contentlister/Icon_books.png
}
Once an update comes that gives everyone unbricking support, I'll release this as a package. Or, if you'd like it to install or to test, and have the developer's version of the unbricking package, send me a PM.
Adam B. is offline   Reply With Quote
Old 07-19-2007, 08:54 AM   #2
Adam B.
Addicted to Porting
Adam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the roughAdam B. is a jewel in the rough
 
Adam B.'s Avatar
 
Posts: 1,695
Karma: 7194
Join Date: Oct 2006
Location: Indianapolis, IN
Device: iRex iLiad, Nokia 770, Samsung i760
So I tried running this script on my iLiad with the busybox sed. It gave me the output: "sed: bad format in substitution expression"

However, I compiled the GNU version of Sed, ran that on the iLiad, and it did the replacement without a problem. I can distribute the gnu sed with the package, but I'd like to know why busybox doesn't like my sed script. Any ideas?
Adam B. is offline   Reply With Quote
 
Advertisement
Old 07-19-2007, 11:18 AM   #3
Antartica
Evangelist
Antartica has learned how to read e-booksAntartica has learned how to read e-booksAntartica has learned how to read e-booksAntartica has learned how to read e-booksAntartica has learned how to read e-booksAntartica has learned how to read e-booksAntartica has learned how to read e-books
 
Antartica's Avatar
 
Posts: 417
Karma: 754
Join Date: Jun 2006
Location: Madrid, Spain
Device: iliad, onhandpc, newton, zaurus
Quote:
Originally Posted by Adam B. View Post
So I tried running this script on my iLiad with the busybox sed. It gave me the output: "sed: bad format in substitution expression"

However, I compiled the GNU version of Sed, ran that on the iLiad, and it did the replacement without a problem. I can distribute the gnu sed with the package, but I'd like to know why busybox doesn't like my sed script. Any ideas?
This one is easy: the separator you're using for the first sed command is not recognized by busybox's sed.

Just put the first command like this:
Code:
s:aIDList=:aIDList=FBREADER;:g
That is, using ':' as separator. For the rest of the readers: you can use any character you wish, usually it's chosen so that it minimises the need to escape characters in the regular expression or the substitution string..

Happy sed'ing

P.S.: I'm a big fan of sed -- it's a really useful command (and usually available, unlike awk or even perl ).
P.S.2: Not bad for your first exposure to sed :-o
Antartica is offline   Reply With Quote
Old 07-19-2007, 11:33 AM   #4
Antartica
Evangelist
Antartica has learned how to read e-booksAntartica has learned how to read e-booksAntartica has learned how to read e-booksAntartica has learned how to read e-booksAntartica has learned how to read e-booksAntartica has learned how to read e-booksAntartica has learned how to read e-books
 
Antartica's Avatar
 
Posts: 417
Karma: 754
Join Date: Jun 2006
Location: Madrid, Spain
Device: iliad, onhandpc, newton, zaurus
Quote:
Originally Posted by Adam B. View Post
I've started playing with SED in order to add new viewers to the registry. I've tested this on my PC, but I forgot my iLiad at home. It seems to work pretty well. Does anyone have any comments, suggestions, etc, for my scripts?
Suggestion: make it idempotent (that is, appliying twice the script have nil effect).

For that the easiest way is to first "unsinstall" the script changes (just in case it has been run before), and only then do the changes.

Examples:

For deleting and then re-adding the uaIDList part:
s/\(uaIDList=.*\)FBREADER;\(.*\)/\1\2/g;s/\(uaIDList=\)/\1FBREADER/g

For deleting the chunk:
/^\[FBREADER\]/,/extensions=chm;CHM;fb2;FB2;rtf;RTF;tcr;TCR;oeb;OEB/d

Last edited by Antartica; 07-19-2007 at 11:35 AM. Reason: Clarification
Antartica is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Modifying column display ccayer Calibre 11 05-11-2010 07:18 AM
iLiad Modifying flipbar behavior DesiLinguist iRex Developer's Corner 28 03-10-2010 03:26 PM
Help modifying LRFTools Demented LRF 0 08-30-2009 03:03 PM
Modifying Headsets iggypop Lounge 0 03-05-2007 06:31 PM
iLiad How to modify /etc/er_registry.txt in style scotty1024 iRex Developer's Corner 5 11-08-2006 08:01 PM


All times are GMT -4. The time now is 04:29 AM.


MobileRead.com is a privately owned, operated and funded community.