New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Info page #32
Conversation
|
Awesome! |
One option would be to use import 'dart:ffi';
bool get is32Bit => sizeOf<IntPtr>() == 4;
bool get is64Bit => sizeOf<IntPtr>() == 8; Given that Flutter doesn't officially support 32-bit Linux, however, it's quite unlikely that anyone will ever run the Settings app on a 32-bit system. Technically, it's possible to build Flutter for 32-bit Linux (e.g. |
The import 'package:dbus/dbus.dart';
var client = DBusClient.system();
var object = DBusRemoteObject(client, destination: 'org.freedesktop.hostname1', path: DBusObjectPath('/org/freedesktop/hostname1'));
var hostname = await object.getProperty('org.freedesktop.hostname1', 'Hostname');
print('hostname: ${hostname.toNative()}');
await client.close(); What gnome-control-center does:
|
import 'dart:io';
bool get isX11 => sessionType == 'x11';
bool get isWayland => sessionType == 'wayland';
String? get sessionType => Platform.environment['XDG_SESSION_TYPE']; |
|
- Gpu name - Hostname - OS type - Gnome version - Window server
Here is the current state of the info page: @jpnurmi I integrated as I could all your advice (surly like a big noob 😓). Big thanks for your help :) |
Hi @Jupi007, have you looked at the series of view model PRs from @mivoligo? It would be great to use the pattern here too so we could move the D-Bus stuff etc. out of the widget tree. :)
Let's try to figure out something nicer. That package looks pretty inactive and it's creating a child process to run the
I was playing with this. I can push a service class to help with setting the pretty hostname and sanitizing the static hostname. |
import 'package:filesize/filesize.dart';
import 'package:udisks/udisks.dart';
Future<void> main() async {
final client = UDisksClient();
await client.connect();
final total = client.drives.fold<int>(0, (sum, drive) => sum + drive.size);
print(filesize(total)); // 954 GB
await client.close();
} |
Very nice! 👍 Are the only remaining things GPU info and disk capacity? |
Yes 😃 |
Good idea, then we could fix this issue #59 (a half of the issue) within this PR. I think another page for only the hostname is pretty pointless |
About the terminology, I based my work on the french version where it is written "64 Bits" 😅 Are those the only wrong terms? |
I got it too. It looks related to the |
@Feichtmeier There's something wrong with the master-detail navigation. Whenever you navigate to a page, it's creating 3 instances of that page, and immediately disposes one of them (before the model & service had a chance to even finish initialization). |
@Feichtmeier Did you ever try https://github.com/jpnurmi/flutter_master_detail_example? I don't know if it's perfect either, but it's not trying to do anything "smart" tricks with custom overlay routes at least. |
P.S. We could easily guard HostnameService against this, but it wouldn't fix the problem because then the model will be next in line and explode in its initialization routines... And any other view+model with asynchronous initialization will face the same issue. :( |
Here's an example how we can guard against "too early" disposal: diff --git a/lib/view/pages/info/hostname_service.dart b/lib/view/pages/info/hostname_service.dart
index 4ccb402..1295499 100644
--- a/lib/view/pages/info/hostname_service.dart
+++ b/lib/view/pages/info/hostname_service.dart
@@ -62,8 +62,12 @@ class HostnameService {
_prettyHostname = prettyHostname ?? _prettyHostname;
_staticHostname = staticHostname ?? _staticHostname;
- _hostnameController.add(this.hostname);
- _staticHostnameController.add(this.staticHostname);
+ if (!_hostnameController.isClosed) {
+ _hostnameController.add(this.hostname);
+ }
+ if (!_staticHostnameController.isClosed) {
+ _staticHostnameController.add(this.staticHostname);
+ }
}
Future<void> _initProperties() async {
diff --git a/lib/view/pages/info/info_model.dart b/lib/view/pages/info/info_model.dart
index 1707e01..0f6e90b 100644
--- a/lib/view/pages/info/info_model.dart
+++ b/lib/view/pages/info/info_model.dart
@@ -20,6 +20,7 @@ class InfoModel extends ChangeNotifier {
String _gpuName = '';
int? _diskCapacity;
+ bool _wasDisposed = false;
Future<void> init() async {
await _hostnameService.init();
@@ -32,7 +33,9 @@ class InfoModel extends ChangeNotifier {
_diskCapacity = _uDisksClient.drives.fold<int>(0, (sum, drive) => sum + drive.size);
});
- notifyListeners();
+ if (!_wasDisposed) {
+ notifyListeners();
+ }
}
String get hostname => _hostnameService.hostname;
@@ -57,6 +60,7 @@ class InfoModel extends ChangeNotifier {
@override
void dispose() {
+ _wasDisposed = true;
_hostnameService.dispose();
_uDisksClient.close();
super.dispose(); |
Add |
It seems to be a surprisingly common problem, so I made quickly a package out of it. :P I'll write docs and tests later. |
@Jupi007 Are you not using automatic formatting for Dart code? I get a bit of diff here when touching files. |
Done :)
I don't think I have automatic formatting enabled. Does this require a specific ext? |
Just checked, and it is enabled. |
CTRL + SHIFT + I formats the document just in case the auto format does not work |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
pubspec.yaml
Outdated
@@ -6,7 +6,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev | |||
version: 1.0.0+1 | |||
|
|||
environment: | |||
sdk: ">=2.12.0 <3.0.0" | |||
sdk: ">=2.14.0 <3.0.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
linux_system_info
has>=2.12.0 <3.0.0
: https://github.com/LolzDEV/linux_system_info/blob/master/pubspec.yaml#L7- as said, project-wide language version constraint changes shouldn't be part of an unrelated PR
Shall we merge? |
Ok for me. @jpnurmi ? |
Go for it! 👍 |
Thanks a lot for your help on this @jpnurmi :) |
Work in progress branch for the info page.
gnome-shell
infos ;Closes #24