Skip to content

Commit

Permalink
Support screen number in DISPLAY
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-ancell committed Nov 28, 2023
1 parent 2bcdbf7 commit b89c20a
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion lib/src/x11_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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'";
}

Expand Down

0 comments on commit b89c20a

Please sign in to comment.