aboutsummaryrefslogtreecommitdiff
path: root/libLumina
diff options
context:
space:
mode:
Diffstat (limited to 'libLumina')
-rw-r--r--libLumina/LuminaOS-Debian.cpp20
-rw-r--r--libLumina/LuminaOS-DragonFly.cpp8
-rw-r--r--libLumina/LuminaOS-FreeBSD.cpp10
-rw-r--r--libLumina/LuminaOS-Linux.cpp20
-rw-r--r--libLumina/LuminaOS-OpenBSD.cpp15
-rw-r--r--libLumina/LuminaOS-kFreeBSD.cpp5
-rw-r--r--libLumina/LuminaOS-template.cpp5
-rw-r--r--libLumina/LuminaOS.h3
-rw-r--r--libLumina/LuminaUtils.cpp2
-rw-r--r--libLumina/LuminaX11.cpp83
-rw-r--r--libLumina/LuminaX11.h5
-rw-r--r--libLumina/LuminaXDG.cpp60
-rw-r--r--libLumina/LuminaXDG.h3
-rw-r--r--libLumina/libLumina.pro2
14 files changed, 214 insertions, 27 deletions
diff --git a/libLumina/LuminaOS-Debian.cpp b/libLumina/LuminaOS-Debian.cpp
index 4f2032fa..7ce8250f 100644
--- a/libLumina/LuminaOS-Debian.cpp
+++ b/libLumina/LuminaOS-Debian.cpp
@@ -195,7 +195,25 @@ int LOS::batterySecondsLeft(){ //Returns: estimated number of seconds remaining
//File Checksums
QStringList LOS::Checksums(QStringList filepaths){ //Return: checksum of the input file
- return QStringList();
+ QStringList info = LUtils::getCmdOutput("md5sum \""+filepaths.join("\" \"")+"\"");
+ for(int i=0; i<info.length(); i++){
+ // first: md5sum: = error ; second: there's always one empty entry generated by getCmdOutput
+ if( info[i].startsWith("md5sum:") || info[i].isEmpty()){ info.removeAt(i); i--; }
+ else{
+ //Strip out the extra information
+ info[i] = info[i].section(" ",0,0);
+ }
+ }
+ return info;
+}
+
+//file system capacity
+QString LOS::FileSystemCapacity(QString dir) { //Return: percentage capacity as give by the df command
+ QStringList mountInfo = LUtils::getCmdOutput("df -h \"" + dir + "\"");
+ QString::SectionFlag skipEmpty = QString::SectionSkipEmpty;
+ //output: 200G of 400G available on /mount/point
+ QString capacity = mountInfo[1].section(" ",3,3, skipEmpty) + " of " + mountInfo[1].section(" ",1,1, skipEmpty) + " available on " + mountInfo[1].section(" ",5,5, skipEmpty);
+ return capacity;
}
#endif
diff --git a/libLumina/LuminaOS-DragonFly.cpp b/libLumina/LuminaOS-DragonFly.cpp
index 35bff04c..b9ba58a2 100644
--- a/libLumina/LuminaOS-DragonFly.cpp
+++ b/libLumina/LuminaOS-DragonFly.cpp
@@ -176,4 +176,12 @@ QStringList LOS::Checksums(QStringList filepaths){ //Return: checksum of the inp
return QStringList();
}
+//file system capacity
+QString LOS::FileSystemCapacity(QString dir) { //Return: percentage capacity as give by the df command
+ 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;
+}
#endif
diff --git a/libLumina/LuminaOS-FreeBSD.cpp b/libLumina/LuminaOS-FreeBSD.cpp
index d454ce22..fc4135f0 100644
--- a/libLumina/LuminaOS-FreeBSD.cpp
+++ b/libLumina/LuminaOS-FreeBSD.cpp
@@ -195,4 +195,14 @@ QStringList LOS::Checksums(QStringList filepaths){ //Return: checksum of the inp
}
return info;
}
+
+//file system capacity
+QString LOS::FileSystemCapacity(QString dir) { //Return: percentage capacity as give by the df command
+ 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;
+}
+
#endif
diff --git a/libLumina/LuminaOS-Linux.cpp b/libLumina/LuminaOS-Linux.cpp
index 7587a29b..46a6371a 100644
--- a/libLumina/LuminaOS-Linux.cpp
+++ b/libLumina/LuminaOS-Linux.cpp
@@ -192,6 +192,24 @@ int LOS::batterySecondsLeft(){ //Returns: estimated number of seconds remaining
//File Checksums
QStringList LOS::Checksums(QStringList filepaths){ //Return: checksum of the input file
- return QStringList();
+ QStringList info = LUtils::getCmdOutput("md5sum \""+filepaths.join("\" \"")+"\"");
+ for(int i=0; i<info.length(); i++){
+ // first: md5sum: = error ; second: there's always one empty entry generated by getCmdOutput
+ if( info[i].startsWith("md5sum:") || info[i].isEmpty()){ info.removeAt(i); i--; }
+ else{
+ //Strip out the extra information
+ info[i] = info[i].section(" ",0,0);
+ }
+ }
+ return info;
+}
+
+//file system capacity
+QString LOS::FileSystemCapacity(QString dir) { //Return: percentage capacity as give by the df command
+ 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) + " used";
+ return capacity;
}
#endif
diff --git a/libLumina/LuminaOS-OpenBSD.cpp b/libLumina/LuminaOS-OpenBSD.cpp
index b6996795..df6ddeba 100644
--- a/libLumina/LuminaOS-OpenBSD.cpp
+++ b/libLumina/LuminaOS-OpenBSD.cpp
@@ -207,4 +207,19 @@ QStringList LOS::Checksums(QStringList filepaths){ //Return: checksum of the inp
}
return info;
}
+
+//file system capacity
+QString LOS::FileSystemCapacity(QString dir) {
+ // on OpenBSD, df has the following layout:
+ //>df /home/wi
+ //>Filesystem 512-blocks Used Avail Capacity Mounted on
+ //>/dev/sd2l 14334588 739900 12877960 5% /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;
+}
+
#endif
diff --git a/libLumina/LuminaOS-kFreeBSD.cpp b/libLumina/LuminaOS-kFreeBSD.cpp
index 16c8e6eb..2b24ce51 100644
--- a/libLumina/LuminaOS-kFreeBSD.cpp
+++ b/libLumina/LuminaOS-kFreeBSD.cpp
@@ -158,5 +158,10 @@ QStringList LOS::Checksums(QStringList filepaths){ //Return: checksum of the inp
return QStringList();
}
+//file system capacity
+QString LOS::FileSystemCapacity(QString dir) { //Return: percentage capacity as give by the df command
+ return QString();
+}
+
#endif
#endif
diff --git a/libLumina/LuminaOS-template.cpp b/libLumina/LuminaOS-template.cpp
index c06b8b11..dfb9d850 100644
--- a/libLumina/LuminaOS-template.cpp
+++ b/libLumina/LuminaOS-template.cpp
@@ -106,4 +106,9 @@ QStringList LOS::Checksums(QStringList filepaths){ //Return: checksum of the inp
return QStringList();
}
+//file system capacity
+QString LOS::FileSystemCapacity(QString dir) { //Return: percentage capacity as give by the df command
+ return QString();
+}
+
#endif
diff --git a/libLumina/LuminaOS.h b/libLumina/LuminaOS.h
index 92a7dc7e..091a8d96 100644
--- a/libLumina/LuminaOS.h
+++ b/libLumina/LuminaOS.h
@@ -83,6 +83,9 @@ public:
//Get the checksum for a file
static QStringList Checksums(QStringList filepaths); //Return: checksum of each input file (same order)
+
+ //Get the filesystem capacity
+ static QString FileSystemCapacity(QString dir) ; //Return: percentage capacity as give by the df command
};
#endif
diff --git a/libLumina/LuminaUtils.cpp b/libLumina/LuminaUtils.cpp
index f7f5db74..fa6c64f8 100644
--- a/libLumina/LuminaUtils.cpp
+++ b/libLumina/LuminaUtils.cpp
@@ -21,7 +21,7 @@
// LUtils Functions
//=============
QString LUtils::LuminaDesktopVersion(){
- return "0.8.3-devel";
+ return "0.8.4-devel";
}
int LUtils::runCmd(QString cmd, QStringList args){
diff --git a/libLumina/LuminaX11.cpp b/libLumina/LuminaX11.cpp
index 43d4e577..51df70d5 100644
--- a/libLumina/LuminaX11.cpp
+++ b/libLumina/LuminaX11.cpp
@@ -26,6 +26,7 @@
#include <xcb/xcb_ewmh.h>
#include <xcb/xcb_icccm.h>
#include <xcb/xcb_image.h>
+#include <xcb/composite.h>
//===== WindowList() ========
@@ -1133,26 +1134,6 @@ QIcon LXCB::WindowIcon(WId win){
return icon;
}
-// === WindowImage() ===
-QPixmap LXCB::WindowImage(WId win){
- QPixmap pix;
-
- //First get the size of the window
- xcb_get_geometry_cookie_t cookie = xcb_get_geometry_unchecked(QX11Info::connection(), win);
- xcb_get_geometry_reply_t *reply = xcb_get_geometry_reply(QX11Info::connection(), cookie, NULL);
- if(reply == 0){ return pix; } //could not determine window geometry
- //Now get the image
- xcb_image_t *img = xcb_image_get(QX11Info::connection(), win, 0, 0, reply->width, reply->height, (uint32_t) AllPlanes, XCB_IMAGE_FORMAT_Z_PIXMAP);
- if(img!=0){
- //Now convert the image into a QPixmap
- pix.convertFromImage( QImage( (const uchar*) img->data, img->width, img->height, img->stride, QImage::Format_ARGB32_Premultiplied) );
- //Clean up the xcb_image structure
- xcb_image_destroy(img);
- }
- //Return the pixmap
- return pix;
-}
-
// === SetAsSticky() ===
void LXCB::SetAsSticky(WId win){
//Need to send a client message event for the window so the WM picks it up
@@ -1351,6 +1332,68 @@ void LXCB::MoveResizeWindow(WId win, QRect geom){
}
+// === EmbedWindow() ===
+bool LXCB::EmbedWindow(WId win, WId container){
+ if(win==0 || container==0){ return false; }
+ //qDebug() << "Embed Window:" << win << container;
+
+ //Initialize any atoms that will be needed
+ xcb_intern_atom_cookie_t ecookie = xcb_intern_atom_unchecked(QX11Info::connection(), 0, 7, "_XEMBED");
+
+ xcb_intern_atom_reply_t *ereply = xcb_intern_atom_reply(QX11Info::connection(), ecookie, NULL);
+ if(ereply==0){ return false; } //unable to initialize the atom
+ xcb_atom_t emb = ereply->atom;
+ free(ereply); //done with this structure
+
+ //Reparent the window into the container
+ xcb_reparent_window(QX11Info::connection(), win, container, 0, 0);
+ xcb_map_window(QX11Info::connection(), win);
+
+ //Now send the embed event to the app
+ //qDebug() << " - send _XEMBED event";
+ xcb_client_message_event_t event;
+ event.response_type = XCB_CLIENT_MESSAGE;
+ event.format = 32;
+ event.window = win;
+ event.type = emb; //_XEMBED
+ event.data.data32[0] = CurrentTime;
+ event.data.data32[1] = 0; //XEMBED_EMBEDDED_NOTIFY
+ event.data.data32[2] = 0;
+ event.data.data32[3] = container; //WID of the container
+ event.data.data32[4] = 0;
+
+ xcb_send_event(QX11Info::connection(), 0, win, XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (const char *) &event);
+
+ //Now setup any redirects and return
+ //qDebug() << " - select Input";
+ //XSelectInput(disp, win, StructureNotifyMask); //Notify of structure changes
+ uint32_t val[] = {XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY};
+ xcb_change_window_attributes(QX11Info::connection(), win, XCB_CW_EVENT_MASK, val);
+ //qDebug() << " - Composite Redirect";
+ xcb_composite_redirect_window(QX11Info::connection(), win, XCB_COMPOSITE_REDIRECT_MANUAL);
+
+ //Now map the window (will be a transparent child of the container)
+ xcb_map_window(QX11Info::connection(), win);
+
+ //qDebug() << " - Done";
+ return true;
+}
+
+// === Unembed Window() ===
+bool LXCB::UnembedWindow(WId win){
+ //Display *disp = QX11Info::display();
+ //Remove redirects
+ //XSelectInput(disp, win, NoEventMask);
+ uint32_t val[] = {XCB_EVENT_MASK_NO_EVENT};
+ xcb_change_window_attributes(QX11Info::connection(), win, XCB_CW_EVENT_MASK, val);
+ //Make sure it is invisible
+ xcb_unmap_window(QX11Info::connection(), win);
+ //Reparent the window back to the root window
+ xcb_reparent_window(QX11Info::connection(), win, QX11Info::appRootWindow(), 0, 0);
+ return true;
+}
+
+
// === SetScreenWorkArea() ===
/*void LXCB::SetScreenWorkArea(unsigned int screen, QRect rect){
//This is only useful because Fluxbox does not set the _NET_WORKAREA root atom
diff --git a/libLumina/LuminaX11.h b/libLumina/LuminaX11.h
index 62146ebe..2c34c6f5 100644
--- a/libLumina/LuminaX11.h
+++ b/libLumina/LuminaX11.h
@@ -141,7 +141,6 @@ public:
QString OldWindowIconName(WId win); //WM_ICON_NAME (old standard)
bool WindowIsMaximized(WId win);
QIcon WindowIcon(WId win); //_NET_WM_ICON
- QPixmap WindowImage(WId win); //Pull the image directly from the window
//Window Modification
void SetAsSticky(WId); //Stick to all workspaces
@@ -152,6 +151,10 @@ public:
void MaximizeWindow(WId win, bool flagsonly = false); //request that the window become maximized
void MoveResizeWindow(WId win, QRect geom);
+ //Window Embedding/Detaching (for system tray)
+ bool EmbedWindow(WId win, WId container);
+ bool UnembedWindow(WId win);
+
};
#endif \ No newline at end of file
diff --git a/libLumina/LuminaXDG.cpp b/libLumina/LuminaXDG.cpp
index e4839480..dbf08b88 100644
--- a/libLumina/LuminaXDG.cpp
+++ b/libLumina/LuminaXDG.cpp
@@ -127,8 +127,8 @@ bool LXDG::checkValidity(XDGDesktop dFile, bool showAll){
if(DEBUG){ qDebug() << " - Unknown file type"; }
}
if(!showAll){
- if(!dFile.showInList.isEmpty()){ ok = dFile.showInList.contains("Lumina"); }
- else if(!dFile.notShowInList.isEmpty()){ ok = !dFile.notShowInList.contains("Lumina"); }
+ if(!dFile.showInList.isEmpty()){ ok = dFile.showInList.contains("Lumina", Qt::CaseInsensitive); }
+ else if(!dFile.notShowInList.isEmpty()){ ok = !dFile.notShowInList.contains("Lumina",Qt::CaseInsensitive); }
}
return ok;
}
@@ -665,3 +665,59 @@ QStringList LXDG::loadMimeFileGlobs2(){
return mimeglobs;
}
+//Find all the autostart *.desktop files
+QList<XDGDesktop> LXDG::findAutoStartFiles(bool includeInvalid){
+
+ //First get the list of directories to search (system first, user-provided files come later and overwrite sys files as needed)
+ QStringList paths = QString(getenv("XDG_CONFIG_DIRS")).split(":");
+ paths << QString(getenv("XDG_CONFIG_HOME")).split(":");
+ //Now go through them and find any valid *.desktop files
+ QList<XDGDesktop> files;
+ QStringList filenames; //make it easy to see if this filename is an override
+ QDir dir;
+ for(int i=0;i<paths.length(); i++){
+ if(!QFile::exists(paths[i]+"/autostart")){ continue; }
+ dir.cd(paths[i]+"/autostart");
+ QStringList tmp = dir.entryList(QStringList() << "*.desktop", QDir::Files, QDir::Name);
+ for(int t=0; t<tmp.length(); t++){
+ bool ok = false;
+ XDGDesktop desk = LXDG::loadDesktopFile(dir.absoluteFilePath(tmp[t]), ok);
+ if(!ok){ continue; } //could not read file
+ //Now figure out what to do with it
+ if(filenames.contains(tmp[t])){
+ //This is an overwrite of a lower-priority (system?) autostart file
+ // find the other file
+ int old = -1;
+ for(int o=0; o<files.length(); o++){
+ if(files[o].filePath.endsWith("/"+tmp[t])){ old = o; break; } //found it
+ }
+ if(LXDG::checkValidity(desk, false)){
+ //Full override of the lower-priority file (might be replacing exec/tryexec fields)
+ files[old] = desk;
+ }else{
+ //Small override file (only the "Hidden" field listed in spec)
+ files[old].isHidden = desk.isHidden; //replace this value with the override
+ files << desk; //still add this to the array (will be ignored/skipped later)
+ }
+ }else{
+ //This is a new autostart file
+ files << desk;
+ filenames << tmp[t];
+ }
+ }//end of loop over *.desktop files
+ } //end of loop over directories
+
+ //Now filter the results by validity if desired
+ if(!includeInvalid){
+ for(int i=0; i<files.length(); i++){
+ if( !LXDG::checkValidity(files[i], false) || files[i].isHidden ){
+ //Invalid file - go ahead and remove it from the output list
+ files.removeAt(i);
+ i--;
+ }
+ }
+ }
+
+ return files;
+}
+
diff --git a/libLumina/LuminaXDG.h b/libLumina/LuminaXDG.h
index fe44a4fd..e9a6081e 100644
--- a/libLumina/LuminaXDG.h
+++ b/libLumina/LuminaXDG.h
@@ -99,6 +99,9 @@ public:
static QStringList findAVFileExtensions();
//Load all the "globs2" mime database files
static QStringList loadMimeFileGlobs2();
+
+ //Find all the autostart *.desktop files
+ static QList<XDGDesktop> findAutoStartFiles(bool includeInvalid = false);
};
#endif
diff --git a/libLumina/libLumina.pro b/libLumina/libLumina.pro
index e0963fc6..1b78367a 100644
--- a/libLumina/libLumina.pro
+++ b/libLumina/libLumina.pro
@@ -42,7 +42,7 @@ SOURCES += LuminaXDG.cpp \
INCLUDEPATH += $$PREFIX/include
-LIBS += -lX11 -lXrender -lXcomposite -lxcb -lxcb-ewmh -lxcb-icccm -lxcb-image
+LIBS += -lX11 -lXrender -lXcomposite -lxcb -lxcb-ewmh -lxcb-icccm -lxcb-image -lxcb-composite
include.path=$$PREFIX/include/
include.files=LuminaXDG.h \
bgstack15