Browse Source

allow to set user wallpapper

master
Марков Сергей Викторович 2 years ago
parent
commit
250ef48928
  1. 4
      index.html
  2. 2
      index.yml
  3. 11
      main.js
  4. 20
      secondary.html
  5. 30
      wallpapper.js
  6. 7
      web-greeter-theme-basealt.spec

4
index.html

@ -3,7 +3,8 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<link rel="stylesheet" href="style.css" class="style"> <link rel="stylesheet" href="style.css" class="style">
<script type="text/javascript" src="main.js"></script> <script type="text/javascript" src="wallpapper.js"></script>
<script type="text/javascript" src="main.js"></script>
<title>Example Theme</title> <title>Example Theme</title>
</head> </head>
<body> <body>
@ -32,6 +33,7 @@
<option value="Elbrus1.jpg">Эльбрус - 1</option> <option value="Elbrus1.jpg">Эльбрус - 1</option>
<option value="Elbrus2.jpg">Эльбрус - 2</option> <option value="Elbrus2.jpg">Эльбрус - 2</option>
<option value="Elbrus3.jpg">Эльбрус - 3</option> <option value="Elbrus3.jpg">Эльбрус - 3</option>
<option value="User">Пользовательский</option>
</select> </select>
</dev> </dev>
</td> </td>

2
index.yml

@ -1,2 +1,2 @@
primary_html: "index.html" primary_html: "index.html"
secondary_html: "index.html" secondary_html: "secondary.html"

11
main.js

@ -1,7 +1,5 @@
const DEFAULT_USER = "defaultUser"; const DEFAULT_USER = "defaultUser";
const DEFAULT_SESSION = "defaultSession"; const DEFAULT_SESSION = "defaultSession";
const DEFAULT_WALLPAPPER = "defaultWallpapper";
const WALLPAPPER_ELEMENT = "wallpappers";
const WAITING_CLASS = "waiting"; const WAITING_CLASS = "waiting";
function togglePasswordVisibility() { function togglePasswordVisibility() {
@ -108,13 +106,6 @@ function updateUser(username) {
updateDefaultsInLocalstorage(); updateDefaultsInLocalstorage();
} }
function updateWallpapper(wallpapper) {
var body = document.getElementsByTagName('body')[0];
body.style.backgroundImage = `url(wallpappers/${wallpapper})`;
updateDefaultsInLocalstorage();
}
function initGreeter() { function initGreeter() {
let users = lightdm.users let users = lightdm.users
@ -136,12 +127,14 @@ function initGreeter() {
wallpappers.addEventListener('change', (event) => { wallpappers.addEventListener('change', (event) => {
updateWallpapper(event.target.value); updateWallpapper(event.target.value);
updateDefaultsInLocalstorage();
}); });
let defaultWallpapper = window.localStorage.getItem(DEFAULT_WALLPAPPER); let defaultWallpapper = window.localStorage.getItem(DEFAULT_WALLPAPPER);
if(defaultWallpapper) { if(defaultWallpapper) {
selectItemByValue(wallpappers, defaultWallpapper); selectItemByValue(wallpappers, defaultWallpapper);
updateWallpapper(defaultWallpapper); updateWallpapper(defaultWallpapper);
updateDefaultsInLocalstorage();
} }
let sessions = lightdm.sessions let sessions = lightdm.sessions

20
secondary.html

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="style.css" class="style">
<script type="text/javascript" src="wallpapper.js"></script>
<script type="text/javascript">
function initGreeter() {
let defaultWallpapper = window.localStorage.getItem(DEFAULT_WALLPAPPER);
if(defaultWallpapper) {
updateWallpapper(defaultWallpapper);
}
}
window.addEventListener("GreeterReady", initGreeter)
</script>
<title>Example Theme</title>
</head>
<body />
</html>

30
wallpapper.js

@ -0,0 +1,30 @@
const DEFAULT_WALLPAPPER = "defaultWallpapper";
const WALLPAPPER_ELEMENT = "wallpappers";
function setWallpapper(wallpapper) {
console.log(wallpapper)
var body = document.getElementsByTagName('body')[0];
body.style.backgroundImage = wallpapper;
}
function updateWallpapper(wallpapper) {
let wall_file = `url(wallpappers/${wallpapper})`
if (wallpapper === 'User') {
setWallpapper(`url(wallpappers/Rosatomflot.jpg)`)
theme_utils.dirlist(`/usr/share/web-greeter/themes/basealt/wallpappers`, true, (images) => {
if(images) {
console.log(images)
for (let i = 0; i < images.length; i++) {
let image = images[i]
if(image.indexOf("/wallpapper.png") == image.length - 15) {
setWallpapper(`url(${image})`)
console.log(wall_file)
}
}
}
});
} else {
setWallpapper(`url(wallpappers/${wallpapper})`)
}
}

7
web-greeter-theme-basealt.spec

@ -1,7 +1,7 @@
%define shortname basealt %define shortname basealt
Name: web-greeter-theme-basealt Name: web-greeter-theme-basealt
Version: 1.0.4 Version: 1.0.5
Release: alt1 Release: alt1
Summary: A theme for web-greeter on AltLinux Summary: A theme for web-greeter on AltLinux
@ -11,7 +11,7 @@ Group: System/Configuration/Boot and Init
Url: https://git.markow.su/markow/web-greeter-theme-basealt Url: https://git.markow.su/markow/web-greeter-theme-basealt
Source: %name-%version.tar Source: %name-%version.tar
Packager: Sergey-V Markov <sergey@markow.su> Packager: Sergey-V Markov <markow@altlinux.org>
Requires: lightdm lightdm-webkit2-greeter Requires: lightdm lightdm-webkit2-greeter
@ -34,6 +34,9 @@ rsync -rv --exclude-from=./.copyignore ./* %buildroot%_datadir/web-greeter/theme
%_datadir/web-greeter/themes/%shortname/* %_datadir/web-greeter/themes/%shortname/*
%changelog %changelog
* Mon Apr 3 2023 Sergey-V Markov <markow@altlinux.org> 1.0.5-alt1
- Allow to set user wallpapper
* Sun Jan 8 2023 Sergey-V Markov <sergey@markow.su> 1.0.4-alt1 * Sun Jan 8 2023 Sergey-V Markov <sergey@markow.su> 1.0.4-alt1
- Bug fix with defaults updating storage - Bug fix with defaults updating storage

Loading…
Cancel
Save