Skip to content

Commit 12e6fb4

Browse files
Use xochitl instead of remarkable-shutdown in rm2fb-server (#325)
In the last software relase (2.6), new waveform modes were added to xochitl to make the pinch-to-zoom feature work. Unfortunately, the remarkable-shutdown binary was not updated to support those new waveforms. As a consequence, using pinch-to-zoom with rm2fb results in a less smooth experience than without rm2fb, since the screen gets refreshed less frequently during the gesture. See: * <#322 (comment)> * <ddvk/remarkable2-framebuffer#56> To address this issue, this PR changes the rm2fb-server to preload the `/usr/bin/xochitl` binary instead of `/usr/bin/remarkable-shutdown` in both the `rm2fb-server` command and `rm2fb.service`. This PR also contains a patch to prevent rm2fb-server from appearing as xochitl in process lists. This is done by overwriting `argv[0]` after the library is initialized. This is necessary to prevent remux from mistakenly killing rm2fb-server. A start condition is added to `rm2fb.service` to only start if the librm2fb_server library actually exists on the filesystem. This is to avoid having two concurrent xochitl processes running, as the loader ignores non-existent files provided in LD_PRELOAD. Test plan: * Manually run `rm2fb-server` and `rm2fb-client xochitl`, make use of the pinch-to-zoom gesture, and make sure no message of the form `Unable to complete update: invalid waveform ( 6 )` appears in the server process. * Check that the display continuously updates when using the pinch-to-zoom gesture, even if the `rm2fb.service` service is running and xochitl is started with `rm2fb-client xochitl`. * Remove the `/opt/lib/librm2fb_server.so.1` symlink and restart `rm2fb.service`. The service should not start. Make sure that there’s no duplicate `xochitl` process in this case.
1 parent 18eb01d commit 12e6fb4

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
diff --git a/src/server/main.cpp b/src/server/main.cpp
2+
index 755be17..4186060 100755
3+
--- a/src/server/main.cpp
4+
+++ b/src/server/main.cpp
5+
@@ -173,6 +173,10 @@ int __libc_start_main(int (*_main)(int, char **, char **), int argc,
6+
swtfb::SDK_BIN = argv[0];
7+
fprintf(stderr, "BIN FILE: %s\n", argv[0]);
8+
9+
+ size_t argv0_len = strlen(argv[0]);
10+
+ strncpy(argv[0], "rm2fb-server", argv0_len);
11+
+ argv[0][argv0_len] = 0;
12+
+
13+
return func_main(server_main, argc, argv, init, fini, rtld_fini, stack_end);
14+
};
15+
};

package/rm2fb/package

+8-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ maintainer="raisjn <of.raisjn@gmail.com>"
88
license=MIT
99
pkgdesc="Interface to the reMarkable 2 framebuffer"
1010
url="https://github.com/ddvk/remarkable2-framebuffer"
11-
pkgver=1.0.1-1
11+
pkgver=1.0.1-2
1212
section="devel"
1313

1414
image=qt:v1.1
@@ -18,20 +18,27 @@ source=(
1818
rm2fb.service
1919
rm2fb-server
2020
rm2fb-client
21+
overwrite-server-argv0.patch
2122
)
2223
sha256sums=(
2324
76f1c0b72260a9743f3e008100ffddf1f89cd44c6f0376d906e98ae66eaea716
2425
SKIP
2526
SKIP
2627
SKIP
2728
SKIP
29+
SKIP
2830
)
2931

3032
build() {
3133
qmake
3234
make
3335
}
3436

37+
prepare() {
38+
patch -p1 -d"$srcdir" < "$srcdir"/overwrite-server-argv0.patch
39+
rm "$srcdir"/overwrite-server-argv0.patch
40+
}
41+
3542
package() {
3643
mkdir -p "$pkgdir"/opt/lib "$pkgdir"/opt/etc "$pkgdir"/opt/bin
3744
install -D -m 755 "$srcdir/src/client/librm2fb_client.so.${pkgver%-*}" "$pkgdir"/opt/lib/

package/rm2fb/rm2fb-server

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/usr/bin/env bash
2-
LD_PRELOAD=/opt/lib/librm2fb_server.so.1 exec "$(command -v remarkable-shutdown)"
2+
LD_PRELOAD=/opt/lib/librm2fb_server.so.1 exec "$(command -v xochitl)"

package/rm2fb/rm2fb.service

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ After=opt.mount
88
StartLimitInterval=30
99
StartLimitBurst=5
1010
Conflicts=
11+
ConditionFileNotEmpty=/opt/lib/librm2fb_server.so.1
1112

1213
[Service]
13-
ExecStart=/usr/bin/remarkable-shutdown
14+
ExecStart=/usr/bin/xochitl
1415
Restart=on-failure
1516
RestartSec=5
1617
Environment="HOME=/home/root"

0 commit comments

Comments
 (0)