forked from weakish/kwplayer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kwplayer
executable file
·41 lines (31 loc) · 962 Bytes
/
kwplayer
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
#!/usr/bin/env python3
# Copyright (C) 2013-2014 LiuLang <gsushzhsosgsu@gmail.com>
# Use of this source code is governed by GPLv3 license that can be found
# in the LICENSE file.
import sys
import dbus
from gi.repository import Gtk
BUS_NAME = 'org.mpris.MediaPlayer2.kwplayer'
MPRIS_PATH = '/org/mpris/MediaPlayer2'
ROOT_IFACE = 'org.mpris.MediaPlayer2'
def check_loaded():
'''Check kwplayer is loaded or not.
If kwplayer is running, raise kwplayer window and return True,
otherwise return False.'''
sb = dbus.SessionBus()
try:
kw_proxy = sb.get_object(BUS_NAME, MPRIS_PATH)
prop = dbus.Interface(kw_proxy, ROOT_IFACE)
prop.Raise()
return True
except dbus.exceptions.DBusException:
return False
def load_app():
from kuwo.App import App
app = App()
sys.exit(app.run(sys.argv))
def main():
if not check_loaded():
load_app()
if __name__ == '__main__':
main()