summaryrefslogtreecommitdiff
path: root/overrides
diff options
context:
space:
mode:
Diffstat (limited to 'overrides')
-rw-r--r--overrides/Endless.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/overrides/Endless.js b/overrides/Endless.js
index 00315a3..835688a 100644
--- a/overrides/Endless.js
+++ b/overrides/Endless.js
@@ -1,8 +1,23 @@
+const Gio = imports.gi.Gio;
+
let Endless;
+// Returns the directory that the currently executing JS file resides in
+// This is a silly hack that creates an error and looks at its stack trace
+function getCurrentFileDir() {
+ let e = new Error();
+ let caller = e.stack.split('\n')[1];
+ let pathAndLine = caller.split('@')[1];
+ let path = pathAndLine.split(':')[0];
+
+ // Get full path from GIO
+ return Gio.File.new_for_path(path).get_parent().get_path();
+}
+
function _init() {
// this is imports.gi.Endless
Endless = this;
+ Endless.getCurrentFileDir = getCurrentFileDir;
// Override Endless.PageManager.add() so that you can set child properties
// at the same time