Bring back the oneshot permission daemon (initial commit)

This commit is contained in:
Matti Viljanen 2020-06-11 12:18:11 +03:00
parent 8e3ab2024a
commit 6899638969
No known key found for this signature in database
GPG key ID: CF32A1495158F888
3 changed files with 21 additions and 9 deletions

View file

@ -44,6 +44,9 @@ DISTFILES += qml/harbour-batterybuddy.qml \
qml/cover/CoverPage.qml \ qml/cover/CoverPage.qml \
../rpm/harbour-batterybuddy.spec \ ../rpm/harbour-batterybuddy.spec \
service/harbour-batterybuddy.service \ service/harbour-batterybuddy.service \
service/harbour-batterybuddy-oneshot.service \
service/restore-write-permissions.sh \
service/set-write-permissions.sh \
translations/*.ts \ translations/*.ts \
harbour-batterybuddy.desktop \ harbour-batterybuddy.desktop \
qml/pages/MainPage.qml \ qml/pages/MainPage.qml \
@ -59,11 +62,15 @@ SAILFISHAPP_ICONS = 86x86 108x108 128x128 172x172
TRANSLATIONS += translations/*.ts TRANSLATIONS += translations/*.ts
# Executable provided by "service.pro" # Executable provided by "service.pro"
OTHER_FILES += service/harbour-batterybuddy.service # Two services, actually
OTHER_FILES += service/harbour-batterybuddy.service \
service/harbour-batterybuddy-oneshot.service \
service/restore-write-permissions.sh \
service/set-write-permissions.sh
service.files = service service.files = service
service.path = /usr/share/$${TARGET} service.path = /usr/share/$${TARGET}
# Include images
images.files = images images.files = images
images.path = /usr/share/$${TARGET} images.path = /usr/share/$${TARGET}

View file

@ -69,10 +69,15 @@ desktop-file-install --delete-original \
# << files # << files
%posttrans %posttrans
systemctl disable --now harbour-batterybuddy-oneshot.service
systemctl disable --now harbour-batterybuddy.service systemctl disable --now harbour-batterybuddy.service
cp %{_datadir}/%{name}/service/harbour-batterybuddy-oneshot.service /etc/systemd/system/
cp %{_datadir}/%{name}/service/harbour-batterybuddy.service /etc/systemd/system/ cp %{_datadir}/%{name}/service/harbour-batterybuddy.service /etc/systemd/system/
systemctl enable --now harbour-batterybuddy-oneshot.service
systemctl enable --now harbour-batterybuddy.service systemctl enable --now harbour-batterybuddy.service
%postun %postun
systemctl disable --now harbour-batterybuddy-oneshot.service
systemctl disable --now harbour-batterybuddy.service systemctl disable --now harbour-batterybuddy.service
rm /etc/systemd/system/harbour-batterybuddy-oneshot.service
rm /etc/systemd/system/harbour-batterybuddy.service rm /etc/systemd/system/harbour-batterybuddy.service

View file

@ -76,15 +76,15 @@ Battery::Battery(Settings *newSettings, QTimer *newUpdater, QTimer *newNotifier,
if(chargingEnabledFile) { if(chargingEnabledFile) {
// This should always succeed, since the service is started as root // This should always succeed, since the service is started as root
if(chargingEnabledFile->open(QIODevice::WriteOnly)) { if(chargingEnabledFile->open(QIODevice::WriteOnly)) {
qInfo() << "Controlling charging via" << chargingEnabledFile->fileName(); // qInfo() << "Controlling charging via" << chargingEnabledFile->fileName();
chargingEnabledFile->close(); // chargingEnabledFile->close();
originalPerms = chargingEnabledFile->permissions(); // originalPerms = chargingEnabledFile->permissions();
if(originalPerms | customPerms) { // if(originalPerms | customPerms) {
chargingEnabledFile->setPermissions(customPerms); // chargingEnabledFile->setPermissions(customPerms);
qDebug() << "Charger control file permissions updated."; // qDebug() << "Charger control file permissions updated.";
} // }
} }
else { else {
delete chargingEnabledFile; delete chargingEnabledFile;