diff --git a/cinnamon-dynamic-wallpaper@TobiZog/5.4/res/images/dynamic_background_example b/cinnamon-dynamic-wallpaper@TobiZog/5.4/res/images/dynamic_background_example deleted file mode 100644 index 7cfe217..0000000 Binary files a/cinnamon-dynamic-wallpaper@TobiZog/5.4/res/images/dynamic_background_example and /dev/null differ diff --git a/cinnamon-dynamic-wallpaper@TobiZog/5.4/res/images/dynamic_background_example.jpg b/cinnamon-dynamic-wallpaper@TobiZog/5.4/res/images/dynamic_background_example.jpg deleted file mode 100644 index 6fc12d6..0000000 Binary files a/cinnamon-dynamic-wallpaper@TobiZog/5.4/res/images/dynamic_background_example.jpg and /dev/null differ diff --git a/cinnamon-dynamic-wallpaper@TobiZog/5.4/res/preferences.glade b/cinnamon-dynamic-wallpaper@TobiZog/5.4/res/preferences.glade index 6148d88..62f9001 100644 --- a/cinnamon-dynamic-wallpaper@TobiZog/5.4/res/preferences.glade +++ b/cinnamon-dynamic-wallpaper@TobiZog/5.4/res/preferences.glade @@ -461,7 +461,7 @@ True False 16 - label + label @@ -517,7 +517,7 @@ True False - 00:00 - 00:59 + 00:00 - 00:59 @@ -531,7 +531,7 @@ True False - 02:00 - 02:59 + 02:00 - 02:59 @@ -545,7 +545,7 @@ True False - 04:00 - 04:59 + 04:00 - 04:59 @@ -559,7 +559,7 @@ True False - 06:00 - 06:59 + 06:00 - 06:59 @@ -573,7 +573,7 @@ True False - 08:00 - 08:59 + 08:00 - 08:59 @@ -789,7 +789,7 @@ True False - 01:00 - 01:59 + 01:00 - 01:59 @@ -803,7 +803,7 @@ True False - 03:00 - 03:59 + 03:00 - 03:59 @@ -817,7 +817,7 @@ True False - 05:00 - 05:59 + 05:00 - 05:59 @@ -831,7 +831,7 @@ True False - 07:00 - 07:59 + 07:00 - 07:59 @@ -845,7 +845,7 @@ True False - 09:00 - 09:59 + 09:00 - 09:59 @@ -1245,7 +1245,7 @@ 8 8 8 - label + label @@ -1432,7 +1432,7 @@ 8 8 8 - 23 + 23 vertical adjustment_hours5 23 @@ -1452,7 +1452,7 @@ 8 8 8 - : + : @@ -1467,7 +1467,7 @@ True True - 59 + 59 vertical adjustment_minutes5 59 @@ -1483,7 +1483,7 @@ True False - - + - @@ -1502,7 +1502,7 @@ 8 8 8 - 00:00 + 00:00 @@ -1529,7 +1529,7 @@ True 8 8 - 23 + 23 vertical adjustment_hours6 23 @@ -1549,7 +1549,7 @@ 8 8 8 - : + : @@ -1564,7 +1564,7 @@ True True - 59 + 59 vertical adjustment_minutes6 59 @@ -1580,7 +1580,7 @@ True False - - + - @@ -1599,7 +1599,7 @@ 8 8 8 - 00:00 + 00:00 @@ -1626,7 +1626,7 @@ True 8 8 - 23 + 23 vertical adjustment_hours7 23 @@ -1646,7 +1646,7 @@ 8 8 8 - : + : @@ -1661,7 +1661,7 @@ True True - 59 + 59 vertical adjustment_minutes7 59 @@ -1677,7 +1677,7 @@ True False - - + - @@ -1696,7 +1696,7 @@ 8 8 8 - 00:00 + 00:00 @@ -1721,7 +1721,7 @@ True True - 23 + 23 vertical adjustment_hours8 23 @@ -1741,7 +1741,7 @@ 8 8 8 - : + : @@ -1756,7 +1756,7 @@ True True - 59 + 59 vertical adjustment_minutes8 59 @@ -1772,7 +1772,7 @@ True False - - + - @@ -1791,7 +1791,7 @@ 8 8 8 - 00:00 + 00:00 @@ -1820,7 +1820,7 @@ 8 8 8 - 23 + 23 vertical adjustment_hours9 23 @@ -1840,7 +1840,7 @@ 8 8 8 - : + : @@ -1855,7 +1855,7 @@ True True - 57 + 57 vertical adjustment_minutes9 57 @@ -1871,7 +1871,7 @@ True False - - + - @@ -1890,7 +1890,7 @@ 8 8 8 - 23:59 + 23:59 @@ -1989,7 +1989,7 @@ 8 8 8 - 00:00 + 00:00 @@ -2004,7 +2004,7 @@ True False - - + - @@ -2023,7 +2023,7 @@ 8 8 8 - 00:00 + 00:00 @@ -2052,7 +2052,7 @@ 8 8 8 - 23 + 23 vertical adjustment_hours2 23 @@ -2072,7 +2072,7 @@ 8 8 8 - : + : @@ -2087,7 +2087,7 @@ True True - 59 + 59 vertical adjustment_minutes2 59 @@ -2103,7 +2103,7 @@ True False - - + - @@ -2122,7 +2122,7 @@ 8 8 8 - 00:00 + 00:00 @@ -2151,7 +2151,7 @@ 8 8 8 - 23 + 23 vertical adjustment_hours3 23 @@ -2171,7 +2171,7 @@ 8 8 8 - : + : @@ -2186,7 +2186,7 @@ True True - 59 + 59 vertical adjustment_minutes3 59 @@ -2202,7 +2202,7 @@ True False - - + - @@ -2221,7 +2221,7 @@ 8 8 8 - 00:00 + 00:00 @@ -2250,7 +2250,7 @@ 8 8 8 - 23 + 23 vertical adjustment_hours4 23 @@ -2270,7 +2270,7 @@ 8 8 8 - : + : @@ -2285,7 +2285,7 @@ True True - 59 + 59 vertical adjustment_minutes4 59 @@ -2301,7 +2301,7 @@ True False - - + - @@ -2320,7 +2320,7 @@ 8 8 8 - 00:00 + 00:00 @@ -2345,7 +2345,7 @@ True True - 23 + 23 vertical adjustment_hours1 23 @@ -2365,7 +2365,7 @@ 8 8 8 - : + : @@ -2380,7 +2380,7 @@ True True - 59 + 59 vertical adjustment_minutes1 59 @@ -2396,7 +2396,7 @@ True False - - + - @@ -2415,7 +2415,7 @@ 8 8 8 - 00:00 + 00:00 @@ -2553,7 +2553,7 @@ True False start - Dynamic Background color + Login Screen @@ -2564,6 +2564,80 @@ 2 + + + True + False + none + False + + + True + True + + + True + False + 12 + 12 + 12 + 12 + 12 + 12 + + + True + False + start + True + Set the background image as Login Screen background + + + False + True + 0 + + + + + True + True + + + + False + True + 1 + + + + + + + + + False + True + 3 + 3 + + + + + True + False + start + Dynamic Background color + + + + + + False + True + 4 + + True @@ -2602,6 +2676,7 @@ True True + False @@ -2618,7 +2693,7 @@ False True 3 - 3 + 5 @@ -2630,7 +2705,7 @@ False True - 4 + 6 diff --git a/cinnamon-dynamic-wallpaper@TobiZog/5.4/settings-schema.json b/cinnamon-dynamic-wallpaper@TobiZog/5.4/settings-schema.json index 61fa3b5..1a87cd6 100644 --- a/cinnamon-dynamic-wallpaper@TobiZog/5.4/settings-schema.json +++ b/cinnamon-dynamic-wallpaper@TobiZog/5.4/settings-schema.json @@ -130,5 +130,9 @@ "period_9_custom_start_time": { "type": "generic", "default": "21:00" + }, + "login_image": { + "type": "generic", + "default": true } } \ No newline at end of file diff --git a/cinnamon-dynamic-wallpaper@TobiZog/5.4/src/model/main_view_model.py b/cinnamon-dynamic-wallpaper@TobiZog/5.4/src/model/main_view_model.py index d42f739..5821df0 100644 --- a/cinnamon-dynamic-wallpaper@TobiZog/5.4/src/model/main_view_model.py +++ b/cinnamon-dynamic-wallpaper@TobiZog/5.4/src/model/main_view_model.py @@ -2,7 +2,7 @@ from gi.repository import Gio, Gdk # Packages -import os, time, gi, locale +import os, time, locale, subprocess, sys from PIL import Image # Local scripts @@ -183,9 +183,20 @@ class Main_View_Model: self.current_image_uri = self.cinnamon_prefs.source_folder + self.cinnamon_prefs.period_images[i] break - # Set the background + # Update the background self.background_settings['picture-uri'] = "file://" + self.current_image_uri + # 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") + + # 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") + # Set background stretching self.background_settings['picture-options'] = self.cinnamon_prefs.picture_aspect @@ -269,3 +280,52 @@ class Main_View_Model: except: self.background_settings['primary-color'] = "#000000" self.background_settings['secondary-color'] = "#000000" + + + def set_login_image(self): + """ Writes a path to file in /tmp/cinnamon_dynamic_wallpaper to display the wallpaper on the login screen + """ + # New config file content + file_content = "" + + # 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 + print(line) + 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: + 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=/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() + + # 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/']) diff --git a/cinnamon-dynamic-wallpaper@TobiZog/5.4/src/service/cinnamon_pref_handler.py b/cinnamon-dynamic-wallpaper@TobiZog/5.4/src/service/cinnamon_pref_handler.py index 2cd5d59..b7bc03d 100644 --- a/cinnamon-dynamic-wallpaper@TobiZog/5.4/src/service/cinnamon_pref_handler.py +++ b/cinnamon-dynamic-wallpaper@TobiZog/5.4/src/service/cinnamon_pref_handler.py @@ -73,6 +73,8 @@ class Cinnamon_Pref_Handler: self.extract_json('period_9_custom_start_time') ] + self.login_image = self.extract_json('login_image') + def value_to_json(self, parameter: str, value: str): """ Storing safely a value to the dictionary @@ -127,6 +129,7 @@ class Cinnamon_Pref_Handler: self.value_to_json('period_7_custom_start_time', self.period_custom_start_time[7]) self.value_to_json('period_8_custom_start_time', self.period_custom_start_time[8]) self.value_to_json('period_9_custom_start_time', self.period_custom_start_time[9]) + self.value_to_json('login_image', self.login_image) # Write to file diff --git a/cinnamon-dynamic-wallpaper@TobiZog/5.4/src/view/main_window.py b/cinnamon-dynamic-wallpaper@TobiZog/5.4/src/view/main_window.py index 2de0c29..efa1173 100644 --- a/cinnamon-dynamic-wallpaper@TobiZog/5.4/src/view/main_window.py +++ b/cinnamon-dynamic-wallpaper@TobiZog/5.4/src/view/main_window.py @@ -150,6 +150,7 @@ class Main_Window: # Page 3: Behaviour self.cb_picture_aspect: Gtk.ComboBox = self.builder.get_object("cb_picture_aspect") self.sw_dynamic_background_color: Gtk.Switch = self.builder.get_object("sw_dynamic_background_color") + self.sw_login_image: Gtk.Switch = self.builder.get_object("sw_login_image") def show(self): @@ -178,6 +179,7 @@ class Main_Window: self.add_items_to_combo_box(self.cb_picture_aspect, self.view_model.picture_aspects) self.set_active_combobox_item(self.cb_picture_aspect, self.view_model.cinnamon_prefs.picture_aspect) self.sw_dynamic_background_color.set_active(self.view_model.cinnamon_prefs.dynamic_background_color) + self.sw_login_image.set_active(self.view_model.cinnamon_prefs.login_image) # Show the main window @@ -693,6 +695,16 @@ class Main_Window: """ self.view_model.cinnamon_prefs.dynamic_background_color = state + + def on_sw_login_image_state_set(self, _: Gtk.Switch, state: bool): + """ User switches login background image on or off + + Args: + _ (Gtk.Switch): Used Switch + state (bool): Current state + """ + self.view_model.cinnamon_prefs.login_image = state + # About @@ -747,6 +759,7 @@ class Main_Window: # Use the new settings self.view_model.refresh_image() self.view_model.set_background_gradient() + self.view_model.set_login_image() def on_destroy(self, *args):