I've been looking into gconf and have so many questions I don't know
which to ask first.

But let's start with the simple case: how do I check the state of
automounting and turn off automounting from the command line?

Here's how I went about it:

[1] $ man gconftool-2

[2] $ gconftool-2 -a
Must specify one or more directories to get key/value pairs from.

[3] $ gconftool-2 -a /

[4] $ gconftool-2 -Ra
--recursive-list should not be used with --get, --set, --unset,
--all-entries, --all-dirs, or --search-key

[5] $ gconftool-2 -R / | head
 /desktop:
  /desktop/pgp:
   encrypt_to_self = false
   ascii_armor = false
   last_signer_openpgp =
   last_signer_openssh =
   default_key =
   /desktop/pgp/recipients:
    sort_by = name
   /desktop/pgp/keyservers:

[6] $ gconftool-2 -R / | grep moun | head
    automount_drives = false
    automount_media = false
    media_automount_open = true
    media_automount = true
       mount_point = compiz
  /apps/drivemount-applet:
   /apps/drivemount-applet/prefs:
    mount_point = /media/floppy
     mount_options = [umask=222,utf8,exec]
     mount_options = [shortname=mixed,uid=,utf8,umask=077,exec,flush]

[7] $ gconftool-2 -R / | grep -e automount_drives -e : | grep -B 1 -e
automount_drives
   /desktop/gnome/volume_manager:
    automount_drives = false
--
     autokeyboard_command = Schema (type: `string' list_type:
'*invalid*' car_type: '*invalid*' cdr_type: '*invalid*' locale: `C')
     automount_drives = Schema (type: `bool' list_type: '*invalid*'
car_type: '*invalid*' cdr_type: '*invalid*' locale: `C')

[8] $ gconftool-2 --get /desktop/gnome/volume_manager/automount_drives
false

[9] $ gconftool-2 --set /desktop/gnome/volume_manager/automount_drives true
Must specify a type when setting a value

[10] $ gconftool-2 --set
/desktop/gnome/volume_manager/automount_drives --type=bool true

[11] $ gconftool-2 --get /desktop/gnome/volume_manager/automount_drives
true

[12] $ gconftool-2 --set
/desktop/gnome/volume_manager/automount_drives --type=bool false

[13] $ gconftool-2 --get /desktop/gnome/volume_manager/automount_drives
false

Some questions with answers:

Q: How did I know to use gconf?
A: I didn't.  I took a guess and got lucky as it could also have been
the autofs service, HAL, or something else.

Q: How did I know to grep for mount?
A: I didn't.  I took a guess and got lucky as it could have been
"drive", "disk", "volume", or something cryptic (e.g. mntfs)

Q: How did I know how to use 'gconftool-2 -R /' to get a list of all
key-value pairs?
A: I didn't.  It took me a few guesses before I got it right.

Q: How did I know to use type bool?
A: I just happen to get lucky with my previous grep command and picked
up the schema for automount_drive.

Q: How do I list the gconf tree in full key-value notation or in XML
instead of in tree notation?
A: I have no idea.  None of the options to gconftool-2 look obvious.
I could google for docs and read those, but that hasn't been fruitful,
yet.  Or I could write a script.

Wrote it in ruby just for the fun of it:

$ gconftool-2 -R / | ruby -lne '$_.gsub!(/^\s+/,"") ; if (/:$/) ;
path=$_.slice(0..-2) ; else ; puts "#{path}/#{$_}" ; end' | grep
automount
/desktop/gnome/volume_manager/automount_drives = false
/desktop/gnome/volume_manager/automount_media = false
/apps/nautilus/preferences/media_automount_open = true
/apps/nautilus/preferences/media_automount = true
/schemas/desktop/gnome/volume_manager/automount_drives = Schema (type:
`bool' list_type: '*invalid*' car_type: '*invalid*' cdr_type:
'*invalid*' locale: `C')
/schemas/desktop/gnome/volume_manager/automount_media = Schema (type:
`bool' list_type: '*invalid*' car_type: '*invalid*' cdr_type:
'*invalid*' locale: `C')
/schemas/apps/nautilus/preferences/media_automount_open = Schema
(type: `bool' list_type: '*invalid*' car_type: '*invalid*' cdr_type:
'*invalid*' locale: `C')
/schemas/apps/nautilus/preferences/media_automount = Schema (type:
`bool' list_type: '*invalid*' car_type: '*invalid*' cdr_type:
'*invalid*' locale: `C')

Now it looks a bit more like 'sysctl -a' or 'about:config' in Firefox.

Q: Can anyone recommend a good tutorial on gconf?

The docs seem to be a bit cryptic:

http://library.gnome.org/devel/gconf/2.22/

Regards,
- Robert

-- 
Central West End Linux Users Group (via Google Groups)
Main page: http://www.cwelug.org
To post: [email protected]
To subscribe: [email protected]
To unsubscribe: [email protected]
More options: http://groups.google.com/group/cwelug

Reply via email to