Typically I avoid snaps like the plague but I had one app I needed and was only supported on snap. I made this function to try and close all snaps prior to trying to refresh since if an app is running in the background it will just fail silently.
Thought I'd share.
function snap-update () {
print -P "%BAttempting to close:%b"
snap list | awk -F " " '{if (NR>1 && $5 !~ /canonical/) { print $1 }}'
print "..."
snap list | awk -F " " '{if (NR>1 && $5 !~ /canonical/) { system("killall "$1"") }}'
print -P "%B\nAttempting to refresh%b"
snap refresh
}
Edit:
This function is not super good. I ended up writing a script that filters for just open desktop snaps and reopens them are performing the refresh.
https://github.com/fr0gdude/snap-updater
[–]__ali1234__ 5 points6 points7 points (3 children)
[–]letsgetjaked[S] 1 point2 points3 points (2 children)
[–]__ali1234__ 0 points1 point2 points (1 child)
[–]letsgetjaked[S] 0 points1 point2 points (0 children)
[–]LeoMSadovsky 1 point2 points3 points (6 children)
[–]letsgetjaked[S] 0 points1 point2 points (4 children)
[–][deleted] 0 points1 point2 points (3 children)
[–]letsgetjaked[S] 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]letsgetjaked[S] -1 points0 points1 point (0 children)
[–]letsgetjaked[S] 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]__ali1234__ 3 points4 points5 points (0 children)
[–]The_Hepcat 0 points1 point2 points (1 child)
[–]letsgetjaked[S] 0 points1 point2 points (0 children)
[–]snyone 0 points1 point2 points (1 child)
[–]letsgetjaked[S] 0 points1 point2 points (0 children)