source: lumina/lumina-desktop/Globals.h @ f71b232

releng/10.0.2releng/10.0.3
Last change on this file since f71b232 was f71b232, checked in by Ken Moore <ken@…>, 4 months ago

A few updates to lumina-desktop:
1) Add ability to set/use system-wide defaults in /usr/local/share/Lumina-DE/<file>. The current files are, desktopsettings.conf, stylesheet.conf, defaultapps.conf, and desktop-background.jpg.
2) Enable a couple quick Qt options so that the menus and tooltips now appear to "slide in". Just makes it look a bit nicer.
3) Add the ability to load a Qt stylesheet for the session. By default, all this stylesheet does is make sure the tooltips look a bit nicer at the moment.
4) Add the ability to launch applications via the "~/.lumina/startapps" file. Lumina will launch each line in a seperate process as soon as it finishes its own startup routines (be careful to avoid special characters like quotes!!).

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