blob: d20a99e4b775558768423007a264e3f179a0e1df (
plain) (
blame)
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
|
-- originally written by nilninull
local dpms_mod = nil
local function on_property_change(name, value)
print("RUN on property change", value, dpms_mod)
if dpms_mod == nil and value then
-- This code was checked on xset 1.2.3
if os.execute("[ `xset q | sed -n '/^DPMS/,${/^ DPMS/s/^ DPMS is //p}'` == Enabled ]") == 0 then
dpms_mod = true
else
dpms_mod = false
end
end
end
mp.observe_property("vo-configured", "bool", on_property_change)
local function dpms_mod_stop(event)
if dpms_mod then
os.execute("xset +dpms")
end
end
mp.register_event("shutdown", dpms_mod_stop)
local function dpms_on_play(event)
if dpms_mod then
os.execute("xset -dpms")
end
end
mp.register_event("playback-restart", dpms_on_play)
local function dpms_on_pause(name, value)
if dpms_mod then
if value then
os.execute("xset +dpms")
else
os.execute("xset -dpms")
end
end
end
mp.observe_property("pause", "bool", dpms_on_pause)
|