Dev Week -- Understanding GNOME Technologies -- tedg -- Mon, Jan 19


(03:02:43 PM) james_w: next up is Ted with "Understanding GNOME Technologies"
(03:02:54 PM) james_w: should be an interesting one
(03:03:03 PM) james_w: when he turns up :-p
(03:03:30 PM) agoliveira: james_w: Ted Gould?
(03:03:34 PM) james_w: yup
(03:03:48 PM) james_w: ta-da!
(03:03:57 PM) tedg: Sorry everyone, I messed up the time conversion.
(03:04:04 PM) james_w: tedg: the floor is yours when you are ready
(03:04:23 PM) tedg: Cool, hello everyone, I'm Ted Gould.
(03:04:37 PM) co0lingFir3: hi ted!
(03:04:42 PM) tedg: I'm here to talk a little bit about some Core GNOME Technologies, specifically GConf and DBus.
(03:04:48 PM) theseas: hi Ted!
(03:05:00 PM) tedg: There is of course many more, but we do have a limited amount of time to get through all of them.
(03:05:18 PM) tedg: So, let's get started with GConf.
(03:05:38 PM) tedg: GConf at it's most basic level is just a configuration storage mechanism.
(03:06:01 PM) tedg: Instead of every application inventing it's own configuration file format, each of them uses a standard API to build.
(03:06:35 PM) tedg: Which can be very handy for people like sysadmins and users writing scripts.
(03:07:02 PM) tedg: One of the most standard way for people to interact with GConf is through gconf-editor
(03:07:19 PM) tedg: It kinda looks like Microsoft's registry editor, which is where it gets it's bad reputation.
(03:07:32 PM) tedg: But, I assure you, it's not like the Windows Registry.
(03:08:05 PM) tedg: Sometimes apps do put settings inside GConf that they don't export in other ways, so it's a good place to look to see if you can get a setting you're looking for.
(03:08:28 PM) tedg: One thing that you might notice as you're looking in GConf editor is that each key has a short and long description.
(03:08:45 PM) tedg: This is a translated string that can be used to describe the values or the impact of changing that value.
(03:09:16 PM) tedg: Because GConf is a daemon running in the user's session you can change the values in gconf-editor and they'll change live in the application
(03:09:36 PM) tedg: This also means that you should be careful when changing values!
(03:09:52 PM) james_w: <bullgard4> QUESTION: Why has Configuration Editor  its keys branched in 2 branches 'apps' and 'schemas'?
(03:09:53 PM) iulian left the room (quit: "leaving").
(03:10:06 PM) tedg: Another way that you can access GConf is through the command line tool "gconftool-2"
(03:10:28 PM) tedg: bullgard4, Let me answer that in a little bit, I'll get there I promise :)
(03:10:37 PM) mode (-o nxvl ) by mneptok
(03:10:40 PM) mode (+o tedg ) by mneptok
(03:11:02 PM) tedg: So if you want to see all the keys for GNOME Panel you can do: gconftool-2 -R /apps/panel/global
(03:11:33 PM) tedg: This gives you a way to start to parse things with scripts and change settings based on icons or other effects.
(03:11:53 PM) tedg: So if you wanted to add the  buttons on your panel you could do: gconftool-2 -s /apps/panel/toplevels/top_panel_screen0/enable_buttons -t bool true
(03:12:04 PM) tedg: (and you can fix it with: gconftool-2 -s /apps/panel/toplevels/top_panel_screen0/enable_buttons -t bool false)
(03:12:22 PM) tedg: Again this is live, as you execute that your top panel should have the buttons appear.
(03:12:41 PM) tedg: We can also get the documentation using the gconf tool.
(03:13:03 PM) tedg: Short docs: gconftool-2 --short-docs /apps/panel/global/confirm_panel_remove
(03:13:12 PM) tedg: Long Docs: gconftool-2 --long-docs /apps/panel/global/confirm_panel_remove
(03:13:39 PM) tedg: Another thing that is neat about GConf is that it provides a set of defaults, and then the user's configuration is layered on top of that.
(03:14:09 PM) tedg: You can see that in this slide: http://gould.cx/ted/presentations/oscon08/index.php?slide=20
(03:14:29 PM) tedg: What happens here is that the upstream values are the lowest level of settings that are used.
(03:14:38 PM) tedg: Then we layer on the distro specific changes.
(03:14:53 PM) tedg: Then any other changes a user/admin/dept. wants.
(03:15:03 PM) tedg: Lastly, the user's specific configuration is put in.
(03:15:39 PM) tedg: So, we can also use gconf-tool to revert our settings to the defaults: gconftool --recursive-unset /apps/gnome-power-manager
(03:15:57 PM) tedg: (and I'd recommend saving your old ones first: gconftool --recursive-list /apps/panel > panel.gconf.values.txt )
(03:16:20 PM) tedg: So if you're debugging a problem that might be a local setting, you can ensure that you have the defaults.
(03:16:32 PM) tedg: This is helpful, also in determining which setting broke things.
(03:16:54 PM) tedg: The lowest level of settings that GConf provides are called the GConf Schemas.
(03:17:07 PM) tedg: These involve the default values, but also the descriptions that are translated.
(03:17:37 PM) tedg: We can look at some of the schemas in the system by going to /usr/share/gconf/schemas
(03:17:54 PM) tedg: For example you can look at panel-general.schemas to see some of the settings we were just looking at.
(03:18:18 PM) tedg: Typically there is a set of schemas for every application that uses GConf
(03:18:41 PM) tedg: The way that this layering is built up is through the GConf path.
(03:19:00 PM) tedg: The path that starts everything out is: /etc/gconf/2/path
(03:19:18 PM) tedg: If you look at that file you'll see that it's basically a list of directories and other paths to include.
(03:19:49 PM) tedg: So if the user goes and includes a path in ~/.gconf.path that'll also get included in the list of settings that come through.
(03:20:15 PM) tedg: You can include a repository based on what machine you're on, or any other variable of your liking on a per-user basis.
(03:20:38 PM) tedg: But a sysadmin could also install some defaults for his/her site by putting a path in /etc/gconf/2/local-defaults.path
(03:20:54 PM) tedg: To customize the distribution for their site specifically.
(03:21:13 PM) tedg: Now, let's look a little bit at how the other defaults are set up.
(03:21:38 PM) tedg: The tree that is derived from the schemas shows up in /var/lib/gconf/defaults
(03:21:48 PM) tedg: You probably want to look at %gconf-tree.xml.
(03:22:12 PM) tedg: If you search for 'dir name="panel"' in your editor you can see the default panel settings from upstream.
(03:22:27 PM) tedg: But those get changed by Ubuntu/Debian in /var/lib/gconf/debian-defaults
(03:22:49 PM) tedg: And that tree is built a little bit differently by dh_gconf: http://manpages.ubuntu.com/manpages/intrepid/en/man1/dh_gconf.1.html
(03:23:23 PM) tedg: dh_gconf uses a file 'gconf-defaults' in the debian directory of the package to set the settings for that package.
(03:23:46 PM) tedg: I wanted to show one, the easiest way that I could find is this, but it might take a while: apt-get source gnome-power-manger ; cd gnome-power-manager-* ; vi debian/gconf-defaults
(03:24:29 PM) tedg: Basically the file gets copied to /usr/share/gconf/defaults
(03:24:46 PM) tedg: So you can look at 10_gnome-power-manager to see basically the same file.
(03:24:51 PM) tedg: It's just a list of keys and values.
(03:25:00 PM) tedg: So you can see we're setting the icon type with this line:
(03:25:09 PM) tedg:  /apps/gnome-power-manager/ui/icon_policy charge
(03:25:43 PM) tedg: And you can see what that does: gconftool-2 --short-docs  /apps/gnome-power-manager/ui/icon_policy
(03:26:07 PM) james_w: <maix> QUESTION: where are the translated descriptions of the schemas?
(03:26:19 PM) tedg: So, the basics of GConf is that it's a set of configuration storage.
(03:26:52 PM) tedg: That provides a good way to store settings in a uniform file format which lets the users and sysadmins have control over the settings in a universal way.
(03:27:30 PM) tedg: maix, the translated values are installed in /var/lib/gconf/defaults/%gconf-tree-{locale}.xml but they are built from the schemas.
(03:27:55 PM) james_w: <creek23> QUESTION: is there no chance to export settings from GConf Editor -- like windows' regedit does?
(03:27:59 PM) tedg: I'm going to stop for a second, for GConf questions.
(03:28:05 PM) james_w: <oliver_g_1> QUESTION: how can I import a list created with gconftool --recursive-list ?
(03:29:10 PM) tedg: oliver_g_1, creek23, you can export the settings and install them using gconftool.  Let me get the syntax.
(03:30:04 PM) tedg: Ah, it's not coming quickly there.  There is a way I can't find right now :(
(03:30:36 PM) james_w: <Arc> QUESTION: is GConf intended for just gnome-specific apps or is it used for more general purpose apps (ie, those that may run under other desktop environments)
(03:31:17 PM) tedg: Arc, there is no reason that other applications couldn't use GConf, but most do not.  There is some work on a "DConf" which is DBus based which could be more universal across desktops, though it hasn't been released yet.
(03:31:39 PM) tedg: Arc, one of the issues with GConf is that it's dependent on CORBA which is a dependency that most folks don't want to carry.
(03:32:09 PM) james_w: (gconftool --dump and gconftool --load look like candidates for backup and restore)
(03:32:40 PM) tedg: james_w: Yes, thank you.
(03:33:14 PM) tedg: Okay, if there aren't any more questions I'll start talking some about DBus.
(03:33:29 PM) tedg: DBus is a generic IPC mechanism for applications to talk to each other.
(03:33:51 PM) tedg: What makes DBus interesting is that it's designed to be rather small and that it communicates in messages.
(03:34:04 PM) tedg: These messages have parameters which are typed in a defined way.
(03:34:21 PM) maix: stop, there are some questions
(03:34:29 PM) maix: <creek23> QUESTION: is it recommended that user settings should be saved on gconf instead of ~/.foobar?
(03:34:33 PM) maix: <maix> QUESTION: it is not possible to have two instances of a program with different settings, is it? (like with other programs where one can specify another conf file by a command line option)
(03:34:35 PM) tedg: So when you're building or using a DBus API you have more guarantees about how that API would work.
(03:34:40 PM) tedg: maix: Okay.
(03:35:28 PM) tedg: creek23: Yes, that is generally preferred.
(03:35:55 PM) tedg: creek23: Of course that can be a pretty big change, as doing that users will expect you to be able to respond to configuration file changes.
(03:35:55 PM) creek23: ty.
(03:36:10 PM) tedg: creek23: Which most apps don't do if they're not GConf enabled.
(03:36:44 PM) tedg: maix: I'm not sure of an easy way to do that.  It would be possible to provide a different path, but I don't know of any applications that do that.
(03:37:46 PM) tedg: Any more Q's?
(03:38:20 PM) maix: not seen more in -chat
(03:38:20 PM) tedg: Okay, I'll continue with DBus.
(03:38:53 PM) tedg: So DBus is one of the first things specified by Freedesktop
(03:39:02 PM) tedg: And so it typically works with most GNOME and KDE applications.
(03:39:26 PM) tedg: One interesting development in the DBus world is that there was talk at the Linux Plumbers conference about integrating DBus into the kernel.
(03:39:37 PM) tedg: Which would also make it a very fast way for applications to communicate.
(03:39:59 PM) tedg: Currently dbus is a daemon, and there are two of them.
(03:40:07 PM) tedg: One of them runs the system bus and one runs the session bus.
(03:40:47 PM) tedg: The system bus is all of the applications that are executing on your system with privileges and that there should be only one of even with multiple users.
(03:41:25 PM) tedg: Probably the most famous of these is HAL, or Hardware Abstraction Layer, which abstracts out the different events that happen at the system level (like plugging in a USB key) and sends out that message.
(03:42:04 PM) tedg: One tool to use to start playing with DBus is called "d-feet" and provides a graphical way to send messages on DBus.
(03:42:16 PM) tedg: It'll also let you see which applications are exposing themselves over DBus.
(03:42:23 PM) tedg: And what functions they're providing.
(03:42:46 PM) tedg: Oh, I had a slide for the broadcast point a few lines back :)  http://gould.cx/ted/presentations/oscon08/index.php?slide=27
(03:43:16 PM) tedg: The session bus is allocated on a per-user basis.
(03:43:32 PM) tedg: So if there are multiple users logged into the system then they'll each have a session bus.
(03:43:57 PM) tedg: Applications that sit on the session bus are those that are working with the user, usually providing their desktop environment.
(03:44:08 PM) tedg: You can do fun stuff like most media players provide a way to switch songs over DBus.
(03:44:26 PM) tedg: The easiest way over IRC to tickle DBus is by using dbus-send
(03:44:43 PM) tedg: So you can do something like: dbus-send --system --print-reply --dest="org.freedesktop.Hal" /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Suspend int32:0
(03:44:56 PM) ***tedg waits to see how many people drop off with a suspended laptop :)
(03:45:10 PM) xnox: <Ng> QUESTION: are there any nice wrappers for using dbus from, say, python?
(03:45:10 PM) xnox:      the raw API seems kind of cumbersome to use
(03:45:41 PM) tedg: Ng: Yes, there is a bunch.  Python-dbus is nice.  And if you're using C and GLib the glib bindings are very nice.
(03:46:00 PM) tedg: Ng: I haven't used any others, but in general there are a ton of bindings available for DBus.
(03:46:27 PM) tedg: A command that you can play with more safely is: dbus-send --system --print-reply --dest="org.freedesktop.Hal" /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Suspend int32:0
(03:46:37 PM) tedg: No, cut-and-paste error.
(03:46:44 PM) tedg: dbus-send --session --dest="org.freedesktop.PowerManagement" /org/freedesktop/PowerManagement/Backlight org.freedesktop.PowerManagement.Backlight.SetBrightness int32:50
(03:46:48 PM) tedg: There.
(03:46:59 PM) tedg: That should (on most laptops) set your backlight to 50%.
(03:47:31 PM) tedg: What's also interesting about DBus is the broadcast side, and we can see that from teh command line also.
(03:47:39 PM) tedg: To do that we can use dbus-monitor.
(03:47:51 PM) tedg: So if we want to watch for backlight events:
(03:48:00 PM) tedg: dbus-monitor --session "type='signal',interface='org.freedesktop.PowerManagement.Backlight'"
(03:48:29 PM) tedg: So if you run the previous command in another window, you should see the events show up as their broadcast across the bus.
(03:48:51 PM) tedg: Even though you're running on the command line, both the other window and GNOME Power Manger are both getting the event.
(03:49:56 PM) tedg: While you can see the interfaces with d-feet, you can also discover them programatically.  As DBus also provides a way for introspection data to come across the bus.
(03:50:19 PM) tedg: I'd recommend looking at that in d-feet as it's a rather large XML file.
(03:50:44 PM) tedg: A good over view of DBus is at Linux Journal: http://www.linuxjournal.com/article/7744
(03:51:16 PM) tedg: Let me take questions, as otherwise we'll run out of time.
(03:51:39 PM) tedg: <meebey> QUESTION: who defines the path/namespace/method (or whatever it's called) for dbus, so other applications can call it? and can other applications "hijack" APIs?
(03:51:39 PM) Arc: tedg: are you watching #ubuntu-classroom-chat?
(03:51:56 PM) tedg: arc: trying :)
(03:51:56 PM) xnox: <meebey> QUESTION: who defines the path/namespace/method (or whatever it's
(03:51:56 PM) xnox:      called) for dbus, so other applications can call it? and can other
(03:51:56 PM) xnox:      applications "hijack" APIs?
(03:52:02 PM) ***xnox is sorry
(03:52:39 PM) tedg: meebey: The applications apply for a name when they start up, so it is possible for another application to implement the same API and use the same name.  But, DBus ensures that only one app has that name at a time.
(03:53:05 PM) tedg: meebey: For instance, with the work you've probably seen about notifications, we're implementing the same DBus API so many applications can work unchanged.
(03:53:33 PM) mneptok: xnox: please do not paste to this channel without being asked
(03:53:56 PM) tedg: meebey: But, if you try to run our notification daemon and the upstream one is running, one will fail depending on which starts first.
(03:54:21 PM) tedg: <Arc> QUESTION: is inotify setup to use DBus on Ubuntu?
(03:54:59 PM) tedg: Arc, I'm not sure of a way that inotify could broadcast over DBus.  Really it would probably be more advisable that applications that were interested in doing something like that use Tracker to get that information.
(03:55:13 PM) tedg: Arc, that way only Tracker is opening an inotify connection for every file on the system :)
(03:55:37 PM) tedg: <GSMX> QUESTION: (sorry, gconf, missed out a bit) What's the difference between regedit en gconf-editor?
(03:56:00 PM) tedg: GSMX, well I think a better question there is what's the difference between the windows registry and GConf.
(03:56:08 PM) tedg: GSMX: GConf is only for configuration storage.
(03:56:22 PM) tedg: GSMX: While the windows registry also does registration of objects.
(03:56:42 PM) tedg: GSMX: Also, GConf has a layered approach where regular users rarely have a reason to need administrator access.
(03:57:02 PM) tedg: GSMX: Where in Windows you end up with a lot of users needing some level of editing of the windows registry just to be productive.
(03:57:25 PM) tedg: GSMX: Which, while they've tried hard to block them, seems to related to quite a few of their security issues.
(03:57:30 PM) mneptok: tedg: also of note is that gconf outputs its configuration to human-readable markup, while regdit is the only interface to the Win registry. if you have enough GNOME-fu, you can configure gconf with vi ;)
(03:57:58 PM) tedg: mneptok: For the record, I don't recommend that :)
(03:58:06 PM) ***mneptok does not, either.
(03:58:13 PM) mneptok: (vi, that is) >:)
(03:58:42 PM) tedg: Arc, AFAIK, DBus doesn't use inotify directly.
(03:59:17 PM) tedg: Okay, considering I think we have 15 seconds or so left.  Probably a good time to call it a session.
(03:59:29 PM) tedg: Thanks to everyone for showing up.
(03:59:35 PM) ***Israphel claps
(03:59:38 PM) ikis: thanks to you
(03:59:39 PM) Arc: thanks tedg!
(03:59:39 PM) GSMX: thx!
(03:59:40 PM) tedg: I'm usually in #ubuntu-desktop if you have more questions.
(03:59:41 PM) ikis: nice session
(03:59:44 PM) ronj: thanksthanksthanksthanks
(03:59:45 PM) dinxter: cheers ted, interesting stuff
(03:59:46 PM) mbudde: Thanks tedg!
(03:59:56 PM) meebey: thanks tedg
(04:00:03 PM) arch: very thanks :D
(04:00:06 PM) xnox: thank you!!!!
(04:00:06 PM) maix: thank you!
(04:00:07 PM) EnCuKou: Thank you!
(04:00:18 PM) audriusz: thanks. this was very interesting
(04:00:19 PM) theseas: thanx tedg ang goodnight!!! :)
(04:00:19 PM) creek23: thanks you!
(04:00:24 PM) xlazarus: good work, thanks
(04:00:24 PM) oliver_g_1: thanks tedg!
(04:00:26 PM) mnemo: thanks a lot tedg :)
(04:00:35 PM) rooivalk: thank you for your corporation! :)

MeetingLogs/devweek0901/UnderstandGNOME (last edited 2009-01-19 21:13:28 by pool-71-182-96-163)