-
Notifications
You must be signed in to change notification settings - Fork 6
/
test.lua
72 lines (64 loc) · 1.92 KB
/
test.lua
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
local dbus = require('lua-dbus')
local sleep = require('socket').sleep
print "init"
dbus.init()
print "listen"
-- dbus.on('StatusChanged', function (status, data)
-- if _it then
-- print('StatusChanged', status, require('util').dump(data))
-- else
-- print('StatusChanged', status, data)
-- end
-- end, { bus = 'system', interface = 'org.wicd.daemon' })
dbus.on('NameOwnerChanged', function (...)
print("NameOwnerChanged", ...)
end, { bus = 'session', interface = 'org.freedesktop.DBus' })
print "loop"
local loop = function ()
-- print 'poll'
dbus.poll()
-- print 'sleep'
sleep(0.3)
end
if process then
print "use it"
process.loop = loop
process.setup = function ()
print "call method"
dbus.call('GetCategories', function (cats)
if _it then
print("categories =", require('util').dump(cats))
else
print("categories =", cats)
end
end, {
destination = 'org.gnome.Hamster',
interface = 'org.gnome.Hamster',
path = '/org/gnome/Hamster',
bus = 'session',
})
print "call method2"
dbus.call('forceOnNetworkChange', function (...)
print("forceOnNetworkChange", ...)
end, {
destination = 'org.kde.kdeconnectd',
interface = 'org.kde.kdeconnect.daemon',
path = '/modules/kdeconnect',
bus = 'session',
})
print "list property changes"
dbus.property.on('PlaybackStatus', function (status)
print("PlaybackStatus changed", status)
end, {
interface = 'org.mpris.MediaPlayer2.Player',
sender = 'org.mpris.MediaPlayer2.clementine',
})
foobar = require('lua-dbus.interface').test()
end
process:on('exit', dbus.exit)
else
while true do
loop()
end
dbus.exit()
end