fix poweroff

This commit is contained in:
myshow 2020-12-03 14:09:39 +08:00
parent 2f8381c973
commit bc36d39d32
2 changed files with 74 additions and 6 deletions

65
0001-fix-poweroff.patch Normal file
View File

@ -0,0 +1,65 @@
From 6e6f2d46c03b255062c8fdb6f64f0e587445a6ef Mon Sep 17 00:00:00 2001
From: myshow <296570182@qq.com>
Date: Thu, 3 Dec 2020 11:05:51 +0800
Subject: [PATCH] fix-poweroff
---
ukui-session/sessiondbusadaptor.h | 27 +++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/ukui-session/sessiondbusadaptor.h b/ukui-session/sessiondbusadaptor.h
index c005702..4da2b55 100644
--- a/ukui-session/sessiondbusadaptor.h
+++ b/ukui-session/sessiondbusadaptor.h
@@ -21,6 +21,7 @@
#define SESSIONDBUSADAPTOR_H
#include <QtDBus>
+#include <QMessageBox>
#include "../tools/ukuipower.h"
#include "modulemanager.h"
@@ -54,7 +55,16 @@ public slots:
bool canPowerOff()
{
- return mPower->canAction(UkuiPower::PowerShutdown);
+ QProcess p;
+ p.start("bash", QStringList() <<"-c" << "who | wc -l");
+ p.waitForFinished();
+ QString ret = p.readAllStandardOutput();
+ int user = ret.toInt();
+ if (user > 1)
+ return false;
+ else
+ return true;
+ // return mPower->canAction(UkuiPower::PowerShutdown);
}
Q_NOREPLY void logout()
@@ -74,10 +84,19 @@ public slots:
Q_NOREPLY void powerOff()
{
if(mPower->canAction(UkuiPower::PowerShutdown)){
- mManager->logout(false);
- mPower->doAction(UkuiPower::PowerShutdown);
+ // mManager->logout(false);
+ // mPower->doAction(UkuiPower::PowerShutdown);
+ QProcess::execute("shutdown -h now");
+ // QProcess::execute("poweroff");
+ }
+ else {
+ //弹框提示无法生效?
+ QMessageBox msg;
+ msg.setWindowTitle(tr("Error"));
+ msg.setText(tr("The computer could not be shut down!"));
+ msg.addButton(tr("Ok"), QMessageBox::AcceptRole);
+ msg.exec();
}
- //QCoreApplication::exit(0);
}
// QDBusVariant listModules()
--
2.29.2.windows.2

View File

@ -2,7 +2,7 @@
Name: ukui-session-manager Name: ukui-session-manager
Version: 3.0.2 Version: 3.0.2
Release: 1 Release: 2
Summary: Session manager of the UKUI desktop environment Summary: Session manager of the UKUI desktop environment
License: LGPL-2.1+ GPL-3+ License: LGPL-2.1+ GPL-3+
URL: http://www.ukui.org URL: http://www.ukui.org
@ -22,17 +22,17 @@ Recommends: ukui-settings-daemon
Provides: x-session-manager Provides: x-session-manager
#patch0: delay-other-program.patch patch0: 0001-fix-poweroff.patch
%description %description
This package contains a session that can be started from a display This package contains a session that can be started from a display
manager such as lightdm. It will load all necessary applications for manager such as lightdm. It will load all necessary applications for
a full-featured user session. a full-featured user session.
.
This package contain the session manager component. This package contain the session manager component.
%prep %prep
%setup -q %setup -q
#%%patch0 -p2 %patch0 -p1
%build %build
mkdir cmake-build mkdir cmake-build
@ -49,7 +49,7 @@ popd
#install -m644 debian/99ukui-environment %{buildroot}/etc/X11/Xsession.d/99ukui-environment #install -m644 debian/99ukui-environment %{buildroot}/etc/X11/Xsession.d/99ukui-environment
install -d %{buildroot}/usr/share/man/man1/ %{buildroot}/etc/polkit-1/localauthority/50-local.d/ install -d %{buildroot}/usr/share/man/man1/ %{buildroot}/etc/polkit-1/localauthority/50-local.d/
install -m644 data/com.ubuntu.enable-hibernate.pkla %{buildroot}/etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla install -m644 data/com.ubuntu.enable-hibernate.pkla %{buildroot}/etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla
gzip -c man/ukui-session.1 > %{buildroot}/usr/share/man/man1/ukui-session.1.gz gzip -c man/ukui-session.1 > %{buildroot}/usr/share/man/man1/ukui-session.1.gz
gzip -c man/ukui-session-tools.1 > %{buildroot}/usr/share/man/man1/ukui-session-tools.1.gz gzip -c man/ukui-session-tools.1 > %{buildroot}/usr/share/man/man1/ukui-session-tools.1.gz
%clean %clean
@ -62,10 +62,13 @@ rm -rf $RPM_BUILD_ROOT
%{_datadir}/* %{_datadir}/*
%{_prefix}/bin/ukui-session %{_prefix}/bin/ukui-session
%{_prefix}/bin/ukui-session-tools %{_prefix}/bin/ukui-session-tools
#%%{_datadir}/man/man1/ukui-session.1.gz #%%{_datadir}/man/man1/ukui-session.1.gz
#%%{_datadir}/man/man1/ukui-session-tools.1.gz #%%{_datadir}/man/man1/ukui-session-tools.1.gz
%changelog %changelog
* Thu Dec 3 2020 lvhan <lvhan@kylinos.cn> - 3.0.2-2
- fix poweroff
* Mon Oct 26 2020 douyan <douyan@kylinos.cn> - 3.0.2-1 * Mon Oct 26 2020 douyan <douyan@kylinos.cn> - 3.0.2-1
- update to upstream version 3.0.1 - update to upstream version 3.0.1