Skip to content
This repository has been archived by the owner on Dec 4, 2020. It is now read-only.

Commit

Permalink
Add the ability to specify a file manager for a "broken" desktop (LXD…
Browse files Browse the repository at this point in the history
…E at the moment) using the de-info utility to the mount tray - use xdg-open by default.
  • Loading branch information
Ken committed Sep 12, 2013
1 parent 5a2e630 commit 74b4950
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src-qt4/pc-mounttray/mountTray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ void MountTray::programInit()
qDebug() << "pc-mounttray: starting up";
MTINIT=true; //set the flag that the mount tray is initializing;
getInitialUsername(); //try to detect the non-root user who is running the program with root permissions
getFileManager();

loadSavedSettings();

trayIcon = new QSystemTrayIcon(this);
Expand Down Expand Up @@ -286,6 +288,23 @@ void MountTray::getInitialUsername(){
if(DEBUG_MODE){ qDebug() << "-User detected:" << USERNAME; }
}

void MountTray::getFileManager(){
//Check for broken DE's that need a FM manually set
FMCMD = "xdg-open"; //the default auto-detection application
QStringList DEI = pcbsd::Utils::runShellCommand("de-info");
QStringList broken; broken << "LXDE";
for(int i=0; i<DEI.length(); i++){
if(DEI[i].contains("DE name:")){ //this is always at the top of the output
QString DE = DEI[i].section(":",1,1).simplified();
qDebug() << "-Desktop Detected:" << DE;
if( !broken.contains( DE ) ){ break; } //this DE is fine
}else if(DEI[i].contains("File manager:")){
FMCMD = DEI[i].section(":",1,1).section(" ",0,0, QString::SectionSkipEmpty).simplified();
break;
}
}
qDebug() << "-File Manager:" << FMCMD;
}
void MountTray::slotOpenMediaDir(){
openMediaDir(MOUNTDIR);
}
Expand All @@ -302,7 +321,7 @@ void MountTray::openMediaDir(QString dir){
}
//Open the default file manager to the given directory as that user
qDebug() << "Opening the media directory with user permissions";
QString cmd = "su -m "+USERNAME+" -c \"xdg-open \'"+dir+"\' \"";
QString cmd = "su -m "+USERNAME+" -c \""+FMCMD+" \'"+dir+"\' \"";
if(DEBUG_MODE){ qDebug() << " -cmd:" << cmd ; }
cmd.prepend("("); cmd.append(") &");
system( cmd.toUtf8() );
Expand Down
4 changes: 4 additions & 0 deletions src-qt4/pc-mounttray/mountTray.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,16 @@ private slots:
QString popupSave; //for saving the device for the latest pop-up message
bool MTINIT;

//CMD to use for opening the file manager
QString FMCMD;

void updateMenu();
void scanInitialDevices();
int findDeviceInList(QString);
bool addDevice(QString,QString,QString,QString);
void startupDevdProc();
void getInitialUsername();
void getFileManager();
void loadSavedSettings();
void saveCurrentSettings();

Expand Down

0 comments on commit 74b4950

Please sign in to comment.