Tag Archives: bash

flaticron: Send mail notifications for pending Flatpak updates

Some software packages on a typical Linux desktop setup are no longer installed by the package manager of the distribution, but instead are managed with Flatpak. This approach has become more popular over the last years and allows for shorter release cycles in which updates reach users.

My problem with Flatpak was that I regularly did not benefit from these shorter release cycles, because I was not even aware of an available update. Users of desktop environments such as GNOME have Flatpak integrated into the usual graphical software updater. However, as a user of Xfce and strictly using the terminal for managing packages on my desktop systems, I never received any hint on available Flatpak updates.

For pending updates of distribution packages, I use apticron to receive such notifications automatically via mail. As I couldn’t find any existing solution to receive notifications about pending Flatpak updates via mail as well, I wrote flaticron.

GitHub: https://github.com/raimue/flaticron/

An example report sent by flaticron looks like this:

flaticron report [Thu, 28 Mar 2024 18:36:36 +0100]
========================================================================

flaticron has detected that some flatpaks need updating on:

  ferret

The following flatpaks are currently pending an update:

  org.freedesktop.Platform.GL.default              22.08        flathub
  org.freedesktop.Platform.GL.default              22.08-extra  flathub
  org.freedesktop.Platform.GL.default              23.08        flathub
  org.freedesktop.Platform.GL.default              23.08-extra  flathub
  org.freedesktop.Platform.VAAPI.Intel             22.08        flathub
  org.freedesktop.Platform.VAAPI.Intel             23.08        flathub
  org.freedesktop.Platform.ffmpeg-full             23.08        flathub
  org.freedesktop.Platform                         23.08        flathub
  org.gnome.Platform                               44           flathub
  org.gnome.Platform                               45           flathub

========================================================================

You can perform the update by issuing the command:

  flatpak update

as raimue on ferret

-- 
flaticron

The format of the report is very similar to what is generated by apticron, so it should feel familiar for existing users. The prerequisite for mail notifications is that you have a working MTA on your system.

flaticron is available as a Debian package and can be downloaded and installed from the latest GitHub release. If flaticron gains at least some popularity, I might look into getting this into the official Debian repositories. Let me know if you would be interested.

If you are a Flatpak user, I hope flaticron will be a useful tool for you to get notified about pending updates via mail.

Interactive git rebase with non-interactive editing

When working with git and especially GitHub, I often have commits on my local branch that were already submitted as a pull request. Sometimes I continue working and later notice that I have commits on the branch that have nothing to do with the next thing I am already working on. Therefore I want to remove them from the current branch.

$ git log --oneline @{upstream}..
e159d1e Commit C
70140e3 Commit B
16ed14a Commit A

Continue reading

tmux update-environment

tmux is one of the tools I use everyday. But one thing always annoyed me: even though I am using X11 forwarding and ssh-agent forwarding when re-attaching to a session, the DISPLAY and SSH_AUTH_SOCK environment variables are often wrong. Environment variables are initialized only once when the window was created. tmux is able to update some environment variables for new windows and panes based on the update-environment setting, however, existing shell windows cannot be updated.

Continue reading

bash: for-loop with glob patterns

It is common to use a for-loop with glob patterns:

for i in *.txt; do
    mv $i $i.old
done

But if the glob pattern does not match anything it will be preserved unchanged in the command. This results in command execution of mv *.txt *.txt.old which fails because no file named *.txt (literally!) exists.

As this is not the desired behavior, here is a way how to do this as expected without forking using the nullglob bash shell option.

oldnullglob=$(shopt -p nullglob)
shopt -s nullglob

for i in *.txt; do
    mv $i $i.old
done

eval "$oldnullglob" 2>/dev/null
unset oldnullglob

This will silently prevent the execution of the mv command. If you use failglob instead of nullglob bash will interrupt the evaluation of any command if the glob pattern did not match anything.

Disclaimer: Be careful with this option, as this will not be the expected behavior in all cases. Most (in)famously it breaks bash-completion if you set it in your interactive bash session. I suggest to use it temporary only.