2

I am running Ubuntu 14.04 with LTSP. I am using usbmount to mount usb thumbdrives outside of the desktop which works great. The problem is that when a user is logged into the desktop and connects a thumbdrive they are shown an error alert box similar to

"Unable to mount Lexar.  Device /dev/sda1 is already mounted at '/media/usb0'.

I've been able to stop the issue for the logged in user account with gsettings. How can I achieve

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

for all users from the command line?

I've tried a udev rule like suggested here but that did not fix the issue


update #1

So I tried using Upstart Session jobs without any luck.

$ cat /usr/share/upstart/sessions/ltsp-replace-usb-automount-with-usbmount.conf
description "disable default automounting because it displays error boxes to the end user"
start on desktop-session-start
script
  gsettings set org.gnome.desktop.media-handling automount false
end script

and also

$ cat /usr/share/upstart/sessions/ltsp-replace-usb-automount-with-usbmount.conf
description "disable default automounting because it displays error boxes to the end user"
start on desktop-start
script
  gsettings set org.gnome.desktop.media-handling automount false
end script

I cannot find any indication the jobs actually ran.

user319862
  • 226
  • 1
  • 8

1 Answers1

4

I've solved the problem with what feels like a dirty hack. If anyone can provide a better answer, please share. Otherwise I am going to mark this as the correct answer eventually.

Create an autostart launcher for the desktop that runs gsettings. Example as follows:

$ cat /etc/xdg/autostart/gsettings-for-all-users.desktop
[Desktop Entry]
Type=Application
Name=gsettings For All Users
Exec=gsettings set org.gnome.desktop.media-handling automount false
Icon=system-run
X-GNOME-Autostart-enabled=true

Reference:

  1. https://unix.stackexchange.com/questions/122424/execute-a-command-on-user-logon

  2. http://xmodulo.com/how-to-automatically-run-script-when-logging-into-ubuntu-desktop.html

user319862
  • 226
  • 1
  • 8
  • Try this: http://askubuntu.com/a/301133/367165 – A.B. May 04 '15 at 08:09
  • Thank you for the suggestion, but after looking that over I do not think it achieves what I am trying to do. I need the fix to work with arbitrary thumbdrives. I did try using a udev rule linked to in the top question but couldn't get it to work. My problem is that the desktop tries to automount the user's usb stick a second time after I have already mounted it with a script in the background. This second attempt causes the desktop to display an error to the user. I just want to stop the second mount attempt by the desktop. – user319862 May 04 '15 at 13:35
  • I think your idea is not bad +1. – A.B. May 04 '15 at 13:38
  • However, it can be easily circumvented. – A.B. May 04 '15 at 13:44