Zastosowanie: włączenie szybszego, ale mniej bezpiecznego trybu
w czasie oglądania czegoś w Kodi.
Wymaga unitu systemd toggle-bcache@.service:
---
[Unit]
Description=toggle bcache mode for all devices
[Service]
Type=oneshot
WorkingDirectory=/sys
ExecStart=/usr/bin/fd --full-path bcache/cache_mode --exec sh -c "echo %i > {}; "
ProtectSystem=strict
ProtectHome=yes
PrivateTmp=yes
ProtectControlGroups=yes
---
Oraz regułki polkit openhab.rules:
---
polkit.addRule(function(action, subject) {
if (action.id == "org.freedesktop.systemd1.manage-units") {
var unit = action.lookup("unit");
if (unit == "toggle-bcache@writethrough.service" ||
unit == "toggle-bcache@writeback.service") {
var verb = action.lookup("verb");
if (verb == "start" && subject.user == "openhabik") {
return polkit.Result.YES;
}
}
}
});
---
7 lines
249 B
Plaintext
7 lines
249 B
Plaintext
|
|
/* czy jesteśmy dłużej poza domem? */
|
|
Switch sHolidayVacancy "Jesteśmy poza domem"
|
|
|
|
Switch sBCacheWriteback "Bcache w trybie writeback" { exec=">[ON:systemctl start toggle-bcache@writeback] >[OFF:systemctl start toggle-bcache@writethrough]" }
|
|
|