From 4b441ed65293f719e7c0a1ef5ecf1ffddd4edce5 Mon Sep 17 00:00:00 2001 From: iAkii Date: Wed, 28 Aug 2024 17:16:59 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E6=94=AF?= =?UTF-8?q?=E6=8C=81deepin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/src/screen_capturer_linux.dart | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/packages/screen_capturer_linux/lib/src/screen_capturer_linux.dart b/packages/screen_capturer_linux/lib/src/screen_capturer_linux.dart index 0a62f62..74de4ca 100644 --- a/packages/screen_capturer_linux/lib/src/screen_capturer_linux.dart +++ b/packages/screen_capturer_linux/lib/src/screen_capturer_linux.dart @@ -1,3 +1,4 @@ +import 'package:screen_capturer_linux/src/commands/deepin_screen_recorder.dart'; import 'package:screen_capturer_linux/src/commands/gnome_screenshot.dart'; import 'package:screen_capturer_linux/src/commands/spectacle.dart'; import 'package:screen_capturer_platform_interface/screen_capturer_platform_interface.dart'; @@ -26,11 +27,29 @@ class ScreenCapturerLinux extends MethodChannelScreenCapturer { return _isKdeDesktop!; } + bool? _isDeepinDesktop; + + bool get isDeepinDesktop { + if (_isDeepinDesktop == null) { + try { + final result = ShellExecutor.global.execSync('deepin-screen-recorder', ['-v']); + _isDeepinDesktop = result.exitCode == 0; + } catch (_) { + _isDeepinDesktop = false; + } + } + return _isDeepinDesktop!; + } + @override SystemScreenCapturer get systemScreenCapturer { if (isKdeDesktop) { return spectacle; } + + if (isDeepinDesktop) { + return deepinScreenRecorder; + } return gnomeScreenshot; } } From 8806b7104d643b93db8bb1b07d4eece8ebb9d221 Mon Sep 17 00:00:00 2001 From: iAkii Date: Wed, 28 Aug 2024 17:29:04 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat(core):=20=E6=B7=BB=E5=8A=A0deepin?= =?UTF-8?q?=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/commands/deepin_screen_recorder.dart | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 packages/screen_capturer_linux/lib/src/commands/deepin_screen_recorder.dart diff --git a/packages/screen_capturer_linux/lib/src/commands/deepin_screen_recorder.dart b/packages/screen_capturer_linux/lib/src/commands/deepin_screen_recorder.dart new file mode 100644 index 0000000..65a4aab --- /dev/null +++ b/packages/screen_capturer_linux/lib/src/commands/deepin_screen_recorder.dart @@ -0,0 +1,40 @@ +import 'dart:io'; + +import 'package:screen_capturer_platform_interface/screen_capturer_platform_interface.dart'; +import 'package:shell_executor/shell_executor.dart'; + +final Map> _knownCaptureModeArgs = { + CaptureMode.region: [''], + CaptureMode.screen: ['-f'], + CaptureMode.window: ['--dograb'], +}; + +class _Deepin extends Command with SystemScreenCapturer { + @override + String get executable { + return 'deepin-screen-recorder'; + } + + @override + Future install() { + throw UnimplementedError(); + } + + @override + Future capture({ + required CaptureMode mode, + String? imagePath, + bool copyToClipboard = true, + bool silent = true, + }) { + return exec( + [ + ..._knownCaptureModeArgs[mode]!, + ...(imagePath != null ? ['-s', imagePath] : []), + ...(silent ? ['-n'] : []), + ], + ); + } +} + +final deepinScreenRecorder = _Deepin(); From aae8125c7fffa3827b500daa25af89d4f0e35b05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=86=8A=E5=87=AF?= Date: Thu, 29 Aug 2024 18:41:06 +0800 Subject: [PATCH 3/3] fix(core): foramt code --- .../screen_capturer_linux/lib/src/screen_capturer_linux.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/screen_capturer_linux/lib/src/screen_capturer_linux.dart b/packages/screen_capturer_linux/lib/src/screen_capturer_linux.dart index 74de4ca..7f4e808 100644 --- a/packages/screen_capturer_linux/lib/src/screen_capturer_linux.dart +++ b/packages/screen_capturer_linux/lib/src/screen_capturer_linux.dart @@ -32,7 +32,8 @@ class ScreenCapturerLinux extends MethodChannelScreenCapturer { bool get isDeepinDesktop { if (_isDeepinDesktop == null) { try { - final result = ShellExecutor.global.execSync('deepin-screen-recorder', ['-v']); + final result = + ShellExecutor.global.execSync('deepin-screen-recorder', ['-v']); _isDeepinDesktop = result.exitCode == 0; } catch (_) { _isDeepinDesktop = false;