From dde222acac658d54b69e0a549f15141285c29697 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Wed, 1 Dec 2010 16:07:31 -0500 Subject: [PATCH] More sane dactyl.profileName getter. --- common/content/dactyl.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/common/content/dactyl.js b/common/content/dactyl.js index fc3f3e67..310be924 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -48,15 +48,22 @@ const Dactyl = Module("dactyl", { this.commands = {}; this.modules = modules; this.observers = {}; + }, + /** @property {string} The name of the current user profile. */ + profileName: Class.memoize(function () { // NOTE: services.get("profile").selectedProfile.name doesn't return // what you might expect. It returns the last _actively_ selected // profile (i.e. via the Profile Manager or -P option) rather than the // current profile. These will differ if the current process was run // without explicitly selecting a profile. - /** @property {string} The name of the current user profile. */ - this.profileName = services.get("directory").get("ProfD", Ci.nsIFile).leafName.replace(/^.+?\./, ""); - }, + + let dir = services.get("directory").get("ProfD", Ci.nsIFile); + for (let prof in iter(services.get("profile").profiles)) + if (prof.QueryInterface(Ci.nsIToolkitProfile).localDir.path === dir.path) + return prof.name; + return "unknown"; + }), destroy: function () { autocommands.trigger("LeavePre", {});