summaryrefslogtreecommitdiff
path: root/src/sysinfo.cpp
diff options
context:
space:
mode:
authorMatias De lellis <[email protected]>2014-12-14 12:53:38 -0300
committerinfirit <[email protected]>2014-12-15 15:01:56 +0100
commit8aa938cba8881bff0c56091f0e0cbc436dc3e59b (patch)
tree45a606f5d0344cb50218b6b9cb42aaf7a98db752 /src/sysinfo.cpp
parenta86a09d13527ab0af1660f8d31636956a24f1922 (diff)
downloadmate-system-monitor-8aa938cba8881bff0c56091f0e0cbc436dc3e59b.tar.bz2
mate-system-monitor-8aa938cba8881bff0c56091f0e0cbc436dc3e59b.tar.xz
Add support to systemd/freedesktop /etc/os-release to give system info.
Diffstat (limited to 'src/sysinfo.cpp')
-rw-r--r--src/sysinfo.cpp38
1 files changed, 37 insertions, 1 deletions
diff --git a/src/sysinfo.cpp b/src/sysinfo.cpp
index 2cc163d..e60058e 100644
--- a/src/sysinfo.cpp
+++ b/src/sysinfo.cpp
@@ -387,9 +387,45 @@ namespace {
};
+ class GenericSysInfo
+ : public SysInfo
+ {
+ public:
+ GenericSysInfo()
+ {
+ this->load_os_release();
+ }
+
+ private:
+ void load_os_release()
+ {
+ std::ifstream input("/etc/os-release");
+
+ if (input) {
+ while (!input.eof()) {
+ string s;
+ int len;
+ std::getline(input, s);
+ if (s.find("NAME=") == 0) {
+ len = strlen("NAME=");
+ this->distro_name = s.substr(len);
+ } else if (s.find("VERSION=") == 0) {
+ len = strlen("VERSION=");
+ // also strip the surrounding quotes
+ this->distro_release = s.substr(len + 1, s.size() - len - 2);
+ }
+ }
+ }
+ }
+ };
+
+
SysInfo* get_sysinfo()
{
- if (char *p = g_find_program_in_path("lsb_release")) {
+ if (g_file_test ("/etc/os-release", G_FILE_TEST_EXISTS)) {
+ return new GenericSysInfo;
+ }
+ else if (char *p = g_find_program_in_path("lsb_release")) {
g_free(p);
return new LSBSysInfo;
}