mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-25 07:57:19 +00:00
fix player
This commit is contained in:
parent
c0561a95e0
commit
ea287c21b1
@ -176,13 +176,9 @@ void ExtendedSysMon::setProcesses()
|
|||||||
this, SLOT(setUpgradeInfo(int, QProcess::ExitStatus)));
|
this, SLOT(setUpgradeInfo(int, QProcess::ExitStatus)));
|
||||||
}
|
}
|
||||||
// player
|
// player
|
||||||
// two processes because amarok and clementine requires two commands
|
|
||||||
// general
|
|
||||||
processes[QString("player")].append(new QProcess);
|
processes[QString("player")].append(new QProcess);
|
||||||
connect(processes[QString("player")][0], SIGNAL(readyReadStandardOutput()), this, SLOT(setPlayer()));
|
connect(processes[QString("player")][0], SIGNAL(finished(int, QProcess::ExitStatus)),
|
||||||
// addition
|
this, SLOT(setPlayer(int, QProcess::ExitStatus)));
|
||||||
processes[QString("player")].append(new QProcess);
|
|
||||||
connect(processes[QString("player")][1], SIGNAL(readyReadStandardOutput()), this, SLOT(setPlayer()));
|
|
||||||
// ps
|
// ps
|
||||||
// pscount && ps
|
// pscount && ps
|
||||||
processes[QString("ps")].append(new QProcess);
|
processes[QString("ps")].append(new QProcess);
|
||||||
@ -435,21 +431,15 @@ void ExtendedSysMon::getPlayerInfo(const QString playerName,
|
|||||||
QString cmd;
|
QString cmd;
|
||||||
if (playerName == QString("amarok")) {
|
if (playerName == QString("amarok")) {
|
||||||
// amarok
|
// amarok
|
||||||
cmd = QString("qdbus org.kde.amarok /Player GetMetadata");
|
cmd = QString("bash -c \"qdbus org.kde.amarok /Player GetMetadata && qdbus org.kde.amarok /Player PositionGet\"");
|
||||||
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
||||||
processes[QString("player")][0]->start(cmd);
|
processes[QString("player")][0]->start(cmd);
|
||||||
cmd = QString("qdbus org.kde.amarok /Player PositionGet");
|
|
||||||
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
|
||||||
processes[QString("player")][1]->start(cmd);
|
|
||||||
}
|
}
|
||||||
else if (playerName == QString("clementine")) {
|
else if (playerName == QString("clementine")) {
|
||||||
// clementine
|
// clementine
|
||||||
cmd = QString("qdbus org.mpris.clementine /Player GetMetadata");
|
cmd = QString("bash -c \"qdbus org.mpris.clementine /Player GetMetadata && qdbus org.mpris.clementine /Player PositionGet\"");
|
||||||
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
||||||
processes[QString("player")][0]->start(cmd);
|
processes[QString("player")][0]->start(cmd);
|
||||||
cmd = QString("qdbus org.mpris.clementine /Player PositionGet");
|
|
||||||
if (debug) qDebug() << "[DE]" << "[getPlayerInfo]" << ":" << "Run cmd" << cmd;
|
|
||||||
processes[QString("player")][1]->start(cmd);
|
|
||||||
}
|
}
|
||||||
else if (playerName == QString("mpd")) {
|
else if (playerName == QString("mpd")) {
|
||||||
// mpd
|
// mpd
|
||||||
@ -467,9 +457,12 @@ void ExtendedSysMon::getPlayerInfo(const QString playerName,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ExtendedSysMon::setPlayer()
|
void ExtendedSysMon::setPlayer(int exitCode, QProcess::ExitStatus exitStatus)
|
||||||
{
|
{
|
||||||
|
Q_UNUSED(exitStatus)
|
||||||
|
|
||||||
if (debug) qDebug() << "[DE]" << "[setPlayer]";
|
if (debug) qDebug() << "[DE]" << "[setPlayer]";
|
||||||
|
if (debug) qDebug() << "[DE]" << "[setPlayer]" << ":" << "Cmd returns" << exitCode;
|
||||||
QString playerName = configuration[QString("PLAYER")];
|
QString playerName = configuration[QString("PLAYER")];
|
||||||
QString qoutput = QString("");
|
QString qoutput = QString("");
|
||||||
QString qstr = QString("");
|
QString qstr = QString("");
|
||||||
@ -487,7 +480,6 @@ void ExtendedSysMon::setPlayer()
|
|||||||
if (playerName == QString("amarok")) {
|
if (playerName == QString("amarok")) {
|
||||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(processes[QString("player")][0]->readAllStandardOutput());
|
qoutput = QTextCodec::codecForMib(106)->toUnicode(processes[QString("player")][0]->readAllStandardOutput());
|
||||||
if (!qoutput.isEmpty()) {
|
if (!qoutput.isEmpty()) {
|
||||||
if (debug) qDebug() << "[DE]" << "[setPlayer]" << ":" << "Found data for cmd" << 0;
|
|
||||||
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
||||||
qstr = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i];
|
qstr = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i];
|
||||||
if (qstr.split(QString(": "), QString::SkipEmptyParts).count() > 1) {
|
if (qstr.split(QString(": "), QString::SkipEmptyParts).count() > 1) {
|
||||||
@ -500,22 +492,16 @@ void ExtendedSysMon::setPlayer()
|
|||||||
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("title"))
|
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("title"))
|
||||||
info[4] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
info[4] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
||||||
}
|
}
|
||||||
}
|
else {
|
||||||
}
|
int time = qstr.toInt() / 1000;
|
||||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(processes[QString("player")][1]->readAllStandardOutput());
|
info[2] = QString::number(time);
|
||||||
if (!qoutput.isEmpty()) {
|
}
|
||||||
if (debug) qDebug() << "[DE]" << "[setPlayer]" << ":" << "Found data for cmd" << 1;
|
|
||||||
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
|
||||||
qstr = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i];
|
|
||||||
int time = qstr.toInt() / 1000;
|
|
||||||
info[2] = QString::number(time);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (playerName == QString("clementine")) {
|
else if (playerName == QString("clementine")) {
|
||||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(processes[QString("player")][0]->readAllStandardOutput());
|
qoutput = QTextCodec::codecForMib(106)->toUnicode(processes[QString("player")][0]->readAllStandardOutput());
|
||||||
if (!qoutput.isEmpty()) {
|
if (!qoutput.isEmpty()) {
|
||||||
if (debug) qDebug() << "[DE]" << "[setPlayer]" << ":" << "Found data for cmd" << 0;
|
|
||||||
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
||||||
qstr = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i];
|
qstr = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i];
|
||||||
if (qstr.split(QString(": "), QString::SkipEmptyParts).count() > 1) {
|
if (qstr.split(QString(": "), QString::SkipEmptyParts).count() > 1) {
|
||||||
@ -528,15 +514,10 @@ void ExtendedSysMon::setPlayer()
|
|||||||
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("title"))
|
else if (qstr.split(QString(": "), QString::SkipEmptyParts)[0] == QString("title"))
|
||||||
info[4] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
info[4] = qstr.split(QString(": "), QString::SkipEmptyParts)[1].trimmed();
|
||||||
}
|
}
|
||||||
}
|
else {
|
||||||
}
|
int time = qstr.toInt() / 1000;
|
||||||
qoutput = QTextCodec::codecForMib(106)->toUnicode(processes[QString("player")][1]->readAllStandardOutput());
|
info[2] = QString::number(time);
|
||||||
if (!qoutput.isEmpty()) {
|
}
|
||||||
if (debug) qDebug() << "[DE]" << "[setPlayer]" << ":" << "Found data for cmd" << 1;
|
|
||||||
for (int i=0; i<qoutput.split(QChar('\n'), QString::SkipEmptyParts).count(); i++) {
|
|
||||||
qstr = qoutput.split(QChar('\n'), QString::SkipEmptyParts)[i];
|
|
||||||
int time = qstr.toInt() / 1000;
|
|
||||||
info[2] = QString::number(time);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ private slots:
|
|||||||
void setGpuTemp(int exitCode, QProcess::ExitStatus exitStatus);
|
void setGpuTemp(int exitCode, QProcess::ExitStatus exitStatus);
|
||||||
void setHddTemp(int exitCode, QProcess::ExitStatus exitStatus);
|
void setHddTemp(int exitCode, QProcess::ExitStatus exitStatus);
|
||||||
void setUpgradeInfo(int exitCode, QProcess::ExitStatus exitStatus);
|
void setUpgradeInfo(int exitCode, QProcess::ExitStatus exitStatus);
|
||||||
void setPlayer();
|
void setPlayer(int exitCode, QProcess::ExitStatus exitStatus);
|
||||||
void setPs();
|
void setPs();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user