Skip to content

Commit

Permalink
Allow check update and restart within flatpak.
Browse files Browse the repository at this point in the history
  • Loading branch information
wengxt committed Apr 30, 2022
1 parent 6d8e39a commit 9d0fad6
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/lib/fcitx/instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,8 @@ class InstancePrivate : public QPtrHolder<Instance> {
AddonInstance *notifications_ = nullptr;

std::string lastGroup_;

const bool inFlatpak_ = fs::isreg("/.flatpak-info");
};

InputState::InputState(InstancePrivate *d, InputContext *ic)
Expand Down Expand Up @@ -1445,12 +1447,17 @@ void Instance::initialize() {
save();
if (d->restart_) {
auto fcitxBinary = StandardPath::fcitxPath("bindir", "fcitx5");
std::vector<char> command{fcitxBinary.begin(), fcitxBinary.end()};
command.push_back('\0');
char *const argv[] = {command.data(), nullptr};
execv(argv[0], argv);
perror("Restart failed: execvp:");
_exit(1);
if (d->inFlatpak_) {
startProcess({"flatpak-spawn", fcitxBinary, "-r"});
} else {
std::vector<char> command{fcitxBinary.begin(),
fcitxBinary.end()};
command.push_back('\0');
char *const argv[] = {command.data(), nullptr};
execv(argv[0], argv);
perror("Restart failed: execvp:");
_exit(1);
}
}
return false;
});
Expand Down Expand Up @@ -2398,7 +2405,8 @@ void Instance::showInputMethodInformation(InputContext *ic) {

bool Instance::checkUpdate() const {
FCITX_D();
return d->addonManager_.checkUpdate() || d->imManager_.checkUpdate() ||
return (d->inFlatpak_ && fs::isreg("/app/.updated")) ||
d->addonManager_.checkUpdate() || d->imManager_.checkUpdate() ||
postEvent(CheckUpdateEvent());
}

Expand Down

0 comments on commit 9d0fad6

Please sign in to comment.