-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatusd_amarok.lua
51 lines (39 loc) · 1.03 KB
/
statusd_amarok.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
-- statusd_amarok.lua : Mark Tran <[email protected]>
-- Display current track from Amarok
if not statusd_amarok then
statusd_amarok = { interval = 3*1000 }
end
local function amarok_dcop()
local f = io.popen('dcop amarok player nowPlaying 2> /dev/null', 'r')
local amarok = f:read('*l')
f:close()
return amarok
end
local function amarok_status()
local f = io.popen('dcop amarok player status 2> /dev/null', 'r')
local status = f:read('*l')
f:close()
return status
end
local function change_display()
local status = amarok_status()
if status == "0" then
return ""
elseif status == "1" then
local amarok = amarok_dcop()
if (amarok ~= nil) then
return amarok.." (paused)"
end
elseif status == "2" then
return amarok_dcop()
else
return ""
end
end
local amarok_timer
local function update_amarok()
statusd.inform("amarok", change_display())
amarok_timer:set(statusd_amarok.interval, update_amarok)
end
amarok_timer = statusd.create_timer()
update_amarok()