Hungarian translation, move current login image to usr/share/pixmaps

This commit is contained in:
2024-02-15 19:58:53 +01:00
parent 77db85cc71
commit 333bb3b995
8 changed files with 411 additions and 116 deletions

View File

@@ -2,7 +2,7 @@
from gi.repository import Gio, Gdk
# Packages
import os, time, locale, subprocess
import os, time, locale, subprocess, getpass
from PIL import Image
# Local scripts
@@ -187,13 +187,13 @@ class Main_View_Model:
# Update the login_image
if self.cinnamon_prefs.login_image:
# Create the folder in /tmp
try:
os.mkdir("/tmp/cinnamon_dynamic_wallpaper")
except:
print("Folder already exists")
directory = '/usr/share/pixmaps/cinnamon_dynamic_wallpaper'
if not os.path.isdir(directory):
subprocess.run(['pkexec', 'install', '-o', getpass.getuser(), '-d', directory])
# Copy the current image to the temp folder for the login screen
os.system("cp " + self.current_image_uri + " " + "/tmp/cinnamon_dynamic_wallpaper/login_image.jpg")
os.system("cp " + self.current_image_uri + " " + directory + "/login_image.jpg")
# Set background stretching
self.background_settings['picture-options'] = self.cinnamon_prefs.picture_aspect
@@ -289,40 +289,32 @@ class Main_View_Model:
# Location of the config file
file_location = self.WORKING_DIR + "/slick-greeter.conf"
if os.path.isfile("/etc/lightdm/slick-greeter.conf"):
# File already exists, make a copy of the config
with open("/etc/lightdm/slick-greeter.conf", "r") as conf_file:
for line in conf_file.readlines():
if line.startswith("background"):
# Case 1: Preference is already set as expected -> leave function
if line.find("cinnamon_dynamic_wallpaper/login_image.jpg") != -1 and self.cinnamon_prefs.login_image or \
line.find("cinnamon_dynamic_wallpaper/login_image.jpg") == -1 and not self.cinnamon_prefs.login_image:
if self.cinnamon_prefs.login_image:
self.refresh_image()
if os.path.isfile("/etc/lightdm/slick-greeter.conf"):
# File already exists, make a copy of the config
with open("/etc/lightdm/slick-greeter.conf", "r") as conf_file:
for line in conf_file.readlines():
if not line.startswith("background"):
file_content += line
elif line.endswith("cinnamon_dynamic_wallpaper/login_image.jpg"):
# Skip the configuration. It's already perfect!
return
# Case 2: Function enabled -> Set the path to the login image
elif self.cinnamon_prefs.login_image:
file_content += "background=/tmp/cinnamon_dynamic_wallpaper/login_image.jpg\n"
# Case 3: Function disabled -> Remove the custom login image
elif not self.cinnamon_prefs.login_image:
break
# Other config lines will be simply copied
else:
file_content += line
else:
# File doesn't exists
file_content = "[Greeter]\n"
file_content += "background=/usr/share/pixmaps/cinnamon_dynamic_wallpaper/login_image.jpg"
else:
# File doesn't exists
file_content = "[Greeter]\n"
file_content += "background=/tmp/cinnamon_dynamic_wallpaper/login_image.jpg"
# Create the file
with open(file_location, "w") as conf_file:
conf_file.write(file_content)
conf_file.close()
# Create the file
with open(file_location, "w") as conf_file:
conf_file.write(file_content)
conf_file.close()
# Move it to /etc/lightdm
if os.path.isfile("/etc/lightdm/slick-greeter.conf"):
subprocess.call(['pkexec', 'rm', '/etc/lightdm/slick-greeter.conf', 'mv', file_location, '/etc/lightdm/'])
else:
subprocess.call(['pkexec', 'mv', file_location, '/etc/lightdm/'])
# Move it to /etc/lightdm
if os.path.isfile("/etc/lightdm/slick-greeter.conf"):
subprocess.call(['pkexec', 'rm', '/etc/lightdm/slick-greeter.conf', 'mv', file_location, '/etc/lightdm/'])
else:
subprocess.call(['pkexec', 'mv', file_location, '/etc/lightdm/'])