In the previous post, I mentioned that I kept an eye on the network traffic on my LTE connection on my laptop. I’ve been bitten hard (It updated IntelliJ IDEA, several hundred megabytes) by snap’s autorefresh feature, which have seemed hard/impossible to disable. There’s been config options for only allowing updates at certain times etc., but the feature I’ve been crying for, to be able to disable it when on a metered connection, has been missing in action. Until now!

$ snap set system refresh.metered=hold

Easy as that!

(Found it here - otherwise not much info about this around the web) UPDATE 2020-02-11: Link is dead, but this is in the official documentation here

Seems quite recent, introduced in snapd 2.33, which was released on 2018-06-25.

So how does it work? How do I confirm that it’s actually working? No feedback when running the command, nothing in syslog.

Hmm.

Only one thing to do; use the source, Luke!

From the source, I can see that it reads the DBus property org.freedesktop.NetworkManager.Metered for a value, and decides what to do based on that.

const ( 
        // https://developer.gnome.org/NetworkManager/stable/nm-dbus-types.html#NMMetered
        NetworkManagerMeteredUnknown  = 0
        NetworkManagerMeteredYes      = 1
        NetworkManagerMeteredNo       = 2
        NetworkManagerMeteredGuessYes = 3
        NetworkManagerMeteredGuessNo  = 4
)

If it’s a NetworkManagerMeteredYes or NetworkManagerMeteredGuessYes, it will disable autorefresh.

I then read the DBus property with the tool D-Feet, and confirmed that the value returned was ‘3’ when on LTE, and ‘4’ on Wi-fi. Wow, this actually seems to work!

While I would prefer more information about this (regular users will NEVER find it, and it is default off), and more logging, I’ll take this for now!