-
Notifications
You must be signed in to change notification settings - Fork 43
/
FileOperations.js
70 lines (54 loc) · 2.29 KB
/
FileOperations.js
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// FileOperations -> Required by Components/WallpaperSwitcher
// --------------------------------------
// LightDM related file / config fetching.
export function getWallpaperDirectory() {
// Return the test folder when debugging.
if (window.__debug === true) {
return "src/test/wallpapers/";
}
let wallpapersDirectory = window.config.get_str("branding", "background_images");
// Do NOT allow the default wallpaper directory to set, as this will prevent the default provided backgrounds from
// being used 100% of the time in a stock install.
if (wallpapersDirectory == "/usr/share/backgrounds" || wallpapersDirectory == "/usr/share/backgrounds/") {
wallpapersDirectory = "/usr/share/lightdm-webkit/themes/lightdm-webkit-theme-aether/src/img/wallpapers/";
}
return wallpapersDirectory;
}
export function getWallpapers(directory) {
// If we're in test mode, we stick to a static rotation of three default wallpapers.
// In production, it is possible that a user will change what wallpapers are available.
if (window.__debug === true) {
return ['boko.jpg', 'mountains-2.png', 'space-1.jpg'];
}
let wallpapers;
wallpapers = window.greeterutil.dirlist(directory);
wallpapers = wallpapers.map((e) => e.split("/").pop());
return wallpapers;
}
export function getLogos() {
// If we're in test mode, just return the default three.
if (window.__debug === true) {
return [
["src/test/logos/archlinux.png", "archlinux.png"],
["src/test/logos/antergos.png", "antergos.png"],
["src/test/logos/ubuntu.png", "ubuntu.png"],
["src/test/logos/debian.png", "debian.png"],
["src/test/logos/generic.png", "generic.png"],
["src/test/logos/tux.png", "tux.png"],
["src/test/logos/tux-silhouette.png", "tux-silhouette.png"]
];
}
// Return a tuple of the path and filename for usage in the Settings dialogue.
let userLogo = window.config.get_str("branding", "logo");
let themeLogos = window.greeterutil.dirlist("/usr/share/lightdm-webkit/themes/lightdm-webkit-theme-aether/src/img/logos/");
themeLogos.push(userLogo);
return themeLogos.map((e) => [e, e.split("/").pop()]);
}
export function getEnvironments() {
return window.lightdm.sessions.map((session) => {
return {
'name': session.name,
'value': session.key
};
});
}