-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Kobo] Support USBMS exports #6552
Conversation
processes... Otherwise, it breaks USBMS.
To prevent any and all issues w/ USBMS down the road...
Better safe than sorry.
(It's fd >= 10 or more, CLOEXEC).
Depends on koreader/koreader-base#1165 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine.
Co-authored-by: Frans de Jonge <[email protected]>
I'm open to a few more eyeballs on the C tool (especially as far as the strings are concerned, I guess), because as @pgaskin has already shown, I'm super great at stupid typos :D. |
Other than that, I'll probably need people with shitty^Wold devices/FW to test it, make sure nothing implodes. (And that the eject events are detected properly everywhere, especially, say, on the old Touch, because there's one USB controller in the list that I haven't seen anywhere. Unplug should be universal, though. But detecting ejects is way more fun :)). Also, KSM people, because if there's an fd on onboard inherited by KSM (or, hell, KSM itself, I don't know how this thing works), it'll go kablooey. (By kablooey I mean that it'll trip the failsafe, which is a shutdown after 90s, which should give people the time to connect to SSH over Wi-Fi, check the syslog, and run lsof to find the culprit, because 99.99% of failures should be something nasty holding an fd to onboard). |
Had a quick look, nothing suspicious - but I'm not that confortable with low-level C. I've been spoiled by crengine lString16 and stuff :)
I'm using KSM (the old 0.7 version, where everything is in /mnt/onboard - the newer 0.9 version has the essential stuff copied in the system partition, just so to allow it - and so you - to do that umount and export of /mnt/onboard via USB :). Here's what I see from when KOReader is running:
I'd say that for KSM users, this option might not be needed as we're used to quit KOReader to do that from KSM. So, if you can detect KSM is running (or just the old version?), you could just not show that option in the menu/ignore it for gestures. |
I'd much rather trap them in a shutdown so that they realize they really shouldn't be using KSM these days :D. Ooops. :D. |
Okay, with the latest KoboUSBMS version, a busy mountpoint will just restart KOReader, after displaying the offending processes on screen ;). |
USBMS function is working good on Kobo Aura H2O v1 device. Please add all related messages to i18n localisation page! |
We can't, it's currently not i18n aware at all. And it's a separate project, which means it would take time and be... a separate project. Ping @Frenzie to see how that would work? (assuming I do end switching to gettext to handle i18n). |
The easiest for our translators is probably to tweak these lines slightly to include that one specific C file. Also best chance of people actually noticing them etc. Lines 550 to 558 in 6e3a3e8
Alternatively you could transfer the repo to the KOReader organization. Then I could ask them to add it as a new component on Weblate. You could also do all that yourself without transferring anything, but then it'd be a wholly separate you thing which imo would just be a pain because you'd have to manage it all yourself. |
Hmm, I'd also need to siphon the language from the settings and set |
Also, the font only has LGC (if even that) coverage. And we can't co-opt our stock fonts, I need a stock NerdFont one. |
Okay, not happening, locales are even more broken than I already knew on Kobo. libintl won't even try to look for the .mo if the (libc) locale isn't generated. No fr_FR libc locale:
With an en_US libc locale (that's already non-standard, Kobo ships without any):
|
For posterity's sake: diff --git a/Makefile b/Makefile
index f06fb9a..e43b971 100644
--- a/Makefile
+++ b/Makefile
@@ -148,6 +148,7 @@ kobo: armcheck release
ln -sf $(CURDIR)/scripts/fuser-check.sh Kobo/scripts/fuser-check.sh
ln -sf $(CURDIR)/resources/img/koreader.png Kobo/resources/img/koreader.png
ln -sf $(CURDIR)/resources/fonts/CaskaydiaCove_NF.ttf Kobo/resources/fonts/CaskaydiaCove_NF.ttf
+ ln -sf $(CURDIR)/l10n Kobo/l10n
ln -sf $(CURDIR)/$(OUT_DIR)/usbms Kobo/usbms
tar --mtime=@$(USBMS_EPOCH) --owner=root --group=root -cvzhf $(OUT_DIR)/KoboUSBMS.tar.gz -C Kobo .
diff --git a/libevdev b/libevdev
--- a/libevdev
+++ b/libevdev
@@ -1 +1 @@
-Subproject commit 1f54f82f700e847a5d5892ee68e31cb2e007af4e
+Subproject commit 1f54f82f700e847a5d5892ee68e31cb2e007af4e-dirty
diff --git a/usbms.c b/usbms.c
index db26ffb..68b9a5f 100644
--- a/usbms.c
+++ b/usbms.c
@@ -386,6 +386,13 @@ int
goto cleanup;
}
+ // gettext
+ setlocale(LC_ALL, "");
+ char resource_path[PATH_MAX] = { 0 };
+ snprintf(resource_path, sizeof(resource_path) - 1U, "%s/l10n", abs_pwd);
+ fprintf(stderr, "bindtextdomain: %s\n", bindtextdomain("usbms", resource_path));
+ fprintf(stderr, "textdomain: %s\n", textdomain("usbms"));
+
// Setup FBInk
FBInkConfig fbink_cfg = { 0 };
fbink_cfg.row = -5;
@@ -463,14 +470,13 @@ int
FBInkOTConfig ot_cfg = { 0 };
ot_cfg.margins.top = (short int) fbink_state.font_h;
ot_cfg.size_px = (unsigned short int) (fbink_state.font_h * 2U);
- char resource_path[PATH_MAX] = { 0 };
snprintf(resource_path, sizeof(resource_path) - 1U, "%s/resources/fonts/CaskaydiaCove_NF.ttf", abs_pwd);
if (fbink_add_ot_font(resource_path, FNT_REGULAR) != EXIT_SUCCESS) {
PFLOG(LOG_CRIT, "Failed to load TTF font!");
rv = EXIT_FAILURE;
goto cleanup;
}
- fbink_print_ot(fbfd, "USB Mass Storage", &ot_cfg, &fbink_cfg, NULL);
+ fbink_print_ot(fbfd, _("USB Mass Storage"), &ot_cfg, &fbink_cfg, NULL);
fbink_cfg.ignore_alpha = true;
fbink_cfg.halign = CENTER;
fbink_cfg.scaled_height = (short int) (fbink_state.screen_height / 10U);
@@ -517,7 +523,7 @@ int
print_icon(fbfd, "\uf6ff", &fbink_cfg, &icon_cfg);
fbink_print_ot(fbfd,
- "\uf071 Please disable USBNet manually!\nPress the power button to exit.",
+ _("\uf071 Please disable USBNet manually!\nPress the power button to exit."),
&msg_cfg,
&fbink_cfg,
NULL);
diff --git a/usbms.h b/usbms.h
index 92628aa..bc8c324 100644
--- a/usbms.h
+++ b/usbms.h
@@ -39,6 +39,9 @@
#include <syslog.h>
#include <unistd.h>
+#include <locale.h>
+#include <libintl.h>
+
#include "FBInk/fbink.h"
#include "libue/libue.h"
#include <libevdev/libevdev.h>
@@ -55,6 +58,9 @@
// Apparently the libevdev version string isn't available anywhere, so, fake it
#define LIBEVDEV_VERSION "1.9.1"
+// gettext
+#define _(String) gettext(String)
+
// Logging helpers
#define LOG(prio, fmt, ...) ({ syslog(prio, fmt, ##__VA_ARGS__); })
Also, xgettext's comment feature doesn't understand functions broken down across multiple lines. i.e., // @translators
printf(_("foo")); vs. // @translators
printf(
_("foo")); |
What if you wrote (ugly, I know): printf(
// @translators
_("foo")); |
Yep, that works ;). |
That's not really nice :) |
@poire-z: The merged version doesn't shutdown anymore in this instance, it does this: :? (i.e., KOReader restarts when pressing power/after 30s). The popup was a conscious decision, because I find that utterly annoying (i.e., what if I just want to charge, damn it?!), but I agree it's an opinionated decision. The setting still applies for the menu entry, though. I mean, I could add another setting specific to the plug-in event? (It exists in Nickel, albeit as a hidden manual undocumented setting). |
As a proud member of the KSM Preservation Society, I ... don't care :) (changes nothing with seeing the popup where we know we should not hit anything but Cancel).
Did only a short press with this morning nightly - and it did not restart. Went to shutdown after another minute. (dunno what you mean with "the merged version") |
I meant what ended up in the nightly vs. what was in during most of this PR, in case you tried a pre-release build ;). The restart requires startup script changes, which requires a full exit -> start cycle to pickup ;). |
Done (44ee96f) :). |
Thanks :) |
Hi, |
On which KOReader version, on which FW version, what's actually shown on screen, and a crash.log please. |
Well, I have got the last Koreader version (2020.11) on the last FWversion (4.25.15875) |
Well, reading the screen would have been a good start: your device is in USBNet mode ;). Let me guess: you're using KSM 9? |
No, I am not using KSM 9, BUT.... It is true that I did several changes on device for having usb access for WIFI and usb access for cable. I followed the instructions on the page I understand this is the problem, but I don't know how 'disable usb manually'. I think I will have to delete several code lines into ac in usr/local/kobo/udev AND leave only telnet over wifi If you can confirm this, I will change the files and I 'will kill' usbnet for telnet access. ;) Thanks |
Oh god >_<". This kind of thing is a terrible idea to begin with, and, fun fact: FW 4.25 actually updated the inittab, proving the point that modifying it was a terrible idea to begin with. Revert all of that insanity, and invest in something that doesn't mangle the guts of the OS and doesn't require you to jump through an insane amount of hoops (oh, hai!). |
NiLuJe: Oh god >_<". Ha,ha,ha,ha. NiLuJe: This kind of thing is a terrible idea to begin with, and, fun fact: FW 4.25 actually updated the inittab, proving the point that modifying it was a terrible idea to begin with. Of ,yes, yes, I am very cautious. On every FW updated I look into FW for my modified files. I updated my inittab. NiLuJe: Revert all of that insanity, and invest in something that doesn't mangle the guts of the OS and doesn't require you to jump through an insane amount of hoops (oh, hai!). Yes, I know your great job, but this paragraph was terrible for me: "This is basically a collection of all the custom binaries I use throughout my Kindle hacks, My god, I don't understand 90% of the words 8)) |
By doing absolutely nothing besides installing it: It's enabled by default, and will actually persist across FW updates without further interaction. (Same for SSH, because telnet is the worst). |
Ok. I'll do it. I'll 'clean' my device 8)) and I'll install your package. thanks again |
All on our lonesome, for everybody, no custom setups required.
With pretty pictures, Wi-Fi support, ample logging and no lazy unmounts.
Requires a matching PR in base to bundle the tool, which I'll possibly do tonight if my brain doesn't give up before that ;p.
This change is