forked from ralph-irving/tcz-jivelite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pcp-JiveMain-lua.patch
87 lines (82 loc) · 3.17 KB
/
pcp-JiveMain-lua.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
Index: share/jive/jive/JiveMain.lua
===================================================================
--- share/jive/jive/JiveMain.lua (revision 783)
+++ share/jive/jive/JiveMain.lua (working copy)
@@ -18,6 +18,9 @@
=cut
--]]
+-----------------------------------------------------------------------------------------
+local io = require("io")
+-----------------------------------------------------------------------------------------
-- stuff we use
local math = require("math")
@@ -195,7 +198,19 @@
--already in the desired state, leave (can happen for instance when notify_playerPower comes back after a local power change)
return
end
+-----------------------------------------------------------------------------------------
+ local isPiDisplay = _read("/sys/class/backlight/rpi_backlight/brightness")
+
+ local backlightBrightness = appletManager:callService("getBacklightBrightnessWhenOn")
+ if backlightBrightness == nil then
+ backlightBrightness = "255"
+ end
+ local reducedBacklightBrightness = appletManager:callService("getBacklightBrightnessWhenOff")
+ if reducedBacklightBrightness == nil then
+ reducedBacklightBrightness = "130"
+ end
+-----------------------------------------------------------------------------------------
_softPowerState = softPowerState
local currentPlayer = appletManager:callService("getCurrentPlayer")
if _softPowerState == "off" then
@@ -203,6 +218,11 @@
if currentPlayer and (currentPlayer:isConnected() or currentPlayer:isLocal()) then
currentPlayer:setPower(false, nil, isServerRequest)
end
+-----------------------------------------------------------------------------------------
+ if isPiDisplay ~= nil then
+ _write("/sys/class/backlight/rpi_backlight/brightness", reducedBacklightBrightness)
+ end
+-----------------------------------------------------------------------------------------
--todo: also pause/power off local player since local player might be playing and not be the current player
appletManager:callService("activateScreensaver", isServerRequest)
elseif _softPowerState == "on" then
@@ -215,7 +235,11 @@
end
currentPlayer:setPower(true, nil, isServerRequest)
end
-
+-----------------------------------------------------------------------------------------
+ if isPiDisplay ~= nil then
+ _write("/sys/class/backlight/rpi_backlight/brightness", backlightBrightness)
+ end
+-----------------------------------------------------------------------------------------
appletManager:callService("deactivateScreensaver")
appletManager:callService("restartScreenSaverTimer")
@@ -224,6 +248,27 @@
end
end
+-----------------------------------------------------------------------------------------
+function _write(file, val)
+ local fh, err = io.open(file, "w")
+ if err then
+ return
+ end
+ fh:write(val)
+ fh:close()
+end
+
+function _read(file)
+ local fh, err = io.open(file, "r")
+ if err then
+ return nil
+ end
+ local fc = fh:read("*all")
+ fh:close()
+ return fc
+end
+-----------------------------------------------------------------------------------------
+
function JiveMain:togglePower()
local powerState = JiveMain:getSoftPowerState()
if powerState == "off" then