Add systemd service for ensuring write access
This commit is contained in:
parent
c67a33a4b7
commit
d15d45ee1f
5 changed files with 46 additions and 3 deletions
|
@ -28,6 +28,9 @@ DISTFILES += qml/harbour-batterybuddy.qml \
|
||||||
qml/cover/CoverPage.qml \
|
qml/cover/CoverPage.qml \
|
||||||
rpm/harbour-batterybuddy.spec \
|
rpm/harbour-batterybuddy.spec \
|
||||||
rpm/harbour-batterybuddy.yaml \
|
rpm/harbour-batterybuddy.yaml \
|
||||||
|
service/clear-write-permissions.sh \
|
||||||
|
service/harbour-batterybuddy.service \
|
||||||
|
service/set-write-permissions.sh \
|
||||||
translations/*.ts \
|
translations/*.ts \
|
||||||
harbour-batterybuddy.desktop \
|
harbour-batterybuddy.desktop \
|
||||||
qml/pages/MainPage.qml \
|
qml/pages/MainPage.qml \
|
||||||
|
@ -42,15 +45,22 @@ SAILFISHAPP_ICONS = 86x86 108x108 128x128 172x172
|
||||||
|
|
||||||
TRANSLATIONS += translations/*.ts
|
TRANSLATIONS += translations/*.ts
|
||||||
|
|
||||||
|
OTHER_FILES += service/clear-write-permissions.sh \
|
||||||
|
service/harbour-batterybuddy.service \
|
||||||
|
service/set-write-permissions.sh
|
||||||
|
|
||||||
|
service.files = service
|
||||||
|
service.path = /usr/share/$${TARGET}
|
||||||
|
|
||||||
|
INSTALLS += service
|
||||||
|
|
||||||
# Begin: include sound files
|
# Begin: include sound files
|
||||||
|
|
||||||
#OTHER_FILES += sounds/upperLimit.ogg \
|
#OTHER_FILES += sounds/upperLimit.ogg \
|
||||||
# sounds/lowerLimit.ogg \
|
# sounds/lowerLimit.ogg \
|
||||||
|
|
||||||
#DEPLOYMENT_PATH = /usr/share/$${TARGET}
|
|
||||||
|
|
||||||
#sounds.files = sounds
|
#sounds.files = sounds
|
||||||
#sounds.path = $${DEPLOYMENT_PATH}
|
#sounds.path = /usr/share/$${TARGET}
|
||||||
|
|
||||||
#INSTALLS += sounds
|
#INSTALLS += sounds
|
||||||
|
|
||||||
|
|
|
@ -69,3 +69,13 @@ desktop-file-install --delete-original \
|
||||||
%{_datadir}/icons/hicolor/*/apps/%{name}.png
|
%{_datadir}/icons/hicolor/*/apps/%{name}.png
|
||||||
# >> files
|
# >> files
|
||||||
# << files
|
# << files
|
||||||
|
|
||||||
|
%post
|
||||||
|
cp %{_datadir}/%{name}/service/harbour-batterybuddy.service /etc/systemd/system/
|
||||||
|
chmod 755 %{_datadir}/%{name}/service/*.sh
|
||||||
|
systemctl disable --now harbour-batterybuddy.service
|
||||||
|
systemctl enable --now harbour-batterybuddy.service
|
||||||
|
|
||||||
|
%postun
|
||||||
|
systemctl disable --now harbour-batterybuddy.service
|
||||||
|
rm /etc/systemd/system/harbour-batterybuddy.service
|
||||||
|
|
5
service/clear-write-permissions.sh
Executable file
5
service/clear-write-permissions.sh
Executable file
|
@ -0,0 +1,5 @@
|
||||||
|
#!/bin/bash
|
||||||
|
chmod 644 /sys/class/power_supply/battery/input_suspend 2>/dev/null
|
||||||
|
chmod 644 /sys/class/power_supply/battery/charging_enabled 2>/dev/null
|
||||||
|
chmod 644 /sys/class/power_supply/usb/charger_disable 2>/dev/null
|
||||||
|
exit 0
|
13
service/harbour-batterybuddy.service
Normal file
13
service/harbour-batterybuddy.service
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Allow user nemo to write to charging control file
|
||||||
|
#After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/usr/share/harbour-batterybuddy/service/set-write-permissions.sh
|
||||||
|
RemainAfterExit=true
|
||||||
|
ExecStop=/usr/share/harbour-batterybuddy/service/clear-write-permissions.sh
|
||||||
|
StandardOutput=journal
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
5
service/set-write-permissions.sh
Executable file
5
service/set-write-permissions.sh
Executable file
|
@ -0,0 +1,5 @@
|
||||||
|
#!/bin/bash
|
||||||
|
chmod 666 /sys/class/power_supply/battery/input_suspend 2>/dev/null
|
||||||
|
chmod 666 /sys/class/power_supply/battery/charging_enabled 2>/dev/null
|
||||||
|
chmod 666 /sys/class/power_supply/usb/charger_disable 2>/dev/null
|
||||||
|
exit 0
|
Loading…
Reference in a new issue