[Backend+Scripts] Make appimage updating easier.
This commit is contained in:
parent
074ced6844
commit
9c51bb3ad3
|
@ -18,7 +18,7 @@ mkdir -p appdir/usr/lib
|
|||
if [ "$ARCH" == "" ]; then
|
||||
ARCH="x86_64"
|
||||
fi
|
||||
wget https://github.com/AppImage/AppImageUpdate/releases/download/continuous/appimageupdatetool-x86_64.AppImage -O appdir/usr/bin/appimageupdatetool
|
||||
wget https://github.com/AppImage/AppImageUpdate/releases/download/continuous/AppImageUpdate-x86_64.AppImage -O appdir/usr/bin/appimageupdatetool
|
||||
chmod +x appdir/usr/bin/appimageupdatetool
|
||||
|
||||
wget https://yt-dl.org/downloads/latest/youtube-dl -O appdir/usr/bin/youtube-dl
|
||||
|
|
|
@ -468,6 +468,12 @@ MpvPlayerBackend::updateDurationString()
|
|||
getProperty("speed").toString()));
|
||||
}
|
||||
|
||||
void
|
||||
MpvPlayerBackend::updateAppImage()
|
||||
{
|
||||
update();
|
||||
}
|
||||
|
||||
void
|
||||
MpvPlayerBackend::handle_mpv_event(mpv_event* event)
|
||||
{
|
||||
|
|
|
@ -30,11 +30,12 @@ public:
|
|||
virtual Renderer* createRenderer() const;
|
||||
|
||||
public slots:
|
||||
// All 4 required for Player API
|
||||
// All 5 required for Player API
|
||||
QVariant playerCommand(const Enums::Commands& command, const QVariant& args);
|
||||
QVariant playerCommand(const Enums::Commands& command);
|
||||
void launchAboutQt();
|
||||
void toggleOnTop();
|
||||
void updateAppImage();
|
||||
// Optional but handy for MPV or custom backend settings.
|
||||
void command(const QVariant& params);
|
||||
void setProperty(const QString& name, const QVariant& value);
|
||||
|
|
18
src/main.cpp
18
src/main.cpp
|
@ -76,6 +76,12 @@ main(int argc, char* argv[])
|
|||
if (json["target_commitish"].toString().endsWith(current_version) == 0) {
|
||||
qDebug() << "Latest Version: " << json["target_commitish"].toString();
|
||||
qDebug() << "Update Available. Please update ASAP.";
|
||||
QProcess notifier;
|
||||
notifier.setProcessChannelMode(QProcess::ForwardedChannels);
|
||||
notifier.start("notify-send",
|
||||
QStringList()
|
||||
<< "KittehPlayer" << "New update avalable!" << "--icon=KittehPlayer";
|
||||
notifier.waitForFinished();
|
||||
}
|
||||
} else {
|
||||
qDebug() << "Couldn't check for new version.";
|
||||
|
@ -87,17 +93,7 @@ main(int argc, char* argv[])
|
|||
app.setApplicationName("KittehPlayer");
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
if (!qstrcmp(argv[i], "--update")) {
|
||||
QString program =
|
||||
QProcessEnvironment::systemEnvironment().value("APPDIR", "") +
|
||||
"/usr/bin/appimageupdatetool";
|
||||
QProcess updater;
|
||||
updater.setProcessChannelMode(QProcess::ForwardedChannels);
|
||||
updater.start(program,
|
||||
QStringList()
|
||||
<< QProcessEnvironment::systemEnvironment().value(
|
||||
"APPIMAGE", ""));
|
||||
updater.waitForFinished();
|
||||
exit(0);
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -217,6 +217,10 @@ MenuBar {
|
|||
onTriggered: Qt.quit()
|
||||
shortcut: keybinds.quit
|
||||
}
|
||||
Action {
|
||||
text: "Update"
|
||||
onTriggered: player.updateAppImage()
|
||||
}
|
||||
}
|
||||
|
||||
CustomMenu {
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
#include "utils.hpp"
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QGuiApplication>
|
||||
#include <QProcessEnvironment>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QtCore>
|
||||
|
||||
QString
|
||||
|
@ -11,6 +14,20 @@ getPlatformName()
|
|||
qobject_cast<QGuiApplication*>(QCoreApplication::instance());
|
||||
return qapp->platformName();
|
||||
}
|
||||
void
|
||||
update()
|
||||
{
|
||||
QString program =
|
||||
QProcessEnvironment::systemEnvironment().value("APPDIR", "") +
|
||||
"/usr/bin/appimageupdatetool";
|
||||
QProcess updater;
|
||||
updater.setProcessChannelMode(QProcess::ForwardedChannels);
|
||||
updater.start(program,
|
||||
QStringList() << QProcessEnvironment::systemEnvironment().value(
|
||||
"APPIMAGE", ""));
|
||||
updater.waitForFinished();
|
||||
qApp->exit();
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
#include <QX11Info>
|
||||
|
|
|
@ -7,5 +7,7 @@ void
|
|||
SetDPMS(bool on);
|
||||
void
|
||||
AlwaysOnTop(WId wid, bool on);
|
||||
void
|
||||
update();
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue