summaryrefslogtreecommitdiff
path: root/platform/x11
diff options
context:
space:
mode:
authorgeequlim <geequlim@gmail.com>2018-01-20 21:42:19 +0800
committerGeequlim <geequlim@gmail.com>2018-01-31 09:40:33 +0800
commitdf1c16d0fe06426dfdea8259878e479b38623d04 (patch)
treec8e83da3906fc7664ece345f6cc7d1d2fd0b0190 /platform/x11
parent3be04f73f567b9c39efae697e2a9b7d3c6185fc3 (diff)
X11: implement OS.get_unique_id
Diffstat (limited to 'platform/x11')
-rw-r--r--platform/x11/os_x11.cpp15
-rw-r--r--platform/x11/os_x11.h2
2 files changed, 17 insertions, 0 deletions
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index eaf72d4dbf..43a7b41f8a 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -549,6 +549,21 @@ void OS_X11::set_ime_position(const Point2 &p_pos) {
XFree(preedit_attr);
}
+String OS_X11::get_unique_id() const {
+
+ static String machine_id;
+ if (machine_id.empty()) {
+ if (FileAccess *f = FileAccess::open("/etc/machine-id", FileAccess::READ)) {
+ while (machine_id.empty() && !f->eof_reached()) {
+ machine_id = f->get_line().strip_edges();
+ }
+ f->close();
+ memdelete(f);
+ }
+ }
+ return machine_id;
+}
+
void OS_X11::finalize() {
if (main_loop)
diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h
index f7bc0b73e0..c80a292002 100644
--- a/platform/x11/os_x11.h
+++ b/platform/x11/os_x11.h
@@ -266,6 +266,8 @@ public:
virtual bool get_borderless_window();
virtual void set_ime_position(const Point2 &p_pos);
+ virtual String get_unique_id() const;
+
virtual void move_window_to_foreground();
virtual void alert(const String &p_alert, const String &p_title = "ALERT!");