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;
}
}
}
});
---
49 lines
1.3 KiB
Plaintext
49 lines
1.3 KiB
Plaintext
|
|
|
|
rule "Gramy!"
|
|
when
|
|
Item Kodi_State changed to Play
|
|
then
|
|
sOWFS01.sendCommand(OFF)
|
|
|
|
Mpd_quodlibet_StartStop_expected.postUpdate(Mpd_quodlibet_StartStop.state)
|
|
Mpd_quodlibet_StartStop.sendCommand(OFF)
|
|
|
|
sBCacheWriteback.sendCommand(ON)
|
|
end
|
|
|
|
|
|
rule "Nie gramy"
|
|
when
|
|
Item Kodi_State changed to Stop or
|
|
Item Kodi_State changed to Pause
|
|
then
|
|
/* bezpośrednie odwoływanie się do tych zmiennych powoduje jakieś nulle */
|
|
var preCB = sOWFS01_expected.state.toString()
|
|
/* ponizsze generuje w linijce z ifem: The name '<XFeatureCallImplCustom> == <XFeatureCallImplCustom>' cannot be resolved to an item or type.
|
|
var OnOffType preQL = Mpd_quodlibet_StartStop_expected.state */
|
|
var preQL = Mpd_quodlibet_StartStop_expected.state.toString()
|
|
|
|
logInfo("niegramy", "Restore QL to {}", preQL)
|
|
/* Mpd_quodlibet_StartStop.sendCommand(preQL.toString())*/
|
|
/* nie działa: preQL as StringType
|
|
preQL.toString()
|
|
*/
|
|
if (preQL == "ON") {
|
|
sendCommand(Mpd_quodlibet_StartStop, ON)
|
|
} else {
|
|
// logInfo("niegramy", "Did not restore QL. why?")
|
|
}
|
|
|
|
logInfo("niegramy", "Restore sOWFS01 to {}", preCB)
|
|
/* sOWFS01.sendCommand(preCB) */
|
|
/* sOWFS01.sendCommand(sOWFS01_expected.state.toString()) zakomentowane, bo null instance */
|
|
/* sendCommand(sOWFS01, preCB) */
|
|
if (preCB == "ON") {
|
|
sendCommand(sOWFS01, ON)
|
|
}
|
|
|
|
sBCacheWriteback.sendCommand(OFF)
|
|
end
|
|
|