diff --git a/src/tomahawk/CMakeLists.txt b/src/tomahawk/CMakeLists.txt
index 636ff2c3c..da07a97c2 100644
--- a/src/tomahawk/CMakeLists.txt
+++ b/src/tomahawk/CMakeLists.txt
@@ -22,6 +22,8 @@ ENDIF()
SET( tomahawkSources ${tomahawkSources}
AclRegistryImpl.cpp
ShortcutHandler.cpp
+ GnomeShortcutHandler.cpp
+ GnomeSettingsDaemonMediaKeysProxy.cpp
UbuntuUnityHack.cpp
TomahawkApp.cpp
main.cpp
diff --git a/src/tomahawk/GnomeSettingsDaemonMediaKeys.xml b/src/tomahawk/GnomeSettingsDaemonMediaKeys.xml
new file mode 100644
index 000000000..9caf240f5
--- /dev/null
+++ b/src/tomahawk/GnomeSettingsDaemonMediaKeys.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/tomahawk/GnomeSettingsDaemonMediaKeysProxy.cpp b/src/tomahawk/GnomeSettingsDaemonMediaKeysProxy.cpp
new file mode 100644
index 000000000..c94b3cc46
--- /dev/null
+++ b/src/tomahawk/GnomeSettingsDaemonMediaKeysProxy.cpp
@@ -0,0 +1,26 @@
+/*
+ * This file was generated by qdbusxml2cpp version 0.7
+ * Command line was: qdbusxml2cpp -p GnomeSettingsDaemonMediaKeysProxy -c GnomeSettingsDaemonMediaKeysProxy GnomeSettingsDaemonMediaKeys.xml
+ *
+ * qdbusxml2cpp is Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+ *
+ * This is an auto-generated file.
+ * This file may have been hand-edited. Look for HAND-EDIT comments
+ * before re-generating it.
+ */
+
+#include "GnomeSettingsDaemonMediaKeysProxy.h"
+
+/*
+ * Implementation of interface class GnomeSettingsDaemonMediaKeysProxy
+ */
+
+GnomeSettingsDaemonMediaKeysProxy::GnomeSettingsDaemonMediaKeysProxy(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent)
+ : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent)
+{
+}
+
+GnomeSettingsDaemonMediaKeysProxy::~GnomeSettingsDaemonMediaKeysProxy()
+{
+}
+
diff --git a/src/tomahawk/GnomeSettingsDaemonMediaKeysProxy.h b/src/tomahawk/GnomeSettingsDaemonMediaKeysProxy.h
new file mode 100644
index 000000000..0336fd3f2
--- /dev/null
+++ b/src/tomahawk/GnomeSettingsDaemonMediaKeysProxy.h
@@ -0,0 +1,64 @@
+/*
+ * This file was generated by qdbusxml2cpp version 0.7
+ * Command line was: qdbusxml2cpp -p GnomeSettingsDaemonMediaKeysProxy -c GnomeSettingsDaemonMediaKeysProxy GnomeSettingsDaemonMediaKeys.xml
+ *
+ * qdbusxml2cpp is Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+ *
+ * This is an auto-generated file.
+ * Do not edit! All changes made to it will be lost.
+ */
+
+#ifndef GNOMESETTINGSDAEMONMEDIAKEYSPROXY_H_1369414808
+#define GNOMESETTINGSDAEMONMEDIAKEYSPROXY_H_1369414808
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+/*
+ * Proxy class for interface org.gnome.SettingsDaemon.MediaKeys
+ */
+class GnomeSettingsDaemonMediaKeysProxy: public QDBusAbstractInterface
+{
+ Q_OBJECT
+public:
+ static inline const char *staticInterfaceName()
+ { return "org.gnome.SettingsDaemon.MediaKeys"; }
+
+public:
+ GnomeSettingsDaemonMediaKeysProxy(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0);
+
+ ~GnomeSettingsDaemonMediaKeysProxy();
+
+public Q_SLOTS: // METHODS
+ inline QDBusPendingReply<> GrabMediaPlayerKeys(const QString &application, uint time)
+ {
+ QList argumentList;
+ argumentList << QVariant::fromValue(application) << QVariant::fromValue(time);
+ return asyncCallWithArgumentList(QLatin1String("GrabMediaPlayerKeys"), argumentList);
+ }
+
+ inline QDBusPendingReply<> ReleaseMediaPlayerKeys(const QString &application)
+ {
+ QList argumentList;
+ argumentList << QVariant::fromValue(application);
+ return asyncCallWithArgumentList(QLatin1String("ReleaseMediaPlayerKeys"), argumentList);
+ }
+
+Q_SIGNALS: // SIGNALS
+ void MediaPlayerKeyPressed(const QString &in0, const QString &in1);
+};
+
+namespace org {
+ namespace gnome {
+ namespace SettingsDaemon {
+ typedef ::GnomeSettingsDaemonMediaKeysProxy MediaKeys;
+ }
+ }
+}
+#endif
diff --git a/src/tomahawk/GnomeShortcutHandler.cpp b/src/tomahawk/GnomeShortcutHandler.cpp
new file mode 100644
index 000000000..6b0494961
--- /dev/null
+++ b/src/tomahawk/GnomeShortcutHandler.cpp
@@ -0,0 +1,111 @@
+/* === This file is part of Tomahawk Player - ===
+ *
+ * Copyright 2013, Florian Richter
+ *
+ * Tomahawk is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Tomahawk is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Tomahawk. If not, see .
+ */
+
+// implement listen on media keys events provided by the gnome settings daemon
+// as documented here:
+// https://github.com/GNOME/gnome-settings-daemon/blob/master/plugins/media-keys/README.media-keys-API
+
+#include "GnomeShortcutHandler.h"
+
+#include "utils/Logger.h"
+
+
+#ifdef QT_DBUS_LIB
+# include
+#endif
+
+#include
+
+using namespace Tomahawk;
+
+const char* GnomeShortcutHandler::kGsdService = "org.gnome.SettingsDaemon";
+const char* GnomeShortcutHandler::kGsdPath = "/org/gnome/SettingsDaemon/MediaKeys";
+const char* GnomeShortcutHandler::kGsdInterface = "org.gnome.SettingsDaemon.MediaKeys";
+
+
+GnomeShortcutHandler::GnomeShortcutHandler(QObject *parent) :
+ Tomahawk::ShortcutHandler(parent),
+ interface_(NULL)
+{
+
+}
+
+bool GnomeShortcutHandler::DoRegister() {
+#ifdef QT_DBUS_LIB
+ tLog(LOGVERBOSE) << "registering for gnome media keys";
+ // Check if the GSD service is available
+ if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(kGsdService)) {
+ tLog(LOGVERBOSE) << "gnome settings daemon not registered";
+ return false;
+ }
+
+ if (!interface_) {
+ interface_ = new GnomeSettingsDaemonMediaKeysProxy(
+ kGsdService, kGsdPath, QDBusConnection::sessionBus(), this->parent());
+ }
+
+ QDBusPendingReply<> reply = interface_->GrabMediaPlayerKeys(
+ QCoreApplication::applicationName(), 0);
+
+ QDBusPendingCallWatcher* watcher = new QDBusPendingCallWatcher(reply, this);
+ connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
+ this, SLOT(RegisterFinished(QDBusPendingCallWatcher*)));
+
+ return true;
+#else // QT_DBUS_LIB
+ tLog(LOGVERBOSE) << "dbus not available";
+ return false;
+#endif
+}
+
+void GnomeShortcutHandler::RegisterFinished(QDBusPendingCallWatcher* watcher) {
+#ifdef QT_DBUS_LIB
+ QDBusMessage reply = watcher->reply();
+ watcher->deleteLater();
+
+ if (reply.type() == QDBusMessage::ErrorMessage) {
+ tLog(LOGVERBOSE) << "Failed to grab media keys"
+ << reply.errorName() < ===
+ *
+ * Copyright 2013, Florian Richter
+ *
+ * Tomahawk is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Tomahawk is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Tomahawk. If not, see .
+ */
+
+#ifndef GNOMESHORTCUTHANDLER_H
+#define GNOMESHORTCUTHANDLER_H
+
+#include "ShortcutHandler.h"
+#include "GnomeSettingsDaemonMediaKeysProxy.h"
+
+#include
+
+namespace Tomahawk {
+
+
+class GnomeShortcutHandler : public ShortcutHandler
+{
+ Q_OBJECT
+public:
+ explicit GnomeShortcutHandler(QObject *parent = 0);
+ bool DoRegister();
+
+ static const char* kGsdService;
+ static const char* kGsdPath;
+ static const char* kGsdInterface;
+
+
+public slots:
+ void RegisterFinished(QDBusPendingCallWatcher* watcher);
+ void GnomeMediaKeyPressed( const QString& application, const QString& key );
+
+private:
+ GnomeSettingsDaemonMediaKeysProxy* interface_;
+
+};
+
+}
+
+#endif // GNOMESHORTCUTHANDLER_H
+
diff --git a/src/tomahawk/TomahawkApp.cpp b/src/tomahawk/TomahawkApp.cpp
index 06f4203bd..a8bdbfd64 100644
--- a/src/tomahawk/TomahawkApp.cpp
+++ b/src/tomahawk/TomahawkApp.cpp
@@ -46,6 +46,7 @@
#include "web/Api_v1.h"
#include "SourceList.h"
#include "ShortcutHandler.h"
+#include "GnomeShortcutHandler.h"
#include "filemetadata/ScanManager.h"
#include "TomahawkSettings.h"
#include "GlobalActionManager.h"
@@ -232,6 +233,12 @@ TomahawkApp::init()
increaseMaxFileDescriptors();
#endif
+#if !defined(Q_WS_MAC) && !defined(Q_WS_WIN)
+ GnomeShortcutHandler *gnomeShortcutHandler = new GnomeShortcutHandler( this );
+ gnomeShortcutHandler->DoRegister();
+ m_shortcutHandler = QPointer( gnomeShortcutHandler );
+#endif
+
// Connect up shortcuts
if ( !m_shortcutHandler.isNull() )
{