diff --git a/osx_bundle/misc/bundle/launcher.sh b/osx_bundle/misc/bundle/launcher.sh index b3724bae43..cc7b733cd2 100755 --- a/osx_bundle/misc/bundle/launcher.sh +++ b/osx_bundle/misc/bundle/launcher.sh @@ -45,8 +45,6 @@ fi export PYTHON="$bundle_contents/MacOS/python" export PYTHONHOME="$bundle_res" -# temporary disable multimedia keys -export QUODLIBET_NO_MMKEYS=yes # temporary disable tooltips export QUODLIBET_NO_HINTS=yes diff --git a/quodlibet/docs/development/faq.rst b/quodlibet/docs/development/faq.rst index dbadb1a32d..647b0cae86 100644 --- a/quodlibet/docs/development/faq.rst +++ b/quodlibet/docs/development/faq.rst @@ -122,9 +122,6 @@ QUODLIBET_DEBUG QUODLIBET_NO_TRANS When in the environment disables translations -QUODLIBET_NO_MMKEYS - When in the environment disables multimedia keys support - QUODLIBET_BACKEND Can be set to the audio backend, overriding the value present in the main config file. Useful for quickly testing a different audio backend. diff --git a/quodlibet/quodlibet.py b/quodlibet/quodlibet.py index 85b0bf546f..9348eabd69 100755 --- a/quodlibet/quodlibet.py +++ b/quodlibet/quodlibet.py @@ -174,9 +174,9 @@ def show_backend_error(window): except ImportError: DBusHandler = lambda player, library: None - mmkeys_handler = MMKeysHandler(app.name, window, player) - if "QUODLIBET_NO_MMKEYS" not in os.environ: - mmkeys_handler.start() + mmkeys_handler = MMKeysHandler(app) + mmkeys_handler.start() + current_path = os.path.join(quodlibet.get_user_dir(), "current") fsiface = FSInterface(current_path, player) remote = Remote(app, cmd_registry) diff --git a/quodlibet/quodlibet/config.py b/quodlibet/quodlibet/config.py index d53cadc549..312e1eafd6 100644 --- a/quodlibet/quodlibet/config.py +++ b/quodlibet/quodlibet/config.py @@ -120,6 +120,9 @@ # If set to "true" allow directly deleting files, even on systems that # support sending them to the trash. "bypass_trash": "false", + + # our implementation is buggy and disabled by default + "osx_mmkeys": "false", }, "rename": { "spaces": "false", diff --git a/quodlibet/quodlibet/ext/events/advanced_preferences.py b/quodlibet/quodlibet/ext/events/advanced_preferences.py index f1c1806985..085c57c6fb 100644 --- a/quodlibet/quodlibet/ext/events/advanced_preferences.py +++ b/quodlibet/quodlibet/ext/events/advanced_preferences.py @@ -135,6 +135,12 @@ def changed(entry, name, section="settings"): ("Size of the album cover images in the album list browser " "(restart required)"))) + rows.append( + boolean_config( + "settings", "osx_mmkeys", + "OS X Multimedia Keys:", + "Enable experimental mmkeys support (restart required)")) + for (row, (label, entry, button)) in enumerate(rows): label.set_alignment(1.0, 0.5) table.attach(label, 0, 1, row, row + 1, diff --git a/quodlibet/quodlibet/mmkeys/__init__.py b/quodlibet/quodlibet/mmkeys/__init__.py index 15524f297e..18550ff0b7 100644 --- a/quodlibet/quodlibet/mmkeys/__init__.py +++ b/quodlibet/quodlibet/mmkeys/__init__.py @@ -5,6 +5,8 @@ # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation +from quodlibet import config + from ._base import MMKeysAction, MMKeysImportError @@ -31,12 +33,13 @@ def iter_backends(): else: yield PyHookBackend - try: - from .osx import OSXBackend - except MMKeysImportError: - pass - else: - yield OSXBackend + if config.getboolean("settings", "osx_mmkeys"): + try: + from .osx import OSXBackend + except MMKeysImportError: + pass + else: + yield OSXBackend def find_active_backend(): @@ -52,11 +55,11 @@ class MMKeysHandler(object): events to actions on the player backend. """ - def __init__(self, app_name, window, player): + def __init__(self, app): self._backend = None - self._window = window - self._player = player - self._app_name = app_name + self._window = app.window + self._player = app.player + self._app_name = app.name def start(self): kind = find_active_backend() diff --git a/quodlibet/tests/test_mmkeys.py b/quodlibet/tests/test_mmkeys.py index c55634eb19..36c50efdde 100644 --- a/quodlibet/tests/test_mmkeys.py +++ b/quodlibet/tests/test_mmkeys.py @@ -1,17 +1,20 @@ # -*- coding: utf-8 -*- -from tests import TestCase +from tests import TestCase, init_fake_app, destroy_fake_app -from gi.repository import Gtk - -from quodlibet.player.nullbe import NullPlayer +from quodlibet import app from quodlibet.mmkeys import MMKeysHandler, iter_backends class TMmKeys(TestCase): + def setUp(self): + init_fake_app() + + def tearDown(self): + destroy_fake_app() + def test_handler(self): - win = Gtk.Window() - handler = MMKeysHandler("Foo", win, NullPlayer()) + handler = MMKeysHandler(app) handler.quit() def test_backends(self):