mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 15:37:23 +00:00
update to new process api
This commit is contained in:
parent
8eaf444a25
commit
e81d765098
@ -78,13 +78,13 @@ bool AWActions::isDebugEnabled()
|
||||
}
|
||||
|
||||
|
||||
bool AWActions::runCmd(const QString &_cmd)
|
||||
bool AWActions::runCmd(const QString &_cmd, const QStringList &_args)
|
||||
{
|
||||
qCDebug(LOG_AW) << "Cmd" << _cmd;
|
||||
qCDebug(LOG_AW) << "Cmd" << _cmd << "args" << _args;
|
||||
|
||||
sendNotification(QString("Info"), i18n("Run %1", _cmd));
|
||||
|
||||
return QProcess::startDetached(_cmd);
|
||||
return QProcess::startDetached(_cmd, _args);
|
||||
}
|
||||
|
||||
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
Q_INVOKABLE void checkUpdates(const bool _showAnyway = false);
|
||||
Q_INVOKABLE static QString getFileContent(const QString &_path);
|
||||
Q_INVOKABLE static bool isDebugEnabled();
|
||||
Q_INVOKABLE static bool runCmd(const QString &_cmd);
|
||||
Q_INVOKABLE static bool runCmd(const QString &_cmd, const QStringList &_args);
|
||||
Q_INVOKABLE static void showLegacyInfo();
|
||||
Q_INVOKABLE static void showReadme();
|
||||
// configuration slots
|
||||
|
@ -346,7 +346,7 @@ void ExtScript::startProcess()
|
||||
cmdList.append(prefix());
|
||||
cmdList.append(executable());
|
||||
qCInfo(LOG_LIB) << "Run cmd" << cmdList.join(' ');
|
||||
m_process->start(cmdList.join(' '));
|
||||
m_process->start("sh", QStringList() << "-c" << cmdList);
|
||||
}
|
||||
|
||||
|
||||
|
@ -205,9 +205,8 @@ void ExtUpgrade::writeConfiguration() const
|
||||
|
||||
void ExtUpgrade::startProcess()
|
||||
{
|
||||
QString cmd = QString("sh -c \"%1\"").arg(executable());
|
||||
qCInfo(LOG_LIB) << "Run cmd" << cmd;
|
||||
m_process->start(cmd);
|
||||
qCInfo(LOG_LIB) << "Run cmd" << executable();
|
||||
m_process->start("sh", QStringList() << "-c" << executable());
|
||||
}
|
||||
|
||||
|
||||
|
@ -104,10 +104,11 @@ void GPULoadSource::run()
|
||||
if ((m_device != "nvidia") && (m_device != "ati"))
|
||||
return;
|
||||
// build cmd
|
||||
QString cmd = m_device == "nvidia" ? "nvidia-smi -q -x" : "aticonfig --od-getclocks";
|
||||
QString cmd = m_device == "nvidia" ? "nvidia-smi" : "aticonfig";
|
||||
auto args = m_device == "nvidia" ? QStringList({"-q", "-x"}) : QStringList({"--od-getclocks"});
|
||||
qCInfo(LOG_ESS) << "cmd" << cmd;
|
||||
|
||||
m_process->start(cmd);
|
||||
m_process->start(cmd, args);
|
||||
}
|
||||
|
||||
|
||||
|
@ -83,10 +83,11 @@ void GPUTemperatureSource::run()
|
||||
if ((m_device != "nvidia") && (m_device != "ati"))
|
||||
return;
|
||||
// build cmd
|
||||
QString cmd = m_device == "nvidia" ? "nvidia-smi -q -x" : "aticonfig --od-gettemperature";
|
||||
QString cmd = m_device == "nvidia" ? "nvidia-smi" : "aticonfig";
|
||||
auto args = m_device == "nvidia" ? QStringList({"-q", "-x"}) : QStringList({"--od-gettemperature"});
|
||||
qCInfo(LOG_ESS) << "cmd" << cmd;
|
||||
|
||||
m_process->start(cmd);
|
||||
m_process->start(cmd, args);
|
||||
}
|
||||
|
||||
|
||||
|
@ -32,7 +32,7 @@ HDDTemperatureSource::HDDTemperatureSource(QObject *_parent, const QStringList &
|
||||
qCDebug(LOG_ESS) << __PRETTY_FUNCTION__;
|
||||
|
||||
m_devices = _args.at(0).split(',', Qt::SkipEmptyParts);
|
||||
m_cmd = _args.at(1);
|
||||
m_cmd = _args.at(1).split(' '); // lets hope no one put cmd with spaces here lol
|
||||
|
||||
m_smartctl = m_cmd.contains("smartctl");
|
||||
qCInfo(LOG_ESS) << "Parse as smartctl" << m_smartctl;
|
||||
@ -77,8 +77,12 @@ QVariant HDDTemperatureSource::data(const QString &_source)
|
||||
QString device = _source;
|
||||
device.remove("hdd/temperature");
|
||||
// run cmd
|
||||
if (m_processes[device]->state() == QProcess::NotRunning)
|
||||
m_processes[device]->start(QString("%1 %2").arg(m_cmd).arg(device));
|
||||
if (m_processes[device]->state() == QProcess::NotRunning) {
|
||||
auto cmd = m_cmd.first();
|
||||
auto args = m_cmd.mid(1);
|
||||
args.append(device);
|
||||
m_processes[device]->start(cmd, args);
|
||||
}
|
||||
|
||||
return m_values[device];
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ private:
|
||||
// properties
|
||||
QHash<QString, QProcess *> m_processes;
|
||||
// configuration and values
|
||||
QString m_cmd;
|
||||
QStringList m_cmd;
|
||||
QStringList m_devices;
|
||||
bool m_smartctl;
|
||||
QHash<QString, QVariant> m_values;
|
||||
|
@ -84,7 +84,7 @@ QVariantMap NetworkSource::initialData(const QString &_source) const
|
||||
void NetworkSource::run()
|
||||
{
|
||||
m_values["network/current/name"] = NetworkSource::getCurrentDevice();
|
||||
m_process->start("iwgetid -r");
|
||||
m_process->start("iwgetid", QStringList() << "-r");
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user