1 //=========================================== 2 // Lumina-DE source code 3 // Copyright (c) 2012, Ken Moore 4 // Available under the 3-clause BSD license 5 // See the LICENSE file for full details 6 //=========================================== 7 #ifndef _LUMINA_DESKTOP_GLOBALS_H 8 #define _LUMINA_DESKTOP_GLOBALS_H 9 10 #include <LUtils.h> 11 #include <LuminaXDG.h> 12 #include <LuminaOS.h> 13 #include <LDesktopUtils.h> 14 #include <LFileInfo.h> 15 16 #include <QWidgetAction> 17 #include <QMenu> 18 #include <QString> 19 #include <QIcon> 20 #include <QWidget> 21 #include <QAction> 22 #include <QToolButton> 23 24 #include <unistd.h> 25 #include <stdio.h> 26 27 class Lumina{ 28 public: 29 enum STATES {NONE, VISIBLE, INVISIBLE, ACTIVE, NOTIFICATION, NOSHOW}; 30 31 }; 32 33 class SYSTEM{ 34 public: 35 //Installation location for finding default files 36 //static QString installDir(){ return PREFIX + "/share/Lumina-DE/"; } 37 //Current Username user()38 static QString user(){ return QString::fromLocal8Bit(getlogin()); } 39 //Current Hostname hostname()40 static QString hostname(){ 41 char name[BUFSIZ]; 42 int count = gethostname(name,sizeof(name)); 43 if (count < 0) { 44 return QString(); 45 } 46 return QString::fromLocal8Bit(name,count); 47 } 48 /*//Shutdown the system 49 #ifdef __linux 50 static void shutdown(){ system("(shutdown -h now) &"); } 51 #else // #ifdef __linux 52 static void shutdown(){ system("(shutdown -p now) &"); } 53 #endif // #ifdef __linux 54 //Restart the system 55 static void restart(){ system("(shutdown -r now) &"); } 56 57 //Determine if there is battery support 58 static bool hasBattery(){ 59 int val = LUtils::getCmdOutput("apm -l").join("").toInt(); 60 return (val >= 0 && val <= 100); 61 } 62 63 //Get the current battery charge percentage 64 static int batteryCharge(){ 65 int charge = LUtils::getCmdOutput("apm -l").join("").toInt(); 66 if(charge > 100){ charge = -1; } //invalid charge 67 return charge; 68 } 69 70 //Get the current battery charge percentage 71 static bool batteryIsCharging(){ 72 return (LUtils::getCmdOutput("apm -a").join("").simplified() == "1"); 73 } 74 75 //Get the amount of time remaining for the battery 76 static int batterySecondsLeft(){ 77 return LUtils::getCmdOutput("apm -t").join("").toInt(); 78 }*/ 79 }; 80 81 #endif 82