aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libLumina/LuminaOS-NetBSD.cpp168
-rw-r--r--libLumina/libLumina.pro1
2 files changed, 169 insertions, 0 deletions
diff --git a/libLumina/LuminaOS-NetBSD.cpp b/libLumina/LuminaOS-NetBSD.cpp
new file mode 100644
index 00000000..f87d7a2a
--- /dev/null
+++ b/libLumina/LuminaOS-NetBSD.cpp
@@ -0,0 +1,168 @@
+//===========================================
+// Lumina-DE source code
+// Copyright (c) 2014, Ken Moore
+// Available under the 3-clause BSD license
+// See the LICENSE file for full details
+//===========================================
+#ifdef __NetBSD__
+#include "LuminaOS.h"
+#include <unistd.h>
+#include <stdio.h> // Needed for BUFSIZ
+
+QString LOS::OSName(){ return "NetBSD"; }
+
+//OS-specific prefix(s)
+QString LOS::AppPrefix(){ return "/usr/local/"; } //Prefix for applications
+QString LOS::SysPrefix(){ return "/usr/"; } //Prefix for system
+
+//OS-specific application shortcuts (*.desktop files)
+QString LOS::ControlPanelShortcut(){ return ""; } //system control panel
+QString LOS::AppStoreShortcut(){ return ""; } //graphical app/pkg manager
+QString LOS::QtConfigShortcut(){ return ""; } //qtconfig binary (NOT *.desktop file)
+
+// ==== ExternalDevicePaths() ====
+QStringList LOS::ExternalDevicePaths(){
+ //Returns: QStringList[<type>::::<filesystem>::::<path>]
+ //Note: <type> = [USB, HDRIVE, DVD, SDCARD, UNKNOWN]
+
+ //Not implemented yet
+ return QStringList();
+}
+
+//Read screen brightness information
+int LOS::ScreenBrightness(){
+ //Returns: Screen Brightness as a percentage (0-100, with -1 for errors)
+ return -1; //not implemented yet
+}
+
+//Set screen brightness
+void LOS::setScreenBrightness(int percent){
+ //not implemented yet
+}
+
+//Read the current volume
+int LOS::audioVolume(){
+ //Returns: audio volume as a percentage (0-100, with -1 for errors)
+ return -1; //Not implemented yet
+}
+
+//Set the current volume
+void LOS::setAudioVolume(int percent){
+ //not implemented yet
+}
+
+//Change the current volume a set amount (+ or -)
+void LOS::changeAudioVolume(int percentdiff){
+ //not implemented yet
+}
+
+//Check if a graphical audio mixer is installed
+bool LOS::hasMixerUtility(){
+ return false; //not implemented yet
+}
+
+//Launch the graphical audio mixer utility
+void LOS::startMixerUtility(){
+ //not implemented yet
+}
+
+//Check for user system permission (shutdown/restart)
+bool LOS::userHasShutdownAccess(){
+ //User needs to be a part of the operator group to be able to run the shutdown command
+ QStringList groups = LUtils::getCmdOutput("id -Gn").join(" ").split(" ");
+ return groups.contains("operator");
+}
+
+//Check for whether the system is safe to power off (no updates being perfomed)
+bool LOS::systemPerformingUpdates(){
+ return false; //Not implemented yet
+}
+
+//System Shutdown
+void LOS::systemShutdown(){ //start poweroff sequence
+ QProcess::startDetached("shutdown -p now");
+}
+
+//System Restart
+void LOS::systemRestart(){ //start reboot sequence
+ QProcess::startDetached("shutdown -r now");
+}
+
+//Check for suspend support
+bool LOS::systemCanSuspend(){
+ return false;
+}
+
+//Put the system into the suspend state
+void LOS::systemSuspend(){
+
+}
+
+//Battery Availability
+bool LOS::hasBattery(){
+ return false; //not implemented yet
+}
+
+//Battery Charge Level
+int LOS::batteryCharge(){ //Returns: percent charge (0-100), anything outside that range is counted as an error
+ return -1; //not implemented yet
+}
+
+//Battery Charging State
+bool LOS::batteryIsCharging(){
+ return false; //not implemented yet
+}
+
+//Battery Time Remaining
+int LOS::batterySecondsLeft(){ //Returns: estimated number of seconds remaining
+ return 0; //not implemented yet
+}
+
+//File Checksums
+QStringList LOS::Checksums(QStringList filepaths){ //Return: checksum of the input file
+ //on NetBSD md5(1) has the following layout
+ //$ md5 DESCR Makefile
+ //MD5 (DESCR) = 6aaa128cf0466792be6f6d15e4589dfb
+ //MD5 (Makefile) = 4787f3145bba2a3cc393cdd812c5d18b
+
+ QStringList info = LUtils::getCmdOutput("md5 \""+filepaths.join("\" \"")+"\"");
+ for(int i=0; i<info.length(); i++){
+ if( !info[i].contains(" = ") ){ info.removeAt(i); i--; }
+ else{
+ //Strip out the extra information
+ info[i] = info[i].section(" = ",1,1);
+ }
+ }
+ return info;
+}
+
+//file system capacity
+QString LOS::FileSystemCapacity(QString dir) { //Return: percentage capacity as give by the df command
+ // on NetBSD, df has the following layout:
+ // $ df /home
+ // Filesystem 512-blocks Used Avail %Cap Mounted on
+ // /dev/cgd0a 39711132 37140376 585200 98% /home
+
+ QStringList mountInfo = LUtils::getCmdOutput("df \"" + dir+"\"");
+ QString::SectionFlag skipEmpty = QString::SectionSkipEmpty;
+ //we take the 5th word on the 2 line
+ QString capacity = mountInfo[1].section(" ",4,4, skipEmpty);
+ return capacity;
+}
+
+QStringList LOS::CPUTemperatures(){ //Returns: List containing the temperature of any CPU's ("50C" for example)
+ return QStringList(); //not implemented yet
+}
+
+int LOS::CPUUsagePercent(){ //Returns: Overall percentage of the amount of CPU cycles in use (-1 for errors)
+ return -1; //not implemented yet
+}
+
+int LOS::MemoryUsagePercent(){
+ return -1; //not implemented yet
+}
+
+QStringList LOS::DiskUsage(){ //Returns: List of current read/write stats for each device
+ return QStringList(); //not implemented yet
+}
+#endif
diff --git a/libLumina/libLumina.pro b/libLumina/libLumina.pro
index df8544d5..d17908b4 100644
--- a/libLumina/libLumina.pro
+++ b/libLumina/libLumina.pro
@@ -36,6 +36,7 @@ SOURCES += LuminaXDG.cpp \
LuminaSingleApplication.cpp \
LuminaOS-FreeBSD.cpp \
LuminaOS-DragonFly.cpp \
+ LuminaOS-NetBSD.cpp \
LuminaOS-OpenBSD.cpp \
LuminaOS-kFreeBSD.cpp
# new OS support can be added here
bgstack15