Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 0.2.1a1 #25

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Changelog

## [0.2.0a1](https://github.com/OpenVoiceOS/ovos-PHAL-plugin-wallpaper-manager/tree/0.2.0a1) (2024-11-14)
## [0.2.1a1](https://github.com/OpenVoiceOS/ovos-PHAL-plugin-wallpaper-manager/tree/0.2.1a1) (2025-01-28)

[Full Changelog](https://github.com/OpenVoiceOS/ovos-PHAL-plugin-wallpaper-manager/compare/0.1.2...0.2.0a1)
[Full Changelog](https://github.com/OpenVoiceOS/ovos-PHAL-plugin-wallpaper-manager/compare/0.2.0...0.2.1a1)

**Merged pull requests:**

- feat: default wallpapers bundled with plugin [\#22](https://github.com/OpenVoiceOS/ovos-PHAL-plugin-wallpaper-manager/pull/22) ([JarbasAl](https://github.com/JarbasAl))
- Fix non-default wallpaper handling [\#24](https://github.com/OpenVoiceOS/ovos-PHAL-plugin-wallpaper-manager/pull/24) ([NeonDaniel](https://github.com/NeonDaniel))



Expand Down
26 changes: 18 additions & 8 deletions ovos_PHAL_plugin_wallpaper_manager/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import hashlib
import os
import shutil
from typing import List
from typing import List, Optional

import requests
from ovos_bus_client.message import Message
Expand Down Expand Up @@ -75,23 +75,28 @@ def populate_wallpapers(self):
if not os.path.exists(base):
LOG.error(f"Default wallpapers directory not found: {base}")
return
collection = []
valid_extensions = {'.jpg', '.jpeg', '.png', '.gif'}
try:
# Copy default wallpapers to the wallpaper directory
for f in os.listdir(base):
if not any(f.lower().endswith(ext) for ext in valid_extensions):
continue
src = os.path.abspath(os.path.join(base, f))
if not src.startswith(os.path.abspath(base)):
LOG.warning(f"Skipping file outside wallpapers directory: {src}")
continue
LOG.debug(f"Found wallpaper: {f}")
dst = os.path.join(self.local_wallpaper_storage, os.path.basename(f))
shutil.copy2(src, dst)
collection.append(dst)
dst = os.path.join(self.local_wallpaper_storage,
os.path.basename(f))
if not os.path.exists(dst):
LOG.debug(f"Adding default wallpaper: {f}")
shutil.copy2(src, dst)
except OSError as e:
LOG.error(f"Error copying wallpapers: {e}")
return
# Collection is all valid files in the `wallpapers` directory
collection = [os.path.join(self.local_wallpaper_storage, f) for f in
os.listdir(self.local_wallpaper_storage) if
any(f.lower().endswith(ext) for ext in valid_extensions)]

provider_name = "ovos-PHAL-plugin-wallpaper-manager"
self.registered_providers[provider_name] = {
Expand Down Expand Up @@ -282,7 +287,7 @@ def handle_get_wallpaper(self, message):
self.bus.emit(message.response(data={"url": self.selected_wallpaper}))

@staticmethod
def get_wallpaper_idx(collection, filename):
def get_wallpaper_idx(collection, filename) -> Optional[int]:
try:
index_element = collection.index(filename)
return index_element
Expand All @@ -298,8 +303,13 @@ def handle_change_wallpaper(self, message: Message):
"""
LOG.debug(f"current wallpaper provider: {self.selected_provider}")
if len(self.wallpaper_collection) > 0:
current_idx = self.get_wallpaper_idx(self.wallpaper_collection, self.selected_wallpaper)
current_idx = self.get_wallpaper_idx(self.wallpaper_collection,
self.selected_wallpaper)
final_idx = len(self.wallpaper_collection) - 1
if current_idx is None:
LOG.warning("current wallpaper is not from the configured "
"provider. Starting from 0")
current_idx = -1
LOG.debug(f"Getting new wallpaper. current={current_idx} "
f"final_idx={final_idx}")
if not current_idx == final_idx:
Expand Down
4 changes: 2 additions & 2 deletions ovos_PHAL_plugin_wallpaper_manager/version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# START_VERSION_BLOCK
VERSION_MAJOR = 0
VERSION_MINOR = 2
VERSION_BUILD = 0
VERSION_ALPHA = 0
VERSION_BUILD = 1
VERSION_ALPHA = 1
# END_VERSION_BLOCK