Toshaan Bharvani
11 months ago
commit
861c792dd4
2 changed files with 226 additions and 0 deletions
@ -0,0 +1,164 @@
@@ -0,0 +1,164 @@
|
||||
From ac94b6621c2dfa70329fbc89c77ad7a5042f1d5a Mon Sep 17 00:00:00 2001 |
||||
From: Neal Gompa <neal@gompa.dev> |
||||
Date: Sun, 10 Dec 2023 18:03:30 -0500 |
||||
Subject: [PATCH] wlheadless: Add support for kwin |
||||
|
||||
--- |
||||
README.md | 5 ++- |
||||
man/wlheadless-run.man | 2 +- |
||||
meson_options.txt | 2 +- |
||||
src/wlheadless/kwin.py | 76 ++++++++++++++++++++++++++++++++++++++ |
||||
src/wlheadless/meson.build | 1 + |
||||
5 files changed, 82 insertions(+), 4 deletions(-) |
||||
create mode 100644 src/wlheadless/kwin.py |
||||
|
||||
diff --git a/README.md b/README.md |
||||
index f4d4490..d37243e 100644 |
||||
--- a/README.md |
||||
+++ b/README.md |
||||
@@ -26,6 +26,7 @@ and currently support the following compositors: |
||||
|
||||
* [weston](https://gitlab.freedesktop.org/wayland/weston) |
||||
* [cage](https://github.com/cage-kiosk/cage) |
||||
+ * [kwin](https://invent.kde.org/plasma/kwin) |
||||
* [gnome-kiosk](https://gitlab.gnome.org/GNOME/gnome-kiosk) |
||||
* [mutter](https://gitlab.gnome.org/GNOME/mutter) |
||||
|
||||
@@ -81,7 +82,7 @@ usage: wlheadless-run [-c compositor] <compositor arguments> -- client <client a |
||||
``` |
||||
|
||||
The compositor must be supported by `wlheadless-run`, which currently includes |
||||
-the following compositors: `weston`, `cage`, `mutter`, `gnome-kiosk`. |
||||
+the following compositors: `weston`, `cage`, `kwin`, `mutter`, `gnome-kiosk`. |
||||
|
||||
The given compositor arguments must be supported by the specified Wayland compositor |
||||
and will be added to the command line when starting the compositor. That allows for |
||||
@@ -147,7 +148,7 @@ options: |
||||
``` |
||||
|
||||
The compositor must be supported by `xwfb-run`, which currently includes the |
||||
-following compositors: `weston`, `cage`, `mutter`, `gnome-kiosk`. |
||||
+following compositors: `weston`, `cage`, `kwin`, `mutter`, `gnome-kiosk`. |
||||
|
||||
Optional arguments passed to the Xserver (using the `-s` or `--server-args` option) |
||||
must be escaped twice to prevent `xwfb-run` from trying to parse them, e.g. `-s \\-ac` |
||||
diff --git a/man/wlheadless-run.man b/man/wlheadless-run.man |
||||
index f1f5d3a..6c52db2 100644 |
||||
--- a/man/wlheadless-run.man |
||||
+++ b/man/wlheadless-run.man |
||||
@@ -32,7 +32,7 @@ running headless. |
||||
.TP 8 |
||||
.B \-c COMPOSITOR |
||||
Use the compositor class implementation. Currently supported compositor |
||||
-classes are \fIweston\fP, \fImutter\fP, \fIgnome-kiosk\fP, \fIcage\fP. |
||||
+classes are \fIweston\fP, \fIkwin\fP, \fImutter\fP, \fIgnome-kiosk\fP, \fIcage\fP. |
||||
.SH FILES |
||||
.TP 8 |
||||
.I wlheadless.conf |
||||
diff --git a/meson_options.txt b/meson_options.txt |
||||
index 97367ba..535da87 100644 |
||||
--- a/meson_options.txt |
||||
+++ b/meson_options.txt |
||||
@@ -1,4 +1,4 @@ |
||||
option('compositor', |
||||
type: 'combo', |
||||
- choices: ['cage', 'gnome-kiosk', 'mutter', 'weston'], |
||||
+ choices: ['cage', 'gnome-kiosk', 'kwin', 'mutter', 'weston'], |
||||
value: 'weston') |
||||
diff --git a/src/wlheadless/kwin.py b/src/wlheadless/kwin.py |
||||
new file mode 100644 |
||||
index 0000000..e529229 |
||||
--- /dev/null |
||||
+++ b/src/wlheadless/kwin.py |
||||
@@ -0,0 +1,76 @@ |
||||
+# |
||||
+# Copyright © 2023 Neal Gompa. |
||||
+# |
||||
+# This program is free software; you can redistribute it and/or |
||||
+# modify it under the terms of the GNU General Public License as |
||||
+# published by the Free Software Foundation; either version 2 of the |
||||
+# License, or (at your option) any later version. |
||||
+# |
||||
+# This program is distributed in the hope that it will be useful, but |
||||
+# WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
||||
+# General Public License for more details. |
||||
+# |
||||
+# You should have received a copy of the GNU General Public License |
||||
+# along with this program; if not, write to the Free Software |
||||
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
||||
+# 02111-1307, USA. |
||||
+# |
||||
+ |
||||
+""" Abstraction for running a Wayland client on kwin headless. """ |
||||
+ |
||||
+from os import environ, getpid |
||||
+from wlheadless.wlheadless_common import WlheadlessCommon |
||||
+from wlheadless.xwayland import Xwayland |
||||
+ |
||||
+class Wlheadless: |
||||
+ |
||||
+ """ |
||||
+ Abstraction for running a Wayland client on kwin headless. |
||||
+ """ |
||||
+ |
||||
+ def __call__(self): |
||||
+ return self |
||||
+ |
||||
+ |
||||
+ def __init__(self): |
||||
+ self.compositor_args = [] |
||||
+ self.compositor = [ |
||||
+ 'kwin_wayland', |
||||
+ '--virtual', |
||||
+ ] |
||||
+ self.wlheadless_common = WlheadlessCommon() |
||||
+ self.xwayland = Xwayland() |
||||
+ |
||||
+ |
||||
+ def spawn_client(self, command_args): |
||||
+ """Helper function to spawn kwin and the client at once.""" |
||||
+ wayland_display = 'wayland-' + format(getpid()) |
||||
+ environ['WAYLAND_DISPLAY'] = wayland_display |
||||
+ compositor = self.compositor |
||||
+ compositor.extend(self.compositor_args) |
||||
+ compositor.extend(['--wayland-display', format(wayland_display)]) |
||||
+ compositor.extend(['--']) |
||||
+ compositor.extend(command_args) |
||||
+ return self.wlheadless_common.run_command(compositor) |
||||
+ |
||||
+ |
||||
+ def spawn_xwayland(self, xserver_args = []): |
||||
+ """Helper function to spawn kwin and Xwayland at once.""" |
||||
+ compositor = self.compositor |
||||
+ compositor.extend(self.compositor_args) |
||||
+ compositor.extend(['--']) |
||||
+ xserver_args.extend(['-fullscreen']) |
||||
+ return self.xwayland.spawn_xwayland(xserver_args, compositor) |
||||
+ |
||||
+ |
||||
+ def wait_compositor(self): |
||||
+ """Waits for the compositor to start.""" |
||||
+ return 0 |
||||
+ |
||||
+ |
||||
+ def run_compositor(self, compositor_args = []): |
||||
+ """Starts the Wayland compositor.""" |
||||
+ # Just save the given args for when we shall actually spawn the compositor. |
||||
+ self.compositor_args = compositor_args |
||||
+ return 0 |
||||
diff --git a/src/wlheadless/meson.build b/src/wlheadless/meson.build |
||||
index cdf650c..e6fbfce 100644 |
||||
--- a/src/wlheadless/meson.build |
||||
+++ b/src/wlheadless/meson.build |
||||
@@ -2,6 +2,7 @@ python_sources = [ |
||||
'__init__.py', |
||||
'cage.py', |
||||
'gnome-kiosk.py', |
||||
+ 'kwin.py', |
||||
'mutter.py', |
||||
'weston.py', |
||||
'wlheadless_common.py', |
||||
-- |
||||
2.43.0 |
||||
|
@ -0,0 +1,62 @@
@@ -0,0 +1,62 @@
|
||||
Name: xwayland-run |
||||
Version: 0.0.2 |
||||
Release: 2%{?dist} |
||||
Summary: Set of utilities to run headless X/Wayland clients |
||||
|
||||
License: GPL-2.0-or-later |
||||
URL: https://gitlab.freedesktop.org/ofourdan/xwayland-run |
||||
Source0: %{url}/-/archive/%{version}/%{name}-%{version}.tar.gz |
||||
|
||||
# From: https://gitlab.freedesktop.org/ofourdan/xwayland-run/-/merge_requests/4 |
||||
Patch0001: 0001-wlheadless-Add-support-for-kwin.patch |
||||
|
||||
BuildArch: noarch |
||||
|
||||
BuildRequires: meson >= 0.60.0 |
||||
BuildRequires: git-core |
||||
BuildRequires: python3-devel |
||||
Requires: (weston or kwin-wayland or mutter or cage or gnome-kiosk) |
||||
Requires: xorg-x11-server-Xwayland |
||||
|
||||
# Provide names of the other utilities included |
||||
Provides: wlheadless-run = %{version}-%{release} |
||||
Provides: xwfb-run = %{version}-%{release} |
||||
|
||||
%description |
||||
xwayland-run contains a set of small utilities revolving around running |
||||
Xwayland and various Wayland compositor headless. |
||||
|
||||
|
||||
%prep |
||||
%autosetup -S git_am |
||||
|
||||
|
||||
%build |
||||
%meson |
||||
%meson_build |
||||
|
||||
|
||||
%install |
||||
%meson_install |
||||
|
||||
|
||||
%files |
||||
%license COPYING |
||||
%doc README.md |
||||
%{_bindir}/wlheadless-run |
||||
%{_bindir}/xwayland-run |
||||
%{_bindir}/xwfb-run |
||||
%{_datadir}/wlheadless/ |
||||
%{_mandir}/man1/wlheadless-run.1* |
||||
%{_mandir}/man1/xwayland-run.1* |
||||
%{_mandir}/man1/xwfb-run.1* |
||||
%{python3_sitelib}/wlheadless/ |
||||
|
||||
|
||||
%changelog |
||||
* Sun Dec 10 2023 Neal Gompa <ngompa@fedoraproject.org> - 0.0.2-2 |
||||
- Refresh kwin support patch |
||||
- Add provides for other included utilities |
||||
|
||||
* Sun Dec 10 2023 Neal Gompa <ngompa@fedoraproject.org> - 0.0.2-1 |
||||
- Initial package |
Loading…
Reference in new issue