forked from konkor/obmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
obmin-preferences
executable file
·43 lines (39 loc) · 1.58 KB
/
obmin-preferences
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/gjs
/*
* This is a part of OBMIN Server
* Copyright (C) 2017-2019 konkor <konkor.github.io>
*
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const APPDIR = get_appdir ();
imports.searchPath.unshift(APPDIR);
const Prefs = imports.common.preferences;
function getCurrentFile () {
let stack = (new Error()).stack;
let stackLine = stack.split('\n')[1];
if (!stackLine)
throw new Error ('Could not find current file');
let match = new RegExp ('@(.+):\\d+').exec(stackLine);
if (!match)
throw new Error ('Could not find current file');
let path = match[1];
let file = Gio.File.new_for_path (path);
return [file.get_path(), file.get_parent().get_path(), file.get_basename()];
}
function get_appdir () {
let s = getCurrentFile ()[1];
if (GLib.file_test (s + "/prefs.js", GLib.FileTest.EXISTS)) return s;
s = GLib.get_home_dir () + "/.local/share/gnome-shell/extensions/obmin@konkor";
if (GLib.file_test (s + "/prefs.js", GLib.FileTest.EXISTS)) return s;
s = "/usr/local/share/gnome-shell/extensions/obmin@konkor";
if (GLib.file_test (s + "/prefs.js", GLib.FileTest.EXISTS)) return s;
s = "/usr/share/gnome-shell/extensions/obmin@konkor";
if (GLib.file_test (s + "/prefs.js", GLib.FileTest.EXISTS)) return s;
throw "Obmin installation not found...";
return s;
}