diff --git a/scripts/makeappimage.sh b/scripts/makeappimage.sh index 0a376cc..0cacade 100755 --- a/scripts/makeappimage.sh +++ b/scripts/makeappimage.sh @@ -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 diff --git a/src/MpvPlayerBackend.cpp b/src/MpvPlayerBackend.cpp index b467163..0a2a722 100644 --- a/src/MpvPlayerBackend.cpp +++ b/src/MpvPlayerBackend.cpp @@ -468,6 +468,12 @@ MpvPlayerBackend::updateDurationString() getProperty("speed").toString())); } +void +MpvPlayerBackend::updateAppImage() +{ + update(); +} + void MpvPlayerBackend::handle_mpv_event(mpv_event* event) { diff --git a/src/MpvPlayerBackend.h b/src/MpvPlayerBackend.h index 06eaa48..a7960a6 100644 --- a/src/MpvPlayerBackend.h +++ b/src/MpvPlayerBackend.h @@ -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); diff --git a/src/main.cpp b/src/main.cpp index 599514b..98d29fc 100644 --- a/src/main.cpp +++ b/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(); } } diff --git a/src/qml/MainMenu.qml b/src/qml/MainMenu.qml index 08c36db..027435c 100644 --- a/src/qml/MainMenu.qml +++ b/src/qml/MainMenu.qml @@ -217,6 +217,10 @@ MenuBar { onTriggered: Qt.quit() shortcut: keybinds.quit } + Action { + text: "Update" + onTriggered: player.updateAppImage() + } } CustomMenu { diff --git a/src/utils.cpp b/src/utils.cpp index b2d92e0..7cb9485 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -1,7 +1,10 @@ #include "utils.hpp" #include +#include #include +#include +#include #include QString @@ -11,6 +14,20 @@ getPlatformName() qobject_cast(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 diff --git a/src/utils.hpp b/src/utils.hpp index 8af9fff..88c5b6a 100644 --- a/src/utils.hpp +++ b/src/utils.hpp @@ -7,5 +7,7 @@ void SetDPMS(bool on); void AlwaysOnTop(WId wid, bool on); +void +update(); #endif