source: lumina/lumina-desktop/Globals.h @ 9d0ec76

releng/10.0.3
Last change on this file since 9d0ec76 was 9d0ec76, checked in by Ken Moore <ken@…>, 3 months ago

Update lumina-desktop to use the new abilities in LuminaOS instead of the GLobals.h file. Now all the OS-specific stuff is contained in a single location.

  • Property mode set to 100644
File size: 2.0 KB
Line 
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 <LuminaUtils.h>
11
12#include <unistd.h>
13#include <stdio.h>
14
15/*#ifdef __linux
16  // Needed for BUFSIZ
17  #include <stdio.h>
18#endif // #ifdef __linux*/
19
20class Lumina{
21public:
22  enum STATES {NONE, VISIBLE, INVISIBLE, ACTIVE, NOTIFICATION, NOSHOW};
23
24};
25
26class SYSTEM{
27public:
28        //Installation location for finding default files
29        static QString installDir(){ return "/usr/local/share/Lumina-DE/"; }
30        //Current Username
31        static QString user(){ return QString::fromLocal8Bit(getlogin()); }
32        //Current Hostname
33        static QString hostname(){ 
34          char name[BUFSIZ];
35          int count = gethostname(name,sizeof(name));
36          if (count < 0) {
37            return QString::null;
38          }
39          return QString::fromLocal8Bit(name,count);
40        }
41        /*//Shutdown the system
42#ifdef __linux
43        static void shutdown(){ system("(shutdown -h now) &"); }
44#else // #ifdef __linux
45        static void shutdown(){ system("(shutdown -p now) &"); }
46#endif // #ifdef __linux
47        //Restart the system
48        static void restart(){ system("(shutdown -r now) &"); }
49       
50        //Determine if there is battery support
51        static bool hasBattery(){
52          int val = LUtils::getCmdOutput("apm -l").join("").toInt();
53          return (val >= 0 && val <= 100);
54        }
55       
56        //Get the current battery charge percentage
57        static int batteryCharge(){
58          int charge = LUtils::getCmdOutput("apm -l").join("").toInt();
59          if(charge > 100){ charge = -1; } //invalid charge
60          return charge;
61        }
62       
63        //Get the current battery charge percentage
64        static bool batteryIsCharging(){
65          return (LUtils::getCmdOutput("apm -a").join("").simplified() == "1");
66        }
67       
68        //Get the amount of time remaining for the battery
69        static int batterySecondsLeft(){
70          return LUtils::getCmdOutput("apm -t").join("").toInt();
71        }*/
72};
73
74#endif
Note: See TracBrowser for help on using the repository browser.