1 //===========================================
2 //  Lumina-DE source code
3 //  Copyright (c) 2014-17, Ken Moore
4 //  Available under the 3-clause BSD license
5 //  See the LICENSE file for full details
6 //===========================================
7 //  This is the main interface for any OS-specific system calls
8 //    To port Lumina to a different operating system, just create a file
9 //    called "LuminaOS-<Operating System>.cpp", and use that file in
10 //    the project (libLumina.pro) instead of LuminaOS-FreeBSD.cpp
11 //===========================================
12 #ifndef _LUMINA_LIBRARY_OS_H
13 #define _LUMINA_LIBRARY_OS_H
14 
15 #include <QString>
16 #include <QStringList>
17 #include <QProcess>
18 #include <QDir>
19 #include <QObject>
20 
21 #include "LUtils.h"
22 
23 class LOS{
24 public:
25 	//Return the name of the OS being used
26 	static QString OSName();
27 
28 	//OS-specific prefix(s)
29 	static QString LuminaShare(); //Install dir for Lumina share files
30 	static QString AppPrefix(); //Prefix for applications (/usr/local/ on FreeBSD)
31 	static QString SysPrefix(); //Prefix for system (/usr/ on FreeBSD)
32 
33 	//OS-specific application shortcuts (*.desktop files)
34 	static QString ControlPanelShortcut();
35 	static QString AppStoreShortcut();
36 
37 	//OS-specific RSS feeds
38 	static QStringList RSSFeeds(); //Return Format: QStringList[ <name>::::<url> ];
39 
40 	//Scan for mounted external devices
41 	static QStringList ExternalDevicePaths(); //Returns: QStringList[<type>::::<filesystem>::::<path>]
42 	  //Note: <type> = [USB, HDRIVE, DVD, SDCARD, UNKNOWN]
43 
44 	//Read screen brightness information
45 	static int ScreenBrightness(); //Returns: Screen Brightness as a percentage (0-100, with -1 for errors)
46 	//Set screen brightness
47 	static void setScreenBrightness(int percent);
48 
49 	//Read the current volume
50 	static int audioVolume(); //Returns: audio volume as a percentage (0-100, with -1 for errors)
51 	//Set the current volume
52 	static void setAudioVolume(int percent);
53 	//Modify the current volume by a set amount (+ or -)
54 	static void changeAudioVolume(int percentdiff);
55 
56 	//Check if a graphical audio mixer is installed
57 	static bool hasMixerUtility();
58 	//Launch the graphical audio mixer utility
59 	static void startMixerUtility();
60 
61 	//Check for user system permission (shutdown/restart)
62 	static bool userHasShutdownAccess();
63 	static bool systemPerformingUpdates();
64 	static QString systemPendingUpdates(); //returns nothing if no updates waiting to install at shutdown
65 
66 	//System Shutdown
67 	static void systemShutdown(bool skipupdates = false); //start poweroff sequence
68 	//System Restart
69 	static void systemRestart(bool skipupdates = false); //start reboot sequence
70 	//Check for suspend support
71 	static bool systemCanSuspend();
72 	//Put the system into the suspend state
73 	static void systemSuspend();
74 
75 
76 	//Battery Availability
77 	static bool hasBattery();
78 	//Battery Charge Level
79 	static int batteryCharge(); //Returns: percent charge (0-100), anything outside that range is counted as an error
80 	//Battery Charging State
81 	static bool batteryIsCharging();
82 	//Battery Time Remaining
83 	static int batterySecondsLeft(); //Returns: estimated number of seconds remaining
84 
85 	//Get the checksum for a file
86 	static QStringList Checksums(QStringList filepaths); //Return: checksum of each input file (same order)
87 
88 	//Get the filesystem capacity
89 	static QString FileSystemCapacity(QString dir) ; //Return: percentage capacity as give by the df command
90 
91 	//System CPU Information
92 	static QStringList CPUTemperatures(); //Returns: List containing the temperature of any CPU's ("50C" for example)
93 	static int CPUUsagePercent(); //Returns: Overall percentage of the amount of CPU cycles in use (-1 for errors)
94 	static int MemoryUsagePercent(); //Returns: Overall percentage of the amount of available memory in use (-1 for errors)
95 	static QStringList DiskUsage(); //Returns: List of current read/write stats for each device
96 };
97 
98 #endif
99