1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-03-23 20:03:33 +01:00

More sane dactyl.profileName getter.

This commit is contained in:
Kris Maglione
2010-12-01 16:07:31 -05:00
parent e461ca9b95
commit dde222acac

View File

@@ -48,15 +48,22 @@ const Dactyl = Module("dactyl", {
this.commands = {}; this.commands = {};
this.modules = modules; this.modules = modules;
this.observers = {}; this.observers = {};
},
/** @property {string} The name of the current user profile. */
profileName: Class.memoize(function () {
// NOTE: services.get("profile").selectedProfile.name doesn't return // NOTE: services.get("profile").selectedProfile.name doesn't return
// what you might expect. It returns the last _actively_ selected // what you might expect. It returns the last _actively_ selected
// profile (i.e. via the Profile Manager or -P option) rather than the // profile (i.e. via the Profile Manager or -P option) rather than the
// current profile. These will differ if the current process was run // current profile. These will differ if the current process was run
// without explicitly selecting a profile. // 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 () { destroy: function () {
autocommands.trigger("LeavePre", {}); autocommands.trigger("LeavePre", {});