Use sub-process to compute border edges
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 116
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the feature you'd like**
Avoid doing texture reading inside the shell process, while instead use a gjs subprocess to handle this.
**Additional context**
An example of how handling this is something that we had in the past in app-indicators, and still in dash-to-dock for some potentially-blocking things, so see:
https://github.com/micheleg/dash-to-dock/blob/55489eed868dd42474e383b3fc2f47375de44896/locations.js#L350-L381
And the actual script
https://github.com/micheleg/dash-to-dock/blob/master/locationsWorker.js
So you should pass the pixbuf data via stdin to it, make it compute things and return it back...
See also this that we used in app-indicators:
```js
#!/usr/bin/env gjs
const {GLib, Gio} = imports.gi;
const {byteArray: ByteArray} = imports;
const currentPath = GLib.path_get_dirname(new Error().fileName);
imports.searchPath.unshift(currentPath);
const {pixmapsUtils: PixmapsUtils} = imports;
function main(argv) {
if (argv.length < 4) {
const currentBinary = GLib.path_get_basename(new Error().fileName);
printerr(`Usage: ${currentBinary} bus-name path property preferred-size output-fd`);
return 1;
}
const [busName, path, property, preferredSize] = argv;
const cancellable = null;
if (!property.endsWith('Pixmap'))
throw new TypeError(`Invalid property name: ${property}`);
const connection = Gio.bus_get_sync(Gio.BusType.SESSION, cancellable);
const [pixmapsVariant] = connection.call_sync(busName, path,
'org.freedesktop.DBus.Properties', 'Get',
new GLib.Variant('(ss)', ['org.kde.StatusNotifierItem', property]),
null, Gio.DBusCallFlags.NO_AUTO_START, -1, cancellable).unpack();
// Actually use a Gio.UnixInputStream for stdin here to read the data...
const {pixmapVariant, width, height, rowStride} =
PixmapsUtils.getBestPixmap(pixmapsVariant.unpack(), preferredSize);
const iconBytes = PixmapsUtils.argbToRgba(pixmapVariant.deep_unpack());
const stdErrOutputStream = new Gio.UnixOutputStream({fd: 2, closeFd: true});
const controlFields = [iconBytes.length, width, height, rowStride];
stdErrOutputStream.write(controlFields.join(','), cancellable);
const stdOutputStream = new Gio.UnixOutputStream({fd: 1, closeFd: true});
stdOutputStream.write_bytes(iconBytes, cancellable);
```
Contributor guide
Assessment
This issue has not been assessed yet.