Merge pull request #407 from jodal/feature/mpris-needs-display
Turn off MPRIS if no $DISPLAY available
This commit is contained in:
commit
3601b4e687
@ -1,5 +1,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
import mopidy
|
import mopidy
|
||||||
from mopidy import exceptions, ext
|
from mopidy import exceptions, ext
|
||||||
from mopidy.utils import formatting, config
|
from mopidy.utils import formatting, config
|
||||||
@ -89,6 +91,10 @@ class Extension(ext.Extension):
|
|||||||
return schema
|
return schema
|
||||||
|
|
||||||
def validate_environment(self):
|
def validate_environment(self):
|
||||||
|
if 'DISPLAY' not in os.environ:
|
||||||
|
raise exceptions.ExtensionError(
|
||||||
|
'An X11 $DISPLAY is needed to use D-Bus')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import dbus # noqa
|
import dbus # noqa
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
|
|
||||||
import pykka
|
import pykka
|
||||||
|
|
||||||
@ -10,10 +11,14 @@ from mopidy.frontends.mpris import objects
|
|||||||
logger = logging.getLogger('mopidy.frontends.mpris')
|
logger = logging.getLogger('mopidy.frontends.mpris')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import indicate
|
indicate = None
|
||||||
except ImportError as import_error:
|
if 'DISPLAY' in os.environ:
|
||||||
indicate = None # noqa
|
import indicate
|
||||||
logger.debug('Startup notification will not be sent (%s)', import_error)
|
except ImportError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if indicate is None:
|
||||||
|
logger.debug('Startup notification will not be sent')
|
||||||
|
|
||||||
|
|
||||||
class MprisFrontend(pykka.ThreadingActor, CoreListener):
|
class MprisFrontend(pykka.ThreadingActor, CoreListener):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user