From 03574461a9a8bdea01315153ec1a2be594ecfd8e Mon Sep 17 00:00:00 2001 From: arcan1s Date: Sat, 2 Aug 2014 18:36:12 +0400 Subject: [PATCH] update notifications --- sources/ext-sysmon/extsysmon.cpp | 23 +++++++++++----------- sources/ptm/contents/code/ptmnotify.py | 27 +++++++------------------- 2 files changed, 19 insertions(+), 31 deletions(-) diff --git a/sources/ext-sysmon/extsysmon.cpp b/sources/ext-sysmon/extsysmon.cpp index 11f6678..fe00987 100644 --- a/sources/ext-sysmon/extsysmon.cpp +++ b/sources/ext-sysmon/extsysmon.cpp @@ -86,7 +86,7 @@ QString ExtendedSysMon::getAutoGpu() if (qoutput.toLower().contains("nvidia")) gpu = QString("nvidia"); else if (qoutput.toLower().contains("radeon")) - gpu = QString("ati"); + gpu = QString("ati"); if (debug) qDebug() << "[DE]" << "[getAutoGpu]" << ":" << "Device" << gpu; return gpu; @@ -97,17 +97,18 @@ QString ExtendedSysMon::getAutoMpris() { if (debug) qDebug() << "[DE]" << "[getAutoMpris]"; - QProcess command; - QString mpris; - QString cmd = QString("bash -c \"qdbus 'org.mpris.MediaPlayer2.*'\""); - if (debug) qDebug() << "[DE]" << "[getAutoMpris]" << ":" << "Run cmd" << cmd; - command.start(cmd); - command.waitForFinished(-1); - QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput()).trimmed(); - mpris = cmdOutput.split(QChar('\n'))[0].split(QChar('.'))[3]; + QProcess command; + QString mpris; + QString cmd = QString("bash -c \"qdbus 'org.mpris.MediaPlayer2.*'\""); + if (debug) qDebug() << "[DE]" << "[getAutoMpris]" << ":" << "Run cmd" << cmd; + command.start(cmd); + command.waitForFinished(-1); + QString cmdOutput = QTextCodec::codecForMib(106)->toUnicode(command.readAllStandardOutput()).trimmed(); + if (cmdOutput.split(QChar('\n'))[0].split(QChar('.')).count() > 3) + mpris = cmdOutput.split(QChar('\n'))[0].split(QChar('.'))[3]; - if (debug) qDebug() << "[DE]" << "[getAutoMpris]" << ":" << "Player found" << mpris; - return mpris; + if (debug) qDebug() << "[DE]" << "[getAutoMpris]" << ":" << "Player found" << mpris; + return mpris; } diff --git a/sources/ptm/contents/code/ptmnotify.py b/sources/ptm/contents/code/ptmnotify.py index 3359a5c..33af75a 100644 --- a/sources/ptm/contents/code/ptmnotify.py +++ b/sources/ptm/contents/code/ptmnotify.py @@ -144,24 +144,15 @@ class PTMNotify: artist = "N\\A" album = "N\\A" title = "N\\A" - if (len(commands.getoutput("pgrep amarok")) > 0): - player = "amarok" - elif (len(commands.getoutput("pgrep clementine")) > 0): - player = "clementine" - elif (len(commands.getoutput("pgrep mpd")) > 0): + if (len(commands.getoutput("pgrep mpd")) > 0): player = "mpd" - elif (len(commands.getoutput("pgrep qmmp")) > 0): - player = "qmmp" else: - player = "" - if (player == "amarok"): - artist = commands.getoutput("qdbus org.kde.amarok /Player GetMetadata 2> /dev/null | grep albumartist: | cut -c14-") - album = commands.getoutput("qdbus org.kde.amarok /Player GetMetadata 2> /dev/null | grep album: | cut -c8-") - title = commands.getoutput("qdbus org.kde.amarok /Player GetMetadata 2> /dev/null | grep title: | cut -c8-") - elif (player == "clementine"): - artist = commands.getoutput("qdbus org.mpris.clementine /Player GetMetadata 2> /dev/null | grep albumartist: | cut -c14-") - album = commands.getoutput("qdbus org.mpris.clementine /Player GetMetadata 2> /dev/null | grep album: | cut -c8-") - title = commands.getoutput("qdbus org.mpris.clementine /Player GetMetadata 2> /dev/null | grep title: | cut -c8-") + player = "mpris" + if (player == "mpris"): + name = commands.getoutput("qdbus 'org.mpris.MediaPlayer2.*'").split('\n')[0].split('.')[3] + artist = commands.getoutput("qdbus org.mpris." + name + " /Player GetMetadata 2> /dev/null | grep albumartist: | cut -c14-") + album = commands.getoutput("qdbus org.mpris." + name + " /Player GetMetadata 2> /dev/null | grep album: | cut -c8-") + title = commands.getoutput("qdbus org.mpris." + name + " /Player GetMetadata 2> /dev/null | grep title: | cut -c8-") elif (player == "mpd"): output = commands.getoutput("echo 'currentsong\nclose' | curl --connect-timeout 1 -fsm 3 telnet://localhost:6600 2> /dev/null") for line in output.split("\n"): @@ -171,10 +162,6 @@ class PTMNotify: album = line.split(": ")[1] elif (line.split(": ")[0] == "Title"): title = line.split(": ")[1] - elif (player == "qmmp"): - artist = commands.getoutput("qmmp --nowplaying '%if(%p,%p,Unknown)' 2> /dev/null") - album = commands.getoutput("qmmp --nowplaying '%if(%a,%a,Unknown)' 2> /dev/null") - title = commands.getoutput("qmmp --nowplaying '%if(%t,%t,Unknown)' 2> /dev/null") text = text + "Artist: %s\nAlbum: %s\nTitle: %s" % (artist, album, title) except: text = "Something wrong"