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

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

Notices

Reply
 
Thread Tools Search this Thread
Old 01-01-2012, 09:26 PM   #1
rkomar
Wizard
rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.
 
Posts: 1,644
Karma: 4122230
Join Date: Oct 2010
Location: Vancouver, BC, Canada
Device: PRS-505, PB 902, PRS-T1, PB 623
sh_ivtool: a simple UI application for use in scripts

I've written a simple little program for popping up dialogs within script files on PocketBook E-Ink devices. You can show messages, get text or numeric input, ask a yes/no question, pop up the directory selector, and even do (clunky) file selection (based on the OpenContents dialog). I've uploaded the binaries and source code to my website: http://www3.telus.net/rkomar/sh_ivtool/. An example shell script that uses it can be seen at: http://www3.telus.net/rkomar/edit-epub/. This should make it easier to use non-trivial scripts in the Applications tab.
rkomar is offline   Reply With Quote
Old 01-02-2012, 03:45 AM   #2
paola
Wizard
paola ought to be getting tired of karma fortunes by now.paola ought to be getting tired of karma fortunes by now.paola ought to be getting tired of karma fortunes by now.paola ought to be getting tired of karma fortunes by now.paola ought to be getting tired of karma fortunes by now.paola ought to be getting tired of karma fortunes by now.paola ought to be getting tired of karma fortunes by now.paola ought to be getting tired of karma fortunes by now.paola ought to be getting tired of karma fortunes by now.paola ought to be getting tired of karma fortunes by now.paola ought to be getting tired of karma fortunes by now.
 
paola's Avatar
 
Posts: 2,734
Karma: 5095193
Join Date: Oct 2010
Location: UK
Device: Pocketbook Pro 903, (beloved Pocketbook 360 RIP), Kobo Mini, Kobo Aura
great, thanks!
paola is offline   Reply With Quote
Old 01-02-2012, 04:34 AM   #3
rkomar
Wizard
rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.
 
Posts: 1,644
Karma: 4122230
Join Date: Oct 2010
Location: Vancouver, BC, Canada
Device: PRS-505, PB 902, PRS-T1, PB 623
Crap! I just realized that my source code and documentation for the file selection option were out of step. The unused <message> option was removed from the documentation but not the code. The source code has been updated, and the edit-epub.app, as well.
rkomar is offline   Reply With Quote
Old 01-04-2012, 09:33 AM   #4
bogomil
Member
bogomil can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterbogomil can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterbogomil can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterbogomil can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterbogomil can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterbogomil can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterbogomil can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterbogomil can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterbogomil can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterbogomil can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterbogomil can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameter
 
Posts: 21
Karma: 12650
Join Date: Apr 2011
Device: PB903
Thank you
bogomil is offline   Reply With Quote
Old 01-04-2012, 12:29 PM   #5
J.C.
Addict
J.C. could sell banana peel slippers to a Deveel.J.C. could sell banana peel slippers to a Deveel.J.C. could sell banana peel slippers to a Deveel.J.C. could sell banana peel slippers to a Deveel.J.C. could sell banana peel slippers to a Deveel.J.C. could sell banana peel slippers to a Deveel.J.C. could sell banana peel slippers to a Deveel.J.C. could sell banana peel slippers to a Deveel.J.C. could sell banana peel slippers to a Deveel.J.C. could sell banana peel slippers to a Deveel.J.C. could sell banana peel slippers to a Deveel.
 
Posts: 215
Karma: 3184
Join Date: Feb 2011
Device: PB602, Palm TX
Can we choose more than one extension with -f <dir> [ext] ?
.epub;.cbz for example ?
J.C. is offline   Reply With Quote
Old 01-04-2012, 12:53 PM   #6
rkomar
Wizard
rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.
 
Posts: 1,644
Karma: 4122230
Join Date: Oct 2010
Location: Vancouver, BC, Canada
Device: PRS-505, PB 902, PRS-T1, PB 623
Quote:
Originally Posted by J.C. View Post
Can we choose more than one extension with -f <dir> [ext] ?
.epub;.cbz for example ?
No, but it sounds like a good idea and should be pretty straightforward to do. I'll post back later with the results. It will probably be a comma separated list, though, as semi-colons can affect the parsing in Unix shells.
rkomar is offline   Reply With Quote
Old 01-04-2012, 04:49 PM   #7
rkomar
Wizard
rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.
 
Posts: 1,644
Karma: 4122230
Join Date: Oct 2010
Location: Vancouver, BC, Canada
Device: PRS-505, PB 902, PRS-T1, PB 623
Okay, I've uploaded a new version of sh_ivtool to the website linked in the first post. You can add multiple extensions now. By default, the names are separated by commas and/or spaces, but you can specify your own separators using the SHIVFS environmental variable. See the README.txt file for an example of that.

Last edited by rkomar; 01-04-2012 at 09:23 PM.
rkomar is offline   Reply With Quote
Old 01-05-2012, 01:30 AM   #8
bogomil
Member
bogomil can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterbogomil can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterbogomil can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterbogomil can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterbogomil can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterbogomil can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterbogomil can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterbogomil can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterbogomil can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterbogomil can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameterbogomil can solve quadratic equations while standing on his or her head reciting poetry in iambic pentameter
 
Posts: 21
Karma: 12650
Join Date: Apr 2011
Device: PB903
It will be very handy if in -f <dir> [ext]:
- the directory (optionally) can be selected interactively with OpenDirectorySelector;
- introduce an additional option - traversing subdirectories or not;
- introduce an option for filtering the filenames;
Thanks for the nice toolset
bogomil is offline   Reply With Quote
Old 01-05-2012, 02:29 AM   #9
rkomar
Wizard
rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.
 
Posts: 1,644
Karma: 4122230
Join Date: Oct 2010
Location: Vancouver, BC, Canada
Device: PRS-505, PB 902, PRS-T1, PB 623
Quote:
Originally Posted by bogomil View Post
It will be very handy if in -f <dir> [ext]:
- the directory (optionally) can be selected interactively with OpenDirectorySelector;
- introduce an additional option - traversing subdirectories or not;
- introduce an option for filtering the filenames;
Thanks for the nice toolset
As far as the first point goes, I think you can just run the OpenDirectorySelector first with a proper message for the user, and then use the output from that with the "-f" option next. At this point, merging them would add a fair bit of complication (can't just CloseApp() after the dir is picked, have to handle an optional message to the user for directory selection, have to know how to handle the user bailing out of the directory selection,...), and complication == bugs when I'm writing the code.

The other two points would be useful and can't be worked around as above, so I agree that they should go in. I think the whole "-f" option argument structure will have to be reworked for that.

Thanks for the helpful input.
rkomar is offline   Reply With Quote
Old 01-05-2012, 07:56 AM   #10
J.C.
Addict
J.C. could sell banana peel slippers to a Deveel.J.C. could sell banana peel slippers to a Deveel.J.C. could sell banana peel slippers to a Deveel.J.C. could sell banana peel slippers to a Deveel.J.C. could sell banana peel slippers to a Deveel.J.C. could sell banana peel slippers to a Deveel.J.C. could sell banana peel slippers to a Deveel.J.C. could sell banana peel slippers to a Deveel.J.C. could sell banana peel slippers to a Deveel.J.C. could sell banana peel slippers to a Deveel.J.C. could sell banana peel slippers to a Deveel.
 
Posts: 215
Karma: 3184
Join Date: Feb 2011
Device: PB602, Palm TX
Had to go to the source code to see the -d option, so it's missing from the readme.

I've run into a problem:
Code:
#!/bin/sh
SH_IVTOOL=/mnt/ext1/system/bin/sh_ivtool.app
EXT=".txt .ini .php"

FILE=`$SH_IVTOOL -f "/mnt/ext2/Folder" "$EXT"`
if [ $? -eq 0 ]; then
echo $FILE > /mnt/ext1/applications/MPlayer/test.txt
fi
The file selection pops up properly and sh_ivtool exits with error code 0, but $FILE remains empty.
Tried it first with sh_ivtool popping a message containing $FILE but the result is empty.


Edit: Also I believe it would be more consistent and proper if -q returned its answer rather than relying on stderr , especially since right now the answer would be considered 'no' even if the user aborted.

Edit2: Same thing if i build sh_ivtool for the emulator, the selected file shows on the terminal screen (with some errors) but if you try and redirect or capture the result (stdout or stderr) either by redirection or into a variable it evaporates.

Edit3: Examples of those errors:
-d
Code:
./sh_ivtool -d "Choose one"
** Message: Command 501 selected

./system/mnt/ext1
hw_close

(<unknown>:17654): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed

(<unknown>:17654): Gtk-WARNING **: A floating object was finalized. This means that someone
called g_object_unref() on an object that had only a floating
reference; the initial floating reference is not owned by anyone
and must be removed with g_object_ref_sink().
Code:
./sh_ivtool -d "Choose one" > test.txt
** Message: Command 501 selected

hw_close

(<unknown>:17655): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed

(<unknown>:17655): Gtk-WARNING **: A floating object was finalized. This means that someone
called g_object_unref() on an object that had only a floating
reference; the initial floating reference is not owned by anyone
and must be removed with g_object_ref_sink().

-f

Code:
./sh_ivtool -f "/home/main/" ".m3u"
** Message: Command 501 selected

/home/main/0.m3u
hw_close

(<unknown>:17660): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed

(<unknown>:17660): Gtk-WARNING **: A floating object was finalized. This means that someone
called g_object_unref() on an object that had only a floating
reference; the initial floating reference is not owned by anyone
and must be removed with g_object_ref_sink().
Code:
./sh_ivtool -f "/home/main/" ".m3u" > test.txt
** Message: Command 501 selected

hw_close

(<unknown>:17673): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed

(<unknown>:17673): Gtk-WARNING **: A floating object was finalized. This means that someone
called g_object_unref() on an object that had only a floating
reference; the initial floating reference is not owned by anyone
and must be removed with g_object_ref_sink().

Last edited by J.C.; 01-05-2012 at 12:30 PM.
J.C. is offline   Reply With Quote
Old 01-05-2012, 10:20 AM   #11
paola
Wizard
paola ought to be getting tired of karma fortunes by now.paola ought to be getting tired of karma fortunes by now.paola ought to be getting tired of karma fortunes by now.paola ought to be getting tired of karma fortunes by now.paola ought to be getting tired of karma fortunes by now.paola ought to be getting tired of karma fortunes by now.paola ought to be getting tired of karma fortunes by now.paola ought to be getting tired of karma fortunes by now.paola ought to be getting tired of karma fortunes by now.paola ought to be getting tired of karma fortunes by now.paola ought to be getting tired of karma fortunes by now.
 
paola's Avatar
 
Posts: 2,734
Karma: 5095193
Join Date: Oct 2010
Location: UK
Device: Pocketbook Pro 903, (beloved Pocketbook 360 RIP), Kobo Mini, Kobo Aura
Quote:
Originally Posted by rkomar View Post
I've written a simple little program for popping up dialogs within script files on PocketBook E-Ink devices. You can show messages, get text or numeric input, ask a yes/no question, pop up the directory selector, and even do (clunky) file selection (based on the OpenContents dialog). I've uploaded the binaries and source code to my website: http://www3.telus.net/rkomar/sh_ivtool/. An example shell script that uses it can be seen at: http://www3.telus.net/rkomar/edit-epub/. This should make it easier to use non-trivial scripts in the Applications tab.
I cannot get the epub-edit.app to run (with the "open with" command): on the 360 I get a "cannot start program", whereas on the 903 I get the hourglass for a second or less, then nothing happens. I am pretty sure I have followed your instructions to the letter (copied zip, unzip, edit-epub.app and sh_ivtool.app to the system/bin directory, and pi.app to the applications directory, edited the config file appropriately, using the "arm-linux" versions of your apps for the 360 and the "arm-none-linux-gnueabi" for the pro).

Any suggestions on what I might be doing wrong? I did download sh_ivtool and edit-epub after your first correction (though not last night versions). On the pro I have the 2.1.2 firmware, on the 360 I think it is 15.3 (more than a year old). Thanks!
paola is offline   Reply With Quote
Old 01-05-2012, 12:00 PM   #12
J.C.
Addict
J.C. could sell banana peel slippers to a Deveel.J.C. could sell banana peel slippers to a Deveel.J.C. could sell banana peel slippers to a Deveel.J.C. could sell banana peel slippers to a Deveel.J.C. could sell banana peel slippers to a Deveel.J.C. could sell banana peel slippers to a Deveel.J.C. could sell banana peel slippers to a Deveel.J.C. could sell banana peel slippers to a Deveel.J.C. could sell banana peel slippers to a Deveel.J.C. could sell banana peel slippers to a Deveel.J.C. could sell banana peel slippers to a Deveel.
 
Posts: 215
Karma: 3184
Join Date: Feb 2011
Device: PB602, Palm TX
Quote:
Originally Posted by paola View Post
I cannot get the epub-edit.app to run (with the "open with" command): on the 360 I get a "cannot start program", whereas on the 903 I get the hourglass for a second or less, then nothing happens. I am pretty sure I have followed your instructions to the letter (copied zip, unzip, edit-epub.app and sh_ivtool.app to the system/bin directory, and pi.app to the applications directory, edited the config file appropriately, using the "arm-linux" versions of your apps for the 360 and the "arm-none-linux-gnueabi" for the pro).

Any suggestions on what I might be doing wrong? I did download sh_ivtool and edit-epub after your first correction (though not last night versions). On the pro I have the 2.1.2 firmware, on the 360 I think it is 15.3 (more than a year old). Thanks!
I've run into "cannot start program" once, turns out I saved the script in dos format instead of unix by mistake.

Last edited by J.C.; 01-05-2012 at 12:00 PM. Reason: typo
J.C. is offline   Reply With Quote
Old 01-05-2012, 03:21 PM   #13
rkomar
Wizard
rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.
 
Posts: 1,644
Karma: 4122230
Join Date: Oct 2010
Location: Vancouver, BC, Canada
Device: PRS-505, PB 902, PRS-T1, PB 623
Quote:
Originally Posted by J.C. View Post
Had to go to the source code to see the -d option, so it's missing from the readme.
Ah, that would explain bogomil's first request. Thanks for pointing that out.

(I'll get to your other points in a later post.)
rkomar is offline   Reply With Quote
Old 01-05-2012, 03:22 PM   #14
rkomar
Wizard
rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.
 
Posts: 1,644
Karma: 4122230
Join Date: Oct 2010
Location: Vancouver, BC, Canada
Device: PRS-505, PB 902, PRS-T1, PB 623
Quote:
Originally Posted by J.C. View Post
I've run into "cannot start program" once, turns out I saved the script in dos format instead of unix by mistake.
Would it help if I zipped the script, or would unzip on Windows put the carriage returns in anyway?
rkomar is offline   Reply With Quote
Old 01-05-2012, 04:35 PM   #15
rkomar
Wizard
rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.rkomar ought to be getting tired of karma fortunes by now.
 
Posts: 1,644
Karma: 4122230
Join Date: Oct 2010
Location: Vancouver, BC, Canada
Device: PRS-505, PB 902, PRS-T1, PB 623
@J.C.
It never occurred to me try this under the emulator (I have to build on a separate machine for that), so this is the first I've seen of these problems.

Something very strange is going on in the emulated program. Using strace, I can see the output being written to stdout if it isn't redirected. If it is redirected (with '>' or e.g. 'FILE=``'), then strace shows that the write never takes place to any file descriptor. The emulator code just swallows it. It looks like I can get around it by dup'ing stdout and writing to that descriptor instead. Sigh! Such a short program, and it's already kludgy! I'll post here when the changes are uploaded.
rkomar 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
Trio of Picture Books - Simple Animals, Simple Shapes, and You're My Baby! Manley Peterson Self-Promotions by Authors and Publishers 5 01-06-2012 08:55 PM
Application update: application not installed error Merischino Kindle Fire 4 12-01-2011 10:30 PM
erm, simple question , hope for simple answer! al zymers Amazon Kindle 5 09-25-2010 01:01 PM
Simple question for a simple mind :) PKFFW OpenInkpot 6 08-27-2009 09:00 PM
Television scripts for your handheld Bob Russell Lounge 2 01-07-2006 06:22 PM


All times are GMT -4. The time now is 03:28 PM.


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