diff --git a/README.md b/README.md index 3fab0d8..6b49aa2 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,45 @@ RandomWallpaperGnome3 ===================== -Random Wallpapers for Gnome 3 is a gnome shell extension which fetches a random wallpaper from an online source and sets it as desktop background. +Random Wallpapers for Gnome 3 is a gnome-shell extension that fetches a random wallpaper from an online source and sets it as desktop background. ![Screenshot](/assets/screenshot.png) -## Installation (symlink to repository) +## Features + +* Many different online sources with filters + * Unsplash (https://unsplash.com/) + * Desktoppr (https://desktoppr.co/) + * Wallhaven (https://alpha.wallhaven.cc/) + * Reddit (https://reddit.com) + * Basically any JSON API/File ([Examples](https://github.com/ifl0w/RandomWallpaperGnome3/wiki/Generic-JSON-Source)) + * Chromecast Images + * NASA Picture of the day + * Bing Picture of the day + * Google Earth View +* History of previous images +* Set lock screen image +* Automatic renewal (Auto-Fetching) + +## Installation (symlink to the repository) Clone the repository and run `./install.sh` in the repository folder to make a symbolic link from the extensions folder to the git repository. This installation will depend on the repository folder, so do not delete the cloned folder. Then open the command prompt (Alt+F2) end enter `r` to restart the gnome session. -In the case you are using wayland, then no restart should be required. +In the case you are using Wayland, then no restart should be required. Now you should be able to activate the extension through the gnome-tweak-tool. __Installing this way has various advantages:__ * Switching between versions and branches. -* Updateing the extension with `git pull` +* Updating the extension with `git pull` ## Installation (manually) Clone or download the repository and copy the folder `randomwallpaper@iflow.space` in the repository to `~/.local/share/gnome-shell/extensions/`. Then open the command prompt (Alt+F2) end enter `r` to restart the gnome session. -In the case you are using wayland, then no restart should be required. +In the case you are using Wayland, then no restart should be required. Now you should be able to activate the extension through the gnome-tweak-tool. @@ -32,8 +48,14 @@ Run `./install uninstall` to delete the symbolic link. If you installed the extension manually you have to delete the extension folder `randomwallpaper@iflow.space` in `~/.local/share/gnome-shell/extensions/`. ## Debugging -Extension output can be followed with `./debug.sh`. Information should be printed using the existing logger class but can also be printed with `global.log()` (not recommended). +You can follow the output of the extension with `./debug.sh`. Information should be printed using the existing logger class but can also be printed with `global.log()` (not recommended). To debug the `prefs.js` use `./debug.sh perfs`. ## Compiling schemas This can be done with the command: `glib-compile-schemas randomwallpaper@iflow.space/schemas/` + +## Support Me +If you enjoy this extension and want to support the development, then feel free to buy me a coffee. :wink: :coffee: + + +[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RBLX73X4DPS7A) diff --git a/randomwallpaper@iflow.space/elements.js b/randomwallpaper@iflow.space/elements.js index cd6e44f..a8f610b 100644 --- a/randomwallpaper@iflow.space/elements.js +++ b/randomwallpaper@iflow.space/elements.js @@ -230,11 +230,11 @@ var NewWallpaperElement = new Lang.Class({ var StatusElement = new Lang.Class({ Name: 'StatusElement', - Extends: St.Icon, + + icon: null, _init: function () { - - this.parent({ + this.icon = new St.Icon({ icon_name: 'preferences-desktop-wallpaper-symbolic', style_class: 'system-status-icon' }); @@ -243,11 +243,11 @@ var StatusElement = new Lang.Class({ this.loadingTweenIn = { opacity: 20, - time: 1, + time: 2, transition: 'easeInOutSine', onComplete: function () { try { - Tweener.addTween(_this, _this.loadingTweenOut); + Tweener.addTween(_this.icon, _this.loadingTweenOut); } catch (e) { // swollow (not really important) } @@ -261,7 +261,7 @@ var StatusElement = new Lang.Class({ onComplete: function () { if (_this.isLoading) { try { - Tweener.addTween(_this, _this.loadingTweenIn); + Tweener.addTween(_this.icon, _this.loadingTweenIn); } catch (e) { // swollow (not really important) } @@ -276,13 +276,13 @@ var StatusElement = new Lang.Class({ startLoading: function () { this.isLoading = true; - Tweener.addTween(this, this.loadingTweenOut); + Tweener.addTween(this.icon, this.loadingTweenOut); }, stopLoading: function () { this.isLoading = false; - Tweener.removeTweens(this); - this.opacity = 255; + Tweener.removeTweens(this.icon); + this.icon.opacity = 255; } }); diff --git a/randomwallpaper@iflow.space/extension.js b/randomwallpaper@iflow.space/extension.js index 5525928..6e717a3 100644 --- a/randomwallpaper@iflow.space/extension.js +++ b/randomwallpaper@iflow.space/extension.js @@ -50,6 +50,7 @@ function enable() { function disable() { // disable Extension + panelEntry.clearHistoryList(); panelEntry.destroy(); // remove all signal handlers @@ -83,7 +84,7 @@ var RandomWallpaperEntry = new Lang.Class({ // Panelmenu Icon this.statusIcon = new CustomElements.StatusElement(); - this.actor.add_child(this.statusIcon); + this.actor.add_child(this.statusIcon.icon); // new wallpaper button this.newWallpaperItem = new CustomElements.NewWallpaperElement(); diff --git a/randomwallpaper@iflow.space/metadata.json b/randomwallpaper@iflow.space/metadata.json index 0a306c5..6824c8f 100644 --- a/randomwallpaper@iflow.space/metadata.json +++ b/randomwallpaper@iflow.space/metadata.json @@ -1,6 +1,5 @@ { "shell-version": [ - "3.20", "3.22", "3.24", "3.26", @@ -12,6 +11,6 @@ "name": "Random Wallpaper", "description": "Fetches a random wallpaper from an online source and sets it as desktop background. \nThe desktop background can be updated periodically or manually.", "version": 13, - "semantic-version": "2.3.0", + "semantic-version": "2.3.1", "url": "https://github.com/ifl0w/RandomWallpaperGnome3" } diff --git a/randomwallpaper@iflow.space/sourceAdapter.js b/randomwallpaper@iflow.space/sourceAdapter.js old mode 100644 new mode 100755 index ad3e3a1..6161ced --- a/randomwallpaper@iflow.space/sourceAdapter.js +++ b/randomwallpaper@iflow.space/sourceAdapter.js @@ -172,7 +172,7 @@ var UnsplashAdapter = new Lang.Class({ authorName = data.user.name; authorUrl = encodeURI(data.user.links.html); - imageLinkUrl = encodeURI(data.urls.raw + '&' + utmParameters); + imageLinkUrl = encodeURI(data.links.html); let downloadLocation = data.links.download_location + '?' + clientParam; downloadMessage = Soup.Message.new('GET', downloadLocation); @@ -194,7 +194,7 @@ var UnsplashAdapter = new Lang.Class({ let historyEntry = new HistoryModule.HistoryEntry(authorName, this.sourceName, encodeURI(downloadData.url)); historyEntry.source.sourceUrl = encodeURI(this.sourceUrl + '?' + utmParameters); historyEntry.source.authorUrl = encodeURI(authorUrl + '?' + utmParameters); - historyEntry.source.imageLinkUrl = imageLinkUrl; + historyEntry.source.imageLinkUrl = imageLinkUrl + '?' + utmParameters; callback(historyEntry); } } catch (e) { @@ -364,12 +364,16 @@ var RedditAdapter = new Lang.Class({ this._settings = new SettingsModule.Settings(RWG_SETTINGS_SCHEMA_REDDIT); }, + _ampDecode: function(string) { + return string.replace(/\&/g,'&'); + }, + requestRandomImage: function (callback) { let session = new Soup.SessionAsync(); const subreddits = this._settings.get('subreddits', 'string').split(',').map(s => s.trim()).join('+'); const require_sfw = this._settings.get('allow-sfw', 'boolean'); - const url = encodeURI(`https://www.reddit.com/r/${subreddits}.json`); + const url = encodeURI('https://www.reddit.com/r/' + subreddits + '.json'); let message = Soup.Message.new('GET', url); @@ -391,7 +395,7 @@ var RedditAdapter = new Lang.Class({ } const random = Math.floor(Math.random() * submissions.length); const submission = submissions[random].data; - const imageDownloadUrl = submission.preview.images[0].source.url; + const imageDownloadUrl = this._ampDecode(submission.preview.images[0].source.url); if (callback) { let historyEntry = new HistoryModule.HistoryEntry(null, 'Reddit', imageDownloadUrl);