Hello guys, I recently made a bash script to try out auto-updates in flatpak.
Flatpak don't do auto updates and thinking about this post I thought, is it possible with flatpak? every time a have to update flatpaks that I use, I have to go to open the terminal type the command and wait for it to finish. Burning my brain for a few days now (I had no experience before) I made a bash script, using flatpak to run the updates and pgrep and notify-send to get some feedback.

#/bin/sh
icon="-i package-x-generic-symbolic"
runing=$(pgrep flatpak)
if [ $runing <> 0 ]; then
notify-send $icon Faltpak "Flatpak is already running"
else
notify-send $icon Flatpak "Searching and applying updates"
flatpak --user -y update
status=$(echo $?)
if [ $status -eq 0 ]; then
notify-send $icon Flatpak "Flatpaks are up to date"
else
notify-send $icon Flatpak "There were an error updating"
fi
fi

I know it could be optimized to get a few lines less, what do you think? and what can be improve?
I think it's a neat quality of life improve.

    this rocks, thank you. when this gets dialed in I want to use it. Is there a way to make this daily or a couple times a week in the script?

    nolan I had no experience before

    you give me hope🙂

    it is a shell script, I can paste it in gedit save it in /home/user/.local/bin as flatpak-automatic-updater set it as executable, then it can be run as a command in terminal.
    to run it regularly you need to make a timer.
    courtesy of @[deleted] from thist post
    You need to create two files:

    /etc/systemd/system/flatpak-automatic-updater.service

     [Unit]
    Description=Run flatpak update
    
    [Service]
    Type=oneshot
    ExecStart=/home/user/.local/bin/flatpak-automatic-updater

    /etc/systemd/system/eopkg.timer

    [Timer]
    OnBootSec=10min
    OnUnitActiveSec=12h
    Unit=flatpak-automatic-updater.service
    
    [Install]
    WantedBy=multi-user.target  #tis can bee changed if necesary

    Then enable the timer with sudo systemctl enable eopkg.timer --now

    • [deleted]

    • Edited

    No need to do it in such hacky way, one can just run /usr/bin/flatpak update --noninteractive --assumeyes automatically. However, one must consider the security as automatic updates to Flatpaks mean they also may gain additional permissions without the user being aware of the change.

    User flatpaks also need --user flag.

      [deleted] I use this weekly and need to learn how to cron it. (All credit goes to @WetGeek , it's his):
      flatpak update -y && flatpak remove --unused -y ; the unused flag really stays on the debris in the same way eopkg dc or rmo does. (at least that's how I visualize that flag)