diff options
author | Ken Moore <ken@pcbsd.org> | 2014-09-19 10:20:49 -0400 |
---|---|---|
committer | Ken Moore <ken@pcbsd.org> | 2014-09-19 10:20:49 -0400 |
commit | 136d287ae121eb8bfb1d9c5c0857cc5aa2fb507f (patch) | |
tree | 7bcc4e8b41025ccbe9c288c0c334f7dc7fd17a5a | |
parent | Add the ability to lock the screen from the log out menu in lumina-desktop. (diff) | |
download | lumina-136d287ae121eb8bfb1d9c5c0857cc5aa2fb507f.tar.gz lumina-136d287ae121eb8bfb1d9c5c0857cc5aa2fb507f.tar.bz2 lumina-136d287ae121eb8bfb1d9c5c0857cc5aa2fb507f.zip |
Add support for detecting whether the running user has permission to shutdown/restart the system, and enable/disable those options in the logout menu appropriately.
-rw-r--r-- | libLumina/LuminaOS-DragonFly.cpp | 5 | ||||
-rw-r--r-- | libLumina/LuminaOS-FreeBSD.cpp | 7 | ||||
-rw-r--r-- | libLumina/LuminaOS-Linux.cpp | 5 | ||||
-rw-r--r-- | libLumina/LuminaOS-OpenBSD.cpp | 5 | ||||
-rw-r--r-- | libLumina/LuminaOS-template.cpp | 5 | ||||
-rw-r--r-- | libLumina/LuminaOS.h | 2 | ||||
-rw-r--r-- | lumina-desktop/SystemWindow.cpp | 5 |
7 files changed, 34 insertions, 0 deletions
diff --git a/libLumina/LuminaOS-DragonFly.cpp b/libLumina/LuminaOS-DragonFly.cpp index 990bf9f7..6d59f0d7 100644 --- a/libLumina/LuminaOS-DragonFly.cpp +++ b/libLumina/LuminaOS-DragonFly.cpp @@ -131,6 +131,11 @@ void LOS::startMixerUtility(){ QProcess::startDetached("pc-mixer -notray"); } +//Check for user system permission (shutdown/restart) +bool LOS::userHasShutdownAccess(){ + return true; //not implemented yet +} + //System Shutdown void LOS::systemShutdown(){ //start poweroff sequence QProcess::startDetached("shutdown -p now"); diff --git a/libLumina/LuminaOS-FreeBSD.cpp b/libLumina/LuminaOS-FreeBSD.cpp index a078687d..97f465e2 100644 --- a/libLumina/LuminaOS-FreeBSD.cpp +++ b/libLumina/LuminaOS-FreeBSD.cpp @@ -132,6 +132,13 @@ void LOS::startMixerUtility(){ QProcess::startDetached("pc-mixer -notray"); } +//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"); //not implemented yet +} + //System Shutdown void LOS::systemShutdown(){ //start poweroff sequence QProcess::startDetached("shutdown -p now"); diff --git a/libLumina/LuminaOS-Linux.cpp b/libLumina/LuminaOS-Linux.cpp index b7bb3685..af8c740f 100644 --- a/libLumina/LuminaOS-Linux.cpp +++ b/libLumina/LuminaOS-Linux.cpp @@ -114,6 +114,11 @@ void LOS::startMixerUtility(){ QProcess::startDetached("/usr/bin/pavucontrol"); } +//Check for user system permission (shutdown/restart) +bool LOS::userHasShutdownAccess(){ + return true; //not implemented yet +} + //System Shutdown void LOS::systemShutdown(){ //start poweroff sequence QProcess::startDetached("shutdown -h now"); diff --git a/libLumina/LuminaOS-OpenBSD.cpp b/libLumina/LuminaOS-OpenBSD.cpp index 770e3a3a..34ae713c 100644 --- a/libLumina/LuminaOS-OpenBSD.cpp +++ b/libLumina/LuminaOS-OpenBSD.cpp @@ -142,6 +142,11 @@ void LOS::startMixerUtility(){ //Not implemented yet for OpenBSD } +//Check for user system permission (shutdown/restart) +bool LOS::userHasShutdownAccess(){ + return true; //not implemented yet +} + //System Shutdown void LOS::systemShutdown(){ //start poweroff sequence QProcess::startDetached("shutdown -hp now"); diff --git a/libLumina/LuminaOS-template.cpp b/libLumina/LuminaOS-template.cpp index 0bfac22a..b975d5a1 100644 --- a/libLumina/LuminaOS-template.cpp +++ b/libLumina/LuminaOS-template.cpp @@ -64,6 +64,11 @@ void LOS::startMixerUtility(){ //not implemented yet } +//Check for user system permission (shutdown/restart) +bool LOS::userHasShutdownAccess(){ + return false; //not implemented yet +} + //System Shutdown void LOS::systemShutdown(){ //start poweroff sequence QProcess::startDetached("shutdown -p now"); diff --git a/libLumina/LuminaOS.h b/libLumina/LuminaOS.h index 6b755e03..f4fe8970 100644 --- a/libLumina/LuminaOS.h +++ b/libLumina/LuminaOS.h @@ -51,6 +51,8 @@ public: //Launch the graphical audio mixer utility static void startMixerUtility(); + //Check for user system permission (shutdown/restart) + static bool userHasShutdownAccess(); //System Shutdown static void systemShutdown(); //start poweroff sequence //System Restart diff --git a/lumina-desktop/SystemWindow.cpp b/lumina-desktop/SystemWindow.cpp index dc9dc488..10d44524 100644 --- a/lumina-desktop/SystemWindow.cpp +++ b/lumina-desktop/SystemWindow.cpp @@ -20,6 +20,11 @@ SystemWindow::SystemWindow() : QDialog(), ui(new Ui::SystemWindow){ connect(ui->tool_shutdown, SIGNAL(clicked()), this, SLOT(sysShutdown()) ); connect(ui->push_cancel, SIGNAL(clicked()), this, SLOT(sysCancel()) ); connect(ui->push_lock, SIGNAL(clicked()), this, SLOT(sysLock()) ); + //Disable the shutdown/restart buttons if necessary + if( !LOS::userHasShutdownAccess() ){ + ui->tool_restart->setEnabled(false); + ui->tool_shutdown->setEnabled(false); + } //Center this window on the screen QDesktopWidget desktop; this->move(desktop.screenGeometry().width()/2 - this->width()/2, desktop.screenGeometry().height()/2 - this->height()/2); |