cage: add package
authorDaniel Golle <daniel@makrotopia.org>
Tue, 12 Nov 2024 02:22:31 +0000 (03:22 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Thu, 5 Dec 2024 01:27:37 +0000 (01:27 +0000)
Add Cage which is a Wayland kiosk compositor running a single
application in full-screen.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
frameworks/cage/Makefile [new file with mode: 0644]
frameworks/cage/files/cage.config [new file with mode: 0644]
frameworks/cage/files/cage.init [new file with mode: 0644]

diff --git a/frameworks/cage/Makefile b/frameworks/cage/Makefile
new file mode 100644 (file)
index 0000000..c189378
--- /dev/null
@@ -0,0 +1,49 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=cage
+PKG_VERSION:=0.2.0
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=https://github.com/cage-kiosk/cage/releases/download/v0.2.0
+PKG_HASH:=557c194d18af7202a9ec2e8be6dd7129f6c16d0f4528f4079ba26ccd57b6ef88
+
+PKG_MAINTAINER:=Daniel Golle <daniel@makrotopia.org>
+PKG_LICENSE:=MIT
+PKG_LICENSE_FILES:=LICENSE
+
+PKG_INSTALL:=1
+PKG_BUILD_DEPENDS:=wayland/host
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/meson.mk
+
+define Package/cage
+  SECTION:=video-frameworks
+  CATEGORY:=Video
+  SUBMENU:=Frameworks and Toolkits
+  TITLE:=a Wayland kiosk
+  URL:=https://wayland.freedesktop.org/
+  DEPENDS:=+wlroots +xkeyboard-config
+endef
+
+define Package/cage/description
+This is Cage, a Wayland kiosk. A kiosk runs a single, maximized application.
+endef
+
+MESON_ARGS += \
+       -Dman-pages=disabled
+
+define Package/cage/conffiles
+/etc/config/cage
+endef
+
+define Package/cage/install
+       $(INSTALL_DIR) $(1)/usr/bin
+       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/cage $(1)/usr/bin
+       $(INSTALL_DIR) $(1)/etc/init.d
+       $(INSTALL_BIN) ./files/cage.init $(1)/etc/init.d/cage
+       $(INSTALL_DIR) $(1)/etc/config
+       $(INSTALL_CONF) ./files/cage.config $(1)/etc/config/cage
+endef
+
+$(eval $(call BuildPackage,cage))
diff --git a/frameworks/cage/files/cage.config b/frameworks/cage/files/cage.config
new file mode 100644 (file)
index 0000000..eb8ba30
--- /dev/null
@@ -0,0 +1,8 @@
+config cage
+       option noinput '0'
+       option nogpu '0'
+       option cmd '/usr/bin/cog'
+       option user 'cog'
+       list args '--scale=0.33'
+       list args 'http://localhost'
+       list env 'WEBKIT_INSPECTOR_HTTP_SERVER=0.0.0.0:12341'
diff --git a/frameworks/cage/files/cage.init b/frameworks/cage/files/cage.init
new file mode 100644 (file)
index 0000000..9ba5e69
--- /dev/null
@@ -0,0 +1,46 @@
+#!/bin/sh /etc/rc.common
+START=99
+
+USE_PROCD=1
+
+cage_append_command() {
+       procd_append_param command "$@"
+}
+
+cage_append_env() {
+       procd_append_param env "$@"
+}
+
+cage() {
+       local cfg="$1"
+       local cmd user args noinput nogpu
+       local cagedir="/tmp/run/cage"
+       config_get cmd "$cfg" 'cmd'
+       config_get noinput "$cfg" 'noinput' '0'
+       config_get nogpu "$cfg" 'nogpu' '0'
+       config_get user "$cfg" 'user' 'root'
+
+       mkdir -p -m 0700 "$cagedir"
+       chown ${user}:root "$cagedir"
+
+       procd_open_instance
+       procd_set_param command /usr/bin/cage
+       procd_append_param command "--"
+       procd_append_param command "$cmd"
+       config_list_foreach "$cfg" args cage_append_command
+       procd_set_param file /etc/config/cage
+       procd_set_param respawn
+       procd_set_param env "XDG_RUNTIME_DIR=$cagedir"
+       [ "$noinput" != "0" ] && procd_append_param env "WLR_LIBINPUT_NO_DEVICES=1"
+       [ "$nogpu" != "0" ] && procd_append_param env "WLR_RENDERER_ALLOW_SOFTWARE=1"
+       config_list_foreach "$cfg" env cage_append_env
+       procd_set_param user "$user"
+       procd_set_param stderr 1
+       procd_set_param stdout 1
+       procd_close_instance
+}
+
+start_service() {
+       config_load cage
+       config_foreach cage cage
+}