2 # -*- coding: utf-8 -*-
5 import dbus
, os
, signal
, sys
6 from PyQt4
.QtCore
import QCoreApplication
, QObject
18 def quit_(sig
=0, frame
=0):
22 class CadenceUnityApp(QObject
):
23 def __init__(self
, parent
=None):
24 super(CadenceUnityApp
, self
).__init
__(parent
)
29 self
.TIMER_DBUS
= self
.startTimer(5000)
30 self
.TIMER_LAUNCHER
= self
.startTimer(1000)
32 self
.timer_dbus_check()
33 self
.timer_launcher_check()
35 def timer_dbus_check(self
):
39 def timer_launcher_check(self
):
40 load
= self
.jack_get_load()
41 xruns
= self
.jack_get_xruns()
43 if (load
!= self
._load
):
45 launcher
.set_property("progress", load
/100)
46 launcher
.set_property("progress_visible", True)
48 launcher
.set_property("progress", 0.0)
49 launcher
.set_property("progress_visible", False)
51 if (xruns
!= self
._xruns
):
53 launcher
.set_property("count", xruns
)
54 launcher
.set_property("count_visible", True)
56 launcher
.set_property("count", 0)
57 launcher
.set_property("count_visible", False)
62 def refresh_dbus(self
):
63 DBus
.bus
= dbus
.SessionBus()
66 DBus
.jack
= DBus
.bus
.get_object("org.jackaudio.service", "/org/jackaudio/Controller")
70 def jack_get_load(self
):
73 return DBus
.jack
.GetLoad()
80 def jack_get_xruns(self
):
83 return DBus
.jack
.GetXruns()
90 def timerEvent(self
, event
):
91 if (event
.timerId() == self
.TIMER_DBUS
):
92 self
.timer_dbus_check()
93 elif (event
.timerId() == self
.TIMER_LAUNCHER
):
94 self
.timer_launcher_check()
95 return QObject
.timerEvent(self
, event
)
98 #--------------- main ------------------
99 if __name__
== '__main__':
102 from gi
.repository
import Unity
105 app
= QCoreApplication(sys
.argv
)
106 app
.setApplicationName("Cadence-Unity-Support")
107 app
.setApplicationVersion("0.0.3")
108 app
.setOrganizationName("falkTX")
110 launcher
= Unity
.LauncherEntry
.get_for_desktop_id("cadence.desktop")
112 qtLoop
= CadenceUnityApp()
114 signal
.signal(signal
.SIGTERM
, quit_
)
115 signal
.signal(signal
.SIGINT
, quit_
)