14 Commits
v.1.0 ... v.1.3

99 changed files with 284 additions and 94 deletions

1
.gitignore vendored
View File

@@ -4,3 +4,4 @@ extracted/
custom_images/
*.txt
selected/
__pycache__

View File

@@ -1,3 +1,17 @@
# Version 1.3
- Adding option to stretch the image over multiple displays
# Version 1.2
- Compatibility with Cinnamon 4.8 and higher
- Notification on first start
- Bugfix: No more restart needed after first enable
- Load at first start a predefined dynamic wallpaper
- More informations in the settings
# Version 1.1
- Compatibility with Cinnamon 5.4 and 5.8
- Two new image sets
# Version 1.0
- Offline sun time calculation
- Online location estimation or manual input

View File

@@ -6,27 +6,43 @@
Based on a location, this extension calculates the periods of a day and switches the background image of your Cinnamon desktop. The extension offers the choice between a set of included wallpapers or to select a HEIC-file.
### Features
- 6 included image sets
- 8 included image sets
- 9 day periods
- HEIF converter
- Image configuration assistent with simple one-click setup for image choose
- Online location estimation
- Online location estimation or offline with manual latitude and longitude input
- Offline sun angles estimation
- Image stretching over multiple displays or repeat image for every display
### Tested Cinnamon versions
- 5.6
- 4.8 (Mint 20.1)
- 5.0 (Mint 20.2)
- 5.2 (Mint 20.3)
- 5.4 (Mint 21)
- 5.6 (Mint 21.1)
- 5.8 (Mint 21.2)
### Technology
- Using `JavaScript` for
- Sun angle estimation
- Location estimation
- Change of the desktop wallpapers
- `Python` displays the Image Configurator
- Image Configurator UI was written with `Glade`
## Installation
### From Built-in Extension Manager
![](res/download-manager.png)
1. Open "Extensions" in Linux Mint or any other distribution with Cinnamon as Desktop Environment
2. Click on "Download"
3. Search and download it
### From the repo
1. Download the Repository
2. Extract the files
3. Copy the folder `cinnamon-dynamic-wallpaper@TobiZog` to `~/.local/share/cinnamon/extensions/`
### From Built-in Extension Manager
1. Open "Extensions" in Linux Mint or any other distribution with Cinnamon as Desktop Environment
2. Click on "Download"
3. Search and download it
## How to use it
1. Active the Extension via Cinnamon Extension Manager
2. Open the settings
@@ -44,8 +60,12 @@ The image sets are from https://github.com/adi1090x/dynamic-wallpaper
| Aurora | Beach | Bitday |
| ------ | ----- | ------ |
| ![](cinnamon-dynamic-wallpaper@TobiZog/images/included_image_sets/aurora/5.jpg) | ![](cinnamon-dynamic-wallpaper@TobiZog/images/included_image_sets/beach/4.jpg) | ![](cinnamon-dynamic-wallpaper@TobiZog/images/included_image_sets/bitday/4.jpg) |
| ![](cinnamon-dynamic-wallpaper@TobiZog/5.4/images/included_image_sets/aurora/5.jpg) | ![](cinnamon-dynamic-wallpaper@TobiZog/5.4/images/included_image_sets/beach/4.jpg) | ![](cinnamon-dynamic-wallpaper@TobiZog/5.4/images/included_image_sets/bitday/4.jpg) |
| Lakeside | Mountains | Sahara |
| Cliffs | Gradient | Lakeside |
| -------- | --------- | ------ |
| ![](cinnamon-dynamic-wallpaper@TobiZog/images/included_image_sets/lakeside/4.jpg) | ![](cinnamon-dynamic-wallpaper@TobiZog/images/included_image_sets/mountains/4.jpg) | ![](cinnamon-dynamic-wallpaper@TobiZog/images/included_image_sets/sahara/4.jpg) |
| ![](cinnamon-dynamic-wallpaper@TobiZog/5.4/images/included_image_sets/cliffs/4.jpg) | ![](cinnamon-dynamic-wallpaper@TobiZog/5.4/images/included_image_sets/gradient/4.jpg) | ![](cinnamon-dynamic-wallpaper@TobiZog/5.4/images/included_image_sets/lakeside/4.jpg) |
| Mountains | Sahara |
| --------- | ------ |
| ![](cinnamon-dynamic-wallpaper@TobiZog/5.4/images/included_image_sets/mountains/4.jpg) | ![](cinnamon-dynamic-wallpaper@TobiZog/5.4/images/included_image_sets/sahara/4.jpg) |

View File

@@ -0,0 +1 @@
../5.4/extension.js

View File

@@ -0,0 +1 @@
../5.4/icon/

View File

@@ -0,0 +1 @@
../5.4/icons/icon.png

View File

@@ -0,0 +1 @@
../5.4/icons/

View File

@@ -0,0 +1 @@
../../5.4/image-configurator/data/

View File

@@ -0,0 +1 @@
../../5.4/image-configurator/image-configurator.glade

View File

@@ -0,0 +1,6 @@
import os
import windowHandler
if __name__ == "__main__":
wh = windowHandler.WindowHandler(os.path.expanduser("~") + "/.cinnamon/configs/cinnamon-dynamic-wallpaper@TobiZog/cinnamon-dynamic-wallpaper@TobiZog.json")
wh.showMainWindow()

View File

@@ -0,0 +1 @@
../../5.4/image-configurator/windowHandler.py

View File

@@ -0,0 +1 @@
../5.4/images/

View File

@@ -0,0 +1 @@
../5.4/scripts/

View File

@@ -0,0 +1 @@
../5.4/settings-schema.json

View File

@@ -58,27 +58,66 @@ CinnamonDynamicWallpaperExtension.prototype = {
_init: function(uuid) {
this.settings = new Settings.ExtensionSettings(this, uuid);
this.bindSettings("sw_auto_location", "autolocation", this.updateLocation)
this.bindSettings("sc_location_refresh_time", "locationRefreshTime")
this.bindSettings("etr_latitude", "latitude", this.updateLocation)
this.bindSettings("etr_longitude", "longitude", this.updateLocation)
this.bindSettings("etr_img_morning_twilight", "img_morning_twilight", this.setImageToTime)
this.bindSettings("etr_img_sunrise", "img_sunrise", this.setImageToTime)
this.bindSettings("etr_img_morning", "img_morning", this.setImageToTime)
this.bindSettings("etr_img_noon", "img_noon", this.setImageToTime)
this.bindSettings("etr_img_afternoon", "img_afternoon", this.setImageToTime)
this.bindSettings("etr_img_evening", "img_evening", this.setImageToTime)
this.bindSettings("etr_img_sunset", "img_sunset", this.setImageToTime)
this.bindSettings("etr_img_night_twilight", "img_night_twilight", this.setImageToTime)
this.bindSettings("etr_img_night", "img_night", this.setImageToTime)
// Image set
this.bindSettings("sw_image_stretch", "imageStretch", this.settingsUpdated)
// Location estimation
this.bindSettings("sw_auto_location", "autolocation", this.settingsUpdated)
this.bindSettings("sc_location_refresh_time", "locationRefreshTime", this.settingsUpdated)
this.bindSettings("etr_latitude", "latitude", this.settingsUpdated)
this.bindSettings("etr_longitude", "longitude", this.settingsUpdated)
// Time periods
this.bindSettings("tv_times", "tvTimes")
// Image Configurator
this.bindSettings("etr_img_morning_twilight", "img_morning_twilight", this.settingsUpdated)
this.bindSettings("etr_img_sunrise", "img_sunrise", this.settingsUpdated)
this.bindSettings("etr_img_morning", "img_morning", this.settingsUpdated)
this.bindSettings("etr_img_noon", "img_noon", this.settingsUpdated)
this.bindSettings("etr_img_afternoon", "img_afternoon", this.settingsUpdated)
this.bindSettings("etr_img_evening", "img_evening", this.settingsUpdated)
this.bindSettings("etr_img_sunset", "img_sunset", this.settingsUpdated)
this.bindSettings("etr_img_night_twilight", "img_night_twilight", this.settingsUpdated)
this.bindSettings("etr_img_night", "img_night", this.settingsUpdated)
// Check for the first startup
if (this.settings.getValue("first_start")) {
// Welcome notification
this.showNotification("Welcome to Cinnamon Dynamic Wallpaper",
"Check the preferences to choose a dynamic wallpaper", true)
// Hide the notification on system restart
this.settings.setValue("first_start", false)
// Create the folder for the selected images
Util.spawnCommandLine("mkdir " + DIRECTORY.path + "/images/selected/")
// Link the default wallpaper to the folder
for (let i = 1; i <= 9; i++) {
Util.spawnCommandLine("ln -s " +
DIRECTORY.path + "/images/included_image_sets/lakeside/" + i + ".jpg " +
DIRECTORY.path + "/images/selected/" + i + ".jpg");
}
}
// Set image initial at desktop wallpaper
this.setImageToTime()
// Start the main loop, checks in fixed time periods the
this._loop()
},
/**
* Binding the settings objects
*
* @param {*} ui_name Name of preference in settings-schema.json
* @param {*} js_name Name of preference in JavaScript
* @param {*} func Function to call on change
*/
bindSettings: function (ui_name, js_name, func = this.on_settings_changed) {
this.settings.bindProperty(
Settings.BindingDirection.IN,
@@ -89,12 +128,24 @@ CinnamonDynamicWallpaperExtension.prototype = {
},
/**
* Handles changes in settings
*/
settingsUpdated: function() {
lastDayTime = suntimes.DAYPERIOD.NONE
this.updateLocation()
this.setImageToTime()
},
/**
* Displaying a desktop notification
*
* @param {string} title The Title in the notification
* @param {string} text The text in the notification
* @param {boolean} showOpenSettings Display the "Open settings" button in the notification, defaults to false
* @param {boolean} showOpenSettings Display the "Open settings" button in the notification,
* defaults to false
*/
showNotification: function (title, text, showOpenSettings = false) {
let source = new MessageTray.Source(this.uuid);
@@ -135,12 +186,23 @@ CinnamonDynamicWallpaperExtension.prototype = {
changeWallpaper: function(imageURI) {
let gSetting = new Gio.Settings({schema: 'org.cinnamon.desktop.background'});
gSetting.set_string('picture-uri', imageURI);
if (this.imageStretch) {
gSetting.set_string('picture-options', 'spanned')
}
else
{
gSetting.set_string('picture-options', 'zoom')
}
Gio.Settings.sync();
gSetting.apply();
},
/**
* Estimate the right image based on time period of the day
*/
setImageToTime: function() {
let times = suntimes.calcTimePeriod(this.latitude, this.longitude)
let now = new Date()
@@ -159,7 +221,6 @@ CinnamonDynamicWallpaperExtension.prototype = {
for(let i = 0; i < timesArray.length; i++) {
if(timesArray[i][0] <= now && now <= timesArray[i][1] && i != lastDayTime) {
global.log(PATH + "/res/images/selected/" + imageSet[i])
this.changeWallpaper("file://" + PATH + "/images/selected/" + imageSet[i])
lastDayTime = i
@@ -184,7 +245,10 @@ CinnamonDynamicWallpaperExtension.prototype = {
"\nNight:\t\t\t\t" + convertToTimeString(timesArray[8][0]) + " - " + convertToTimeString(timesArray[8][1])
},
/**
* Get the location of the user
* Callback for changes in preferences
*/
updateLocation: function () {
if (this.autolocation) {
let loc = location.estimateLocation()
@@ -195,34 +259,11 @@ CinnamonDynamicWallpaperExtension.prototype = {
this.longitude = this.longitude
}
// Refresh the image information, if it's necessary
this.setImageToTime()
// Update the update information
lastLocationUpdate = new Date()
},
/******************** UI Callbacks ********************/
/**
* Callback for settings-schema
* Opens the external heic-importer window
*/
openImageConfigurator: function() {
Util.spawnCommandLine("/usr/bin/env python3 " + DIRECTORY.path + "/image-configurator/image-configurator.py");
},
/**
* Callback for settings-schema
* Opens the browser and navigate to the URL of the respository
*/
openRepoWebsite: function() {
Util.spawnCommandLine("xdg-open https://github.com/TobiZog/cinnamon-dynamic-wallpaper");
},
/**
* Main loop
*/
@@ -238,6 +279,45 @@ CinnamonDynamicWallpaperExtension.prototype = {
// Refresh every 60 seconds
Mainloop.timeout_add_seconds(60, Lang.bind(this, this._loop));
}
},
/******************** UI Callbacks ********************/
/**
* Callback for settings-schema
* Opens the external image configurator window
*/
openImageConfigurator: function() {
Util.spawnCommandLine("/usr/bin/env python3 " +
DIRECTORY.path + "/image-configurator/image-configurator.py");
},
/**
* Callback for settings-schema
* Opens the browser and navigates to the URL of the respository
*/
openRepoWebsite: function() {
Util.spawnCommandLine("xdg-open https://github.com/TobiZog/cinnamon-dynamic-wallpaper");
},
/**
* Callback for settings-schema
* Opens the browser and navigates to the URL of the Cinnamon Spices extension
*/
openSpicesWebsite: function() {
Util.spawnCommandLine("xdg-open https://cinnamon-spices.linuxmint.com/extensions/view/97")
},
/**
* Callback for settings-schema
* Opens the browser and navigates to the GitHub issue page
*/
openIssueWebsite: function() {
Util.spawnCommandLine("xdg-open https://github.com/TobiZog/cinnamon-dynamic-wallpaper/issues/new")
}
}
@@ -266,13 +346,6 @@ function enable() {
Util.spawnCommandLine("apturl apt://libheif-examples");
}
// Display the welcome notification on activation
// extension.showNotification(
// APPNAME,
// "Welcome to " + APPNAME + "! Open the settings and configure the extensions.",
// true
// );
return extension;
}

View File

@@ -0,0 +1 @@
icons/icon.png

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -0,0 +1,6 @@
from enum import Enum
class Source(Enum):
SELECTED = 0 # Load previous selected images
EXTRACT = 1 # Use a custom image set from a heic file
SET = 2 # Use an included image set

View File

@@ -853,7 +853,7 @@
<property name="window-position">center</property>
<property name="default-width">1024</property>
<property name="default-height">768</property>
<property name="icon">../icons/icon.png</property>
<property name="icon">../../icon.png</property>
<signal name="destroy" handler="onDestroy" swapped="no"/>
<child>
<object class="GtkStack" id="stack_main">

View File

@@ -0,0 +1,6 @@
import os
import windowHandler
if __name__ == "__main__":
wh = windowHandler.WindowHandler(os.path.expanduser("~") + "/.config/cinnamon/spices/cinnamon-dynamic-wallpaper@TobiZog/cinnamon-dynamic-wallpaper@TobiZog.json")
wh.showMainWindow()

View File

@@ -1,28 +1,25 @@
import gi, os, glob, json, shutil, enum, threading
import gi, os, glob, json, shutil, threading, subprocess
from data.enum import Source
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, GdkPixbuf
PROJECT_DIR = os.path.dirname(os.path.dirname(__file__)) + "/"
UI_PATH = PROJECT_DIR + "image-configurator/" + "image-configurator.glade"
CONFIGURATOR_DIR = os.path.dirname(os.path.abspath(__file__))
PROJECT_DIR = os.path.dirname(CONFIGURATOR_DIR) + "/"
UI_PATH = CONFIGURATOR_DIR + "/" + "image-configurator.glade"
IMAGE_DIR = PROJECT_DIR + "images/"
IMAGE_EXTRACT_DIR = IMAGE_DIR + "extracted/"
IMAGE_SETS_DIR = IMAGE_DIR + "included_image_sets/"
IMAGE_SELECTED_DIR = IMAGE_DIR + "selected/"
PREF_PATH = os.path.expanduser("~") + \
"/.config/cinnamon/spices/cinnamon-dynamic-wallpaper@TobiZog/cinnamon-dynamic-wallpaper@TobiZog.json"
class Source(enum.Enum):
SELECTED = 0 # Load previous selected images
EXTRACT = 1 # Use a custom image set from a heic file
SET = 2 # Use an included image set
class WindowHandler:
def __init__(self, pref_path: str) -> None:
class ImageConfigurator:
def __init__(self) -> None:
########### Class variables ###########
self.pref_path = pref_path
self.pref_vars = [
"etr_img_morning_twilight",
"etr_img_sunrise",
@@ -39,6 +36,8 @@ class ImageConfigurator:
"aurora",
"beach",
"bitday",
"cliffs",
"gradient",
"lakeside",
"mountains",
"sahara"
@@ -107,7 +106,6 @@ class ImageConfigurator:
self.image_source = Source.SELECTED
# Load preferences
self.loadFromSettings()
@@ -127,8 +125,9 @@ class ImageConfigurator:
def loadFromSettings(self):
""" Load preferences from the Cinnamon preference file
"""
#try:
# Load the settings
with open(PREF_PATH, "r") as pref_file:
with open(self.pref_path, "r") as pref_file:
pref_data = json.load(pref_file)
@@ -161,13 +160,15 @@ class ImageConfigurator:
self.cb_previews[i].set_active(j)
else:
self.image_source = Source.SET
#except:
# pass
def writeToSettings(self):
""" Save preferences to the Cinnamon preference file
"""
# Load the settings
with open(PREF_PATH, "r") as pref_file:
with open(self.pref_path, "r") as pref_file:
pref_data = json.load(pref_file)
@@ -185,7 +186,7 @@ class ImageConfigurator:
# Write the settings
with open(PREF_PATH, "w") as pref_file:
with open(self.pref_path, "w") as pref_file:
json.dump(pref_data, pref_file, separators=(',', ':'), indent=4)
@@ -364,8 +365,3 @@ class ImageConfigurator:
""" UI signal if the window is closed by the user
"""
Gtk.main_quit()
if __name__ == "__main__":
ic = ImageConfigurator()
ic.showMainWindow()

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 293 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 KiB

View File

@@ -19,15 +19,19 @@
"title": "About",
"sections": [
"sec_project",
"sec_github"
"sec_github",
"sec_report_issue"
]
},
"sec_image_configuration": {
"type": "section",
"title": "Image set",
"keys": [
"lb_image_configuration",
"btn_config_images"
"btn_config_images",
"sw_image_stretch"
]
},
"sec_location": {
@@ -52,7 +56,9 @@
"title": "About the project",
"keys": [
"lb_about",
"lb_author"
"lb_author",
"lb_spices",
"btn_spices"
]
},
"sec_github": {
@@ -62,8 +68,18 @@
"lb_repository",
"btn_open_repository"
]
},
"sec_report_issue": {
"type": "section",
"title": "Report an issue",
"keys": [
"lb_report_issue",
"btn_report_issue"
]
}
},
"lb_image_configuration": {
"type": "label",
"description": "Choose an included image set or import a heic-file with the Image Configurator"
@@ -73,6 +89,11 @@
"description": "Image Configurator",
"callback": "openImageConfigurator"
},
"sw_image_stretch": {
"type": "switch",
"description": "Expand image over all displays",
"default": true
},
"sw_auto_location": {
"type": "switch",
"default": true,
@@ -104,6 +125,8 @@
"description": "Time sections today",
"default": ""
},
"lb_about": {
"type": "label",
"description": "Based on a location, this extension calculates the periods of a day and switch the background image of your Cinnamon desktop. The extension offers the choice between a set of predownloaded wallpapers or to select a custom set of images."
@@ -112,6 +135,16 @@
"type": "label",
"description": "Developed by TobiZog"
},
"lb_spices": {
"type": "label",
"description": "If you want more information or rate the extension, you can visit the site Cinnamon Spices Website."
},
"btn_spices": {
"type": "button",
"description": "Cinnamon Dynamic Wallpaper at Cinnamon Spices Website",
"callback": "openSpicesWebsite"
},
"lb_repository": {
"type": "label",
"description": "This project is Open Source. You can visit the whole source code of this extension on GitHub"
@@ -121,54 +154,71 @@
"description": "Open the Repository",
"callback": "openRepoWebsite"
},
"lb_report_issue": {
"type": "label",
"description": "Do you find an issue? Or want a new feature? Go to the GitHub repository and create a new issue."
},
"btn_report_issue": {
"type": "button",
"description": "Submit an Issue",
"callback": "openIssueWebsite"
},
"etr_choosen_image_set": {
"type": "entry",
"default": "",
"default": "lakeside",
"description": ""
},
"etr_img_morning_twilight": {
"type": "entry",
"default": "",
"default": "1.jpg",
"description": ""
},
"etr_img_sunrise": {
"type": "entry",
"default": "",
"default": "2.jpg",
"description": ""
},
"etr_img_morning": {
"type": "entry",
"default": "",
"default": "3.jpg",
"description": ""
},
"etr_img_noon": {
"type": "entry",
"default": "",
"default": "4.jpg",
"description": ""
},
"etr_img_afternoon": {
"type": "entry",
"default": "",
"default": "5.jpg",
"description": ""
},
"etr_img_evening": {
"type": "entry",
"default": "",
"default": "6.jpg",
"description": ""
},
"etr_img_sunset": {
"type": "entry",
"default": "",
"default": "7.jpg",
"description": ""
},
"etr_img_night_twilight": {
"type": "entry",
"default": "",
"default": "8.jpg",
"description": ""
},
"etr_img_night": {
"type": "entry",
"default": "",
"default": "9.jpg",
"description": ""
},
"first_start": {
"type": "generic",
"default": true
}
}

View File

@@ -1 +1 @@
icons/icon.png
5.4/icons/icon.png

View File

@@ -2,9 +2,15 @@
"uuid": "cinnamon-dynamic-wallpaper@TobiZog",
"name": "Cinnamon Dynamic Wallpaper",
"description": "Cinnamon extension for dynamic desktop backgrounds based on time and location",
"version": "1.0",
"version": "1.3",
"multiversion": true,
"cinnamon-version": [
"5.6"
"4.8",
"5.0",
"5.2",
"5.4",
"5.6",
"5.8"
],
"max-instances": 1,
"url": "https://github.com/TobiZog/cinnamon-dynamic-wallpaper"

BIN
res/download-manager.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB