I’ve 2 network drives on one subnet (nfs and samba). I would like to access them only if computer is connected to particular ssid (subnet).
I’m using gnome primarily. And files stops responding if mount points can’t be accessed. There is no real way to recover from this apart from connecting to network, unmount and then change network.
I would like those drives to be accessed by system only if they are reachable.
[EDIT][UPDATE]:
Following suggestions from comments. I’ve tried systemd and autofs methods both of them don’t work the way I’ve setup access to mounts.
If mount point is in home OR bookmarks in files app, it would hang up as soon as network is disconnected.
It works well when mount points are not visible by default (for e.g. /smb/share1). Currently using autofs <- easy and short to setup with mount points under /smb and /nfs


Maybe look into autofs which will mount only when you choose to access the drives and then unmount on idle. Could be simpler then trying to react to network status.
https://wiki.archlinux.org/title/Autofs
updated OP
How frustrating about the hangs, looks like this has been a problem for years in various desktops and file managers and you’ve already found the best mitigation (keeping the mounts out of home)
Bookmarking this location in file manager also causes problem.
Thanks will have a look at autofs
I second this. autofs is was I’d recommend.