xi-desktop-portals

Simpler specifications for Linux desktop APIs.
git clone https://git.ce9e.org/xi-desktop-portals.git

commit
7735fb5cb73c477e663ef6a43e37cde4e2a62f1c
parent
22560877659566837d0a4ab8e7c2b91bc13ea98d
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2026-03-07 09:46
[OpenURI] reference implementation

Diffstat

A OpenURI/.gitignore 1 +
A OpenURI/Makefile 16 ++++++++++++++++
A OpenURI/PKGBUILD 19 +++++++++++++++++++
A OpenURI/open-uri.c 28 ++++++++++++++++++++++++++++
A OpenURI/systemd/service 7 +++++++
A OpenURI/systemd/socket 9 +++++++++

6 files changed, 80 insertions, 0 deletions


diff --git a/OpenURI/.gitignore b/OpenURI/.gitignore

@@ -0,0 +1 @@
   -1     1 open-uri

diff --git a/OpenURI/Makefile b/OpenURI/Makefile

@@ -0,0 +1,16 @@
   -1     1 PREFIX = /usr
   -1     2 CFLAGS = -std=c99 -Wall -O2 -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 `pkg-config --cflags gio-2.0`
   -1     3 LDFLAGS = -s -Wl,-z,relro `pkg-config --libs gio-2.0`
   -1     4 
   -1     5 all: open-uri
   -1     6 
   -1     7 open-uri: open-uri.c
   -1     8 	gcc $< -o $@ ${CFLAGS} ${LDFLAGS}
   -1     9 
   -1    10 clean:
   -1    11 	rm -f open-uri
   -1    12 
   -1    13 install: all
   -1    14 	install -D -m 755 xiterm ${DESTDIR}${PREFIX}/bin/xi-portal-open-uri
   -1    15 
   -1    16 .PHONY: all clean install

diff --git a/OpenURI/PKGBUILD b/OpenURI/PKGBUILD

@@ -0,0 +1,19 @@
   -1     1 pkgname='xi-portal-open-uri'
   -1     2 pkgdesc='OpenURI portal'
   -1     3 pkgver='0.0.0'
   -1     4 arch=('amd64')
   -1     5 url='https://github.com/xi/xi-portal'
   -1     6 license='MIT'
   -1     7 depends=(
   -1     8 	libglib2.0-0t64
   -1     9 )
   -1    10 makedepends=(
   -1    11 	libgio-2.0-dev
   -1    12 )
   -1    13 
   -1    14 package() {
   -1    15 	make
   -1    16 	install -Dm 755 open-uri "$pkgdir/usr/bin/$pkgname"
   -1    17 	install -Dm 644 systemd/service "$pkgdir/usr/lib/systemd/user/$pkgname@.service"
   -1    18 	install -Dm 644 systemd/socket "$pkgdir/usr/lib/systemd/user/$pkgname.socket"
   -1    19 }

diff --git a/OpenURI/open-uri.c b/OpenURI/open-uri.c

@@ -0,0 +1,28 @@
   -1     1 #include <stdio.h>
   -1     2 #include <sys/socket.h>
   -1     3 #include <gio/gio.h>
   -1     4 
   -1     5 #define MAX_URI_LENGTH 1024
   -1     6 #define SOCK 3
   -1     7 
   -1     8 int main() {
   -1     9     char uri[MAX_URI_LENGTH];
   -1    10 
   -1    11     int n = recv(SOCK, &uri, sizeof(uri) - 1, 0);
   -1    12     if (n < 0) {
   -1    13         perror("recv");
   -1    14         return EXIT_FAILURE;
   -1    15     }
   -1    16     uri[n] = '\0';
   -1    17     g_strchomp(uri);
   -1    18 
   -1    19     GError *error = NULL;
   -1    20     if (!g_app_info_launch_default_for_uri(uri, NULL, &error)) {
   -1    21         send(SOCK, error->message, strlen(error->message), 0);
   -1    22         send(SOCK, "\n", 1, 0);
   -1    23         g_clear_error(&error);
   -1    24         return EXIT_FAILURE;
   -1    25     }
   -1    26 
   -1    27     return EXIT_SUCCESS;
   -1    28 }

diff --git a/OpenURI/systemd/service b/OpenURI/systemd/service

@@ -0,0 +1,7 @@
   -1     1 [Unit]
   -1     2 Description=OpenURI portal
   -1     3 Requires=xi-portal-open-uri.socket
   -1     4 
   -1     5 [Service]
   -1     6 ExecStart=/usr/bin/xi-portal-open-uri
   -1     7 KillMode=process

diff --git a/OpenURI/systemd/socket b/OpenURI/systemd/socket

@@ -0,0 +1,9 @@
   -1     1 [Unit]
   -1     2 Description=OpenURI portal
   -1     3 
   -1     4 [Socket]
   -1     5 ListenStream=%t/xi.portal.OpenURI
   -1     6 Accept=yes
   -1     7 
   -1     8 [Install]
   -1     9 WantedBy=sockets.target