10

When I plug a USB stick or a mobile phone into my laptop, I don't want the operating system to automatically mount the device.
In Ubuntu 14.04 I could run the below command and this would disable automounting of block devices, e.g.

gsettings set org.gnome.desktop.media-handling automount false

In 16.04 this command now seems to have no effect, what is the equivalent command in 16.04?

the_velour_fog
  • 11,840
  • 16
  • 64
  • 109
  • Have you tried it with `dconf-editor`? – garethTheRed May 13 '16 at 06:48
  • @garethTheRed thanks for the comment, per your suggestion, I have now installed `dconf-edittor` . If I try the `gsettings ...` command - dconf-editor recognises the change. I'm not sure if the settings are taking effect at the OS level , testing now... – the_velour_fog May 13 '16 at 07:14
  • Same for me on 16.04 running XFCE. `gsettings get org.gnome.desktop.media-handling automount` returned `true`. After your command it returns `false` but automount still happens. :-( – Stéphane Gourichon Aug 08 '16 at 08:35
  • On Xubuntu 16.04 (xfce) the equivalent command is `xfconf-query -c thunar-volman -n -p "/automount-drives/enabled" -t string -s false ; xfconf-query -c thunar-volman -n -p "/automount-media/enabled" -t string -s false` . This is what `xfce4-settings-manager` does in the "Removal drives and media" section. – Stéphane Gourichon Aug 08 '16 at 09:14
  • @don_crissti that sounds right. IIRC in the time since asking this question I think I discivered the problem was with the environment vars not being set - so the command is likely fine after all. good point checking for mount-ness with lsblk too. – the_velour_fog Sep 28 '16 at 09:19

2 Answers2

8

and for mate desktop its slightly different

gsettings set org.mate.media-handling automount false

its also important to keep in mind that this is a per user setting.
So it is valid only for the current desktop user....

check with:

gsettings list-recursively  org.mate.media-handling

and

gsettings list-recursively  org.gnome.desktop.media-handling 

Due to the mixed nature of the mate desktop (there are always some gnome apps I use) there seem to be some gnome settings leaking into the desktop configuration.
So I always set both parts to make sure.....

U.V.
  • 261
  • 2
  • 6
  • You saved my day! This solution also works on FreeBSD. I was looking for some daemon that would be automounting my devices, but it was the mate desktop! +1 – Giorgio Aug 25 '18 at 07:11
4

After further investigation, which is backed up by several comments on this post, it seems the command

 gsettings set org.gnome.desktop.media-handling automount false

does work as it had previously.
The reason it failed on this occasion seemed to be caused by the lack of environment variables being set, notably $DBUS_SESSION_BUS_ADDRESS.
To re-iterate, the command does work for Ubuntu 16.04 as it had done on 14.04.

the_velour_fog
  • 11,840
  • 16
  • 64
  • 109
  • On my Lubuntu 18.04.4, this doesn't work, and `echo $DBUS_SESSION_BUS_ADDRESS #=> unix:path=/run/user/1000/bus` . Any tips for setting the vars to make it work? – sondra.kinsey May 23 '20 at 12:19