From b89c20ac4ab5ed65f3fb269a32437535b70e824d Mon Sep 17 00:00:00 2001 From: Robert Ancell Date: Tue, 28 Nov 2023 19:48:52 +1300 Subject: [PATCH] Support screen number in DISPLAY --- lib/src/x11_client.dart | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/src/x11_client.dart b/lib/src/x11_client.dart index 5918943..a5c867c 100644 --- a/lib/src/x11_client.dart +++ b/lib/src/x11_client.dart @@ -262,15 +262,30 @@ class X11Client { String? host; int? displayNumber; + int? screen; var dividerIndex = display.indexOf(':'); if (dividerIndex >= 0) { host = display.substring(0, dividerIndex); var displayNumberString = display.substring(dividerIndex + 1); + + var screenDividerIndex = displayNumberString.indexOf('.'); + if (screenDividerIndex >= 0) { + var screenString = + displayNumberString.substring(screenDividerIndex + 1); + displayNumberString = + displayNumberString.substring(0, screenDividerIndex); + if (RegExp(r'^[0-9]+$').hasMatch(screenString)) { + screen = int.parse(screenString); + } + } else { + screen = 0; + } + if (RegExp(r'^[0-9]+$').hasMatch(displayNumberString)) { displayNumber = int.parse(displayNumberString); } } - if (host == null || displayNumber == null) { + if (host == null || displayNumber == null || screen == null) { throw "Invalid DISPLAY: '$display'"; }