diff --git a/README.md b/README.md index d399d22..3fab0d8 100644 --- a/README.md +++ b/README.md @@ -6,33 +6,34 @@ Random Wallpapers for Gnome 3 is a gnome shell extension which fetches a random ![Screenshot](/assets/screenshot.png) ## Installation (symlink to repository) -Run `git clone git@github.com:ifl0w/RandomWallpaperGnome3.git` to clone the repository. -Run `./install.sh` to make a symbolic link from the extensions folder to the git 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. + +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` ## Installation (manually) -Open the commandline and type the following lines: +Clone or download the repository and copy the folder `randomwallpaper@iflow.space` in the repository to `~/.local/share/gnome-shell/extensions/`. -``` -git clone git@github.com:ifl0w/RandomWallpaperGnome3.git -cp -r RandomWallpaperGnome3/randomwallpaper@iflow.space ~/.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. -Then open the command prompt (Alt+F2) end enter `r` without qotes. Now you should be able to activate the extension through the gnome-tweak-tool. ## Uninstall Run `./install uninstall` to delete the symbolic link. -If you installed the extension manually you have to delete the extension folder with `rm -rf ~/.local/share/gnome-shell/extensions/randomwallpaper@iflow.space`. +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). -To debug the prefs.js use `./debug.sh perfs`. +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/` diff --git a/assets/icon.png b/assets/icon.png index da3594c..bdff5af 100644 Binary files a/assets/icon.png and b/assets/icon.png differ diff --git a/assets/icon.svg b/assets/icon.svg index 65a781f..f1689a6 100644 --- a/assets/icon.svg +++ b/assets/icon.svg @@ -8,13 +8,17 @@ xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="100" - height="100" - viewBox="0 0 100 100" + width="120" + height="120" + viewBox="0 0 120 120" version="1.1" id="svg4" - sodipodi:docname="icon.svg" - inkscape:version="0.92.1 r"> + sodipodi:docname="icon_v2.svg" + inkscape:version="0.92.2 2405546, 2018-03-11" + style="enable-background:new" + inkscape:export-filename="/home/wolfgang/Develop/RandomWallpaperGnome3/assets/icon.svg.png" + inkscape:export-xdpi="212" + inkscape:export-ydpi="212"> @@ -50,6 +54,16 @@ x2="24" y2="12" gradientUnits="userSpaceOnUse" /> + + + - + fit-margin-top="10" + fit-margin-left="10" + fit-margin-right="10" + fit-margin-bottom="10" /> + + + + + diff --git a/assets/screenshot.png b/assets/screenshot.png index ccc3056..f799046 100644 Binary files a/assets/screenshot.png and b/assets/screenshot.png differ diff --git a/randomwallpaper@iflow.space/elements.js b/randomwallpaper@iflow.space/elements.js index 8217b8f..f40f924 100644 --- a/randomwallpaper@iflow.space/elements.js +++ b/randomwallpaper@iflow.space/elements.js @@ -96,7 +96,7 @@ var HistoryElement = new Lang.Class({ this.imageUrlItem = new PopupMenu.PopupMenuItem('Open Image In Browser'); this.imageUrlItem.connect('activate', () => { - Util.spawn(['xdg-open', this.historyEntry.source.imageUrl]); + Util.spawn(['xdg-open', this.historyEntry.source.imageLinkUrl]); }); this.menu.addMenuItem(this.imageUrlItem); diff --git a/randomwallpaper@iflow.space/history.js b/randomwallpaper@iflow.space/history.js index 155f76b..b6fc5e7 100644 --- a/randomwallpaper@iflow.space/history.js +++ b/randomwallpaper@iflow.space/history.js @@ -24,7 +24,8 @@ var HistoryEntry = new Lang.Class({ authorUrl: null, source: source, sourceUrl: null, - imageUrl: url + imageDownloadUrl: url, // URL used for downloading the image + imageLinkUrl: url // URL used for linking back to the website of the image }; }, }); diff --git a/randomwallpaper@iflow.space/metadata.json b/randomwallpaper@iflow.space/metadata.json index 25153a8..6e91ccd 100644 --- a/randomwallpaper@iflow.space/metadata.json +++ b/randomwallpaper@iflow.space/metadata.json @@ -3,13 +3,14 @@ "3.20", "3.22", "3.24", - "3.26" + "3.26", + "3.28" ], "uuid": "randomwallpaper@iflow.space", "settings-schema": "org.gnome.shell.extensions.space.iflow.randomwallpaper", "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": 10, - "semantic-version": "2.2.1", + "version": 11, + "semantic-version": "2.2.2", "url": "https://github.com/ifl0w/RandomWallpaperGnome3" } diff --git a/randomwallpaper@iflow.space/prefs.js b/randomwallpaper@iflow.space/prefs.js index 91d7e80..94829e1 100644 --- a/randomwallpaper@iflow.space/prefs.js +++ b/randomwallpaper@iflow.space/prefs.js @@ -14,7 +14,7 @@ const Gettext = imports.gettext.domain('space.iflow.randomwallpaper'); const RWG_SETTINGS_SCHEMA = 'org.gnome.shell.extensions.space.iflow.randomwallpaper'; const RWG_SETTINGS_SCHEMA_DESKTOPPER = 'org.gnome.shell.extensions.space.iflow.randomwallpaper.desktopper'; const RWG_SETTINGS_SCHEMA_UNSPLASH = 'org.gnome.shell.extensions.space.iflow.randomwallpaper.unsplash'; -const RWG_SETTINGS_SCHEMA_WALLHEAVEN = 'org.gnome.shell.extensions.space.iflow.randomwallpaper.wallheaven'; +const RWG_SETTINGS_SCHEMA_WALLHAVEN = 'org.gnome.shell.extensions.space.iflow.randomwallpaper.wallhaven'; const RWG_SETTINGS_SCHEMA_GENERIC_JSON = 'org.gnome.shell.extensions.space.iflow.randomwallpaper.genericJSON'; const LoggerModule = Self.imports.logger; @@ -41,7 +41,7 @@ var RandomWallpaperSettings = new Lang.Class({ noSettings: null, desktopperSettings: null, unsplashSettings: null, - wallheavenSettings: null, + wallhavenSettings: null, genericJsonSettings: null, _init: function () { @@ -64,10 +64,10 @@ var RandomWallpaperSettings = new Lang.Class({ this.unsplashSettings = this._builder.get_object('unsplash-settings'); this.bindUnsplash(); - // Wallheaven Settings - this._wallheaven_settings = Convenience.getSettings(RWG_SETTINGS_SCHEMA_WALLHEAVEN); - this.wallheavenSettings = this._builder.get_object('wallheaven-settings'); - this.bindWallheaven(); + // Wallhaven Settings + this._wallhaven_settings = Convenience.getSettings(RWG_SETTINGS_SCHEMA_WALLHAVEN); + this.wallhavenSettings = this._builder.get_object('wallhaven-settings'); + this.bindWallhaven(); // Generic JSON Settings this._generic_json_settings = Convenience.getSettings(RWG_SETTINGS_SCHEMA_GENERIC_JSON); @@ -95,8 +95,8 @@ var RandomWallpaperSettings = new Lang.Class({ case 1: // desktopper this.currentSourceSettingsWidget = this.desktopperSettings; break; - case 2: // wallheaven - this.currentSourceSettingsWidget = this.wallheavenSettings; + case 2: // wallhaven + this.currentSourceSettingsWidget = this.wallhavenSettings; break; case 3: // generic JSON this.currentSourceSettingsWidget = this.genericJsonSettings; @@ -180,35 +180,35 @@ var RandomWallpaperSettings = new Lang.Class({ Gio.SettingsBindFlags.DEFAULT); }, - bindWallheaven: function () { - this._wallheaven_settings.bind('wallheaven-keyword', - this._builder.get_object('wallheaven-keyword'), + bindWallhaven: function () { + this._wallhaven_settings.bind('wallhaven-keyword', + this._builder.get_object('wallhaven-keyword'), 'text', Gio.SettingsBindFlags.DEFAULT); - this._wallheaven_settings.bind('resolutions', - this._builder.get_object('wallheaven-resolutions'), + this._wallhaven_settings.bind('resolutions', + this._builder.get_object('wallhaven-resolutions'), 'text', Gio.SettingsBindFlags.DEFAULT); - this._wallheaven_settings.bind('category-general', - this._builder.get_object('wallheaven-category-general'), + this._wallhaven_settings.bind('category-general', + this._builder.get_object('wallhaven-category-general'), 'active', Gio.SettingsBindFlags.DEFAULT); - this._wallheaven_settings.bind('category-anime', - this._builder.get_object('wallheaven-category-anime'), + this._wallhaven_settings.bind('category-anime', + this._builder.get_object('wallhaven-category-anime'), 'active', Gio.SettingsBindFlags.DEFAULT); - this._wallheaven_settings.bind('category-people', - this._builder.get_object('wallheaven-category-people'), + this._wallhaven_settings.bind('category-people', + this._builder.get_object('wallhaven-category-people'), 'active', Gio.SettingsBindFlags.DEFAULT); - this._wallheaven_settings.bind('allow-sfw', - this._builder.get_object('wallheaven-allow-sfw'), + this._wallhaven_settings.bind('allow-sfw', + this._builder.get_object('wallhaven-allow-sfw'), 'active', Gio.SettingsBindFlags.DEFAULT); - this._wallheaven_settings.bind('allow-sketchy', - this._builder.get_object('wallheaven-allow-sketchy'), + this._wallhaven_settings.bind('allow-sketchy', + this._builder.get_object('wallhaven-allow-sketchy'), 'active', Gio.SettingsBindFlags.DEFAULT); }, diff --git a/randomwallpaper@iflow.space/schemas/gschemas.compiled b/randomwallpaper@iflow.space/schemas/gschemas.compiled index 66a43b6..19ffc5b 100644 Binary files a/randomwallpaper@iflow.space/schemas/gschemas.compiled and b/randomwallpaper@iflow.space/schemas/gschemas.compiled differ diff --git a/randomwallpaper@iflow.space/schemas/org.gnome.shell.extensions.space.iflow.randomwallpaper.gschema.xml b/randomwallpaper@iflow.space/schemas/org.gnome.shell.extensions.space.iflow.randomwallpaper.gschema.xml index e3367a2..0b75de7 100644 --- a/randomwallpaper@iflow.space/schemas/org.gnome.shell.extensions.space.iflow.randomwallpaper.gschema.xml +++ b/randomwallpaper@iflow.space/schemas/org.gnome.shell.extensions.space.iflow.randomwallpaper.gschema.xml @@ -4,7 +4,7 @@ - + @@ -109,8 +109,8 @@ - + id='org.gnome.shell.extensions.space.iflow.randomwallpaper.wallhaven'> + "" Keyword The keyword will be used to search images. diff --git a/randomwallpaper@iflow.space/settings.ui b/randomwallpaper@iflow.space/settings.ui index 6a993b8..b4f0d43 100644 --- a/randomwallpaper@iflow.space/settings.ui +++ b/randomwallpaper@iflow.space/settings.ui @@ -278,7 +278,7 @@ You can also define a prefix that will be added to the image URL. True False True - The source that is used to fetch random wallpapers. You can select between unsplash.com, desktoppr.co, wallheaven.cc and a generic JSON source for experienced users. + The source that is used to fetch random wallpapers. You can select between unsplash.com, desktoppr.co, wallhaven.cc and a generic JSON source for experienced users. True 1 0 @@ -316,7 +316,7 @@ You can also define a prefix that will be added to the image URL. unsplash.com desktoppr.co - alpha.wallheaven.cc + alpha.wallhaven.cc Generic JSON @@ -1187,7 +1187,7 @@ You can also define a prefix that will be added to the image URL. - + True False 10 @@ -1209,7 +1209,7 @@ You can also define a prefix that will be added to the image URL. - + True True 10 @@ -1241,7 +1241,7 @@ You can also define a prefix that will be added to the image URL. 10 start - + SFW (Safe for work) True True @@ -1255,7 +1255,7 @@ You can also define a prefix that will be added to the image URL. - + Sketchy True True @@ -1295,7 +1295,7 @@ You can also define a prefix that will be added to the image URL. 10 start - + General True True @@ -1309,7 +1309,7 @@ You can also define a prefix that will be added to the image URL. - + Anime True True @@ -1323,7 +1323,7 @@ You can also define a prefix that will be added to the image URL. - + People True True @@ -1357,7 +1357,7 @@ You can also define a prefix that will be added to the image URL. - + True True 1920x1080, 1920x1200 diff --git a/randomwallpaper@iflow.space/sourceAdapter.js b/randomwallpaper@iflow.space/sourceAdapter.js index 4d95ca3..5c68c92 100644 --- a/randomwallpaper@iflow.space/sourceAdapter.js +++ b/randomwallpaper@iflow.space/sourceAdapter.js @@ -7,7 +7,7 @@ const Json = imports.gi.Json; const RWG_SETTINGS_SCHEMA_DESKTOPPER = 'org.gnome.shell.extensions.space.iflow.randomwallpaper.desktopper'; const RWG_SETTINGS_SCHEMA_UNSPLASH = 'org.gnome.shell.extensions.space.iflow.randomwallpaper.unsplash'; -const RWG_SETTINGS_SCHEMA_WALLHEAVEN = 'org.gnome.shell.extensions.space.iflow.randomwallpaper.wallheaven'; +const RWG_SETTINGS_SCHEMA_WALLHAVEN = 'org.gnome.shell.extensions.space.iflow.randomwallpaper.wallhaven'; const RWG_SETTINGS_SCHEMA_GENERIC_JSON = 'org.gnome.shell.extensions.space.iflow.randomwallpaper.genericJSON'; const SettingsModule = Self.imports.settings; @@ -74,10 +74,10 @@ var DesktopperAdapter = new Lang.Class({ session.queue_message(message, (session, message) => { let data = JSON.parse(message.response_body.data); let response = data.response; - let imageUrl = encodeURI(response.image.url); + let imageDownloadUrl = encodeURI(response.image.url); if (callback) { - let historyEntry = new HistoryModule.HistoryEntry(null, 'desktopper.co', imageUrl); + let historyEntry = new HistoryModule.HistoryEntry(null, 'desktopper.co', imageDownloadUrl); historyEntry.source.sourceUrl = 'https://www.desktoppr.co/'; callback(historyEntry); } @@ -128,6 +128,7 @@ var UnsplashAdapter = new Lang.Class({ let authorName = data.user.name; let authorUrl = encodeURI(data.user.links.html); + let imageLinkUrl = encodeURI(data.urls.raw + '&' + utmParameters); let downloadLocation = data.links.download_location + '?' + clientParam; let downloadMessage = Soup.Message.new('GET', downloadLocation); @@ -135,12 +136,11 @@ var UnsplashAdapter = new Lang.Class({ session.queue_message(downloadMessage, (session, message) => { let downloadData = JSON.parse(message.response_body.data); - let imageUrl = encodeURI(downloadData.url + '&' + utmParameters); - if (callback) { - let historyEntry = new HistoryModule.HistoryEntry(authorName, this.sourceName, encodeURI(imageUrl)); + 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; callback(historyEntry); } }); @@ -177,8 +177,8 @@ var UnsplashAdapter = new Lang.Class({ } }); -var WallheavenAdapter = new Lang.Class({ - Name: "WallheavenAdapter", +var WallhavenAdapter = new Lang.Class({ + Name: "WallhavenAdapter", Extends: BaseAdapter, _settings: null, @@ -194,7 +194,7 @@ var WallheavenAdapter = new Lang.Class({ _init: function () { this.parent(); - this._settings = new SettingsModule.Settings(RWG_SETTINGS_SCHEMA_WALLHEAVEN); + this._settings = new SettingsModule.Settings(RWG_SETTINGS_SCHEMA_WALLHAVEN); }, requestRandomImage: function (callback) { @@ -223,14 +223,15 @@ var WallheavenAdapter = new Lang.Class({ session.queue_message(message, () => { let body = message.response_body.data; - let imageUrl = body.match(new RegExp(/\/\/wallpapers.wallhaven.cc\/wallpapers\/full\/.*?"/))[0]; - imageUrl = imageUrl.slice(0, -1); - imageUrl = 'http:' + imageUrl; - imageUrl = encodeURI(imageUrl); + let imageDownloadUrl = body.match(new RegExp(/\/\/wallpapers.wallhaven.cc\/wallpapers\/full\/.*?"/))[0]; + imageDownloadUrl = imageDownloadUrl.slice(0, -1); + imageDownloadUrl = 'http:' + imageDownloadUrl; + imageDownloadUrl = encodeURI(imageDownloadUrl); if (callback) { - let historyEntry = new HistoryModule.HistoryEntry(null, 'wallhaven.cc', imageUrl); + let historyEntry = new HistoryModule.HistoryEntry(null, 'wallhaven.cc', imageDownloadUrl); historyEntry.source.sourceUrl = 'https://alpha.wallhaven.cc/'; + historyEntry.source.imageLinkUrl = url; callback(historyEntry); } }) @@ -259,7 +260,7 @@ var WallheavenAdapter = new Lang.Class({ }, _readOptionsFromSettings: function () { - this.options.q = this._settings.get('wallheaven-keyword', 'string'); + this.options.q = this._settings.get('wallhaven-keyword', 'string'); this.options.resolutions = this._settings.get('resolutions', 'string').split(','); this.options.resolutions = this.options.resolutions.map((elem) => { @@ -275,7 +276,7 @@ var WallheavenAdapter = new Lang.Class({ let purity = []; purity.push(+this._settings.get('allow-sfw', 'boolean')); purity.push(+this._settings.get('allow-sketchy', 'boolean')); - purity.push(0); // required by wallheaven + purity.push(0); // required by wallhaven this.options.purity = purity.join(''); } }); @@ -304,12 +305,12 @@ var GenericJsonAdapter = new Lang.Class({ session.queue_message(message, (session, message) => { let response = JSON.parse(message.response_body.data); let JSONPath = this._settings.get("generic-json-response-path", "string"); - let imageUrl = this._jsonPathParser.access(response, JSONPath); - imageUrl = this._settings.get("generic-json-url-prefix", "string") + imageUrl; + let imageDownloadUrl = this._jsonPathParser.access(response, JSONPath); + imageDownloadUrl = this._settings.get("generic-json-url-prefix", "string") + imageDownloadUrl; if (callback) { - let historyEntry = new HistoryModule.HistoryEntry(null, 'Generic JSON Source', imageUrl); - historyEntry.source.sourceUrl = imageUrl; + let historyEntry = new HistoryModule.HistoryEntry(null, 'Generic JSON Source', imageDownloadUrl); + historyEntry.source.sourceUrl = imageDownloadUrl; callback(historyEntry); } }); diff --git a/randomwallpaper@iflow.space/wallpaperController.js b/randomwallpaper@iflow.space/wallpaperController.js index 0298d18..8059206 100644 --- a/randomwallpaper@iflow.space/wallpaperController.js +++ b/randomwallpaper@iflow.space/wallpaperController.js @@ -59,7 +59,7 @@ var WallpaperController = new Lang.Class({ this._desktopperAdapter = new SourceAdapter.DesktopperAdapter(); this._unsplashAdapter = new SourceAdapter.UnsplashAdapter(); - this._wallheavenAdapter = new SourceAdapter.WallheavenAdapter(); + this._wallhavenAdapter = new SourceAdapter.WallhavenAdapter(); this._genericJsonAdapter = new SourceAdapter.GenericJsonAdapter(); this.logger = new LoggerModule.Logger('RWG3', 'WallpaperController'); @@ -97,7 +97,7 @@ var WallpaperController = new Lang.Class({ this.imageSourceAdapter = this._desktopperAdapter; break; case 2: - this.imageSourceAdapter = this._wallheavenAdapter; + this.imageSourceAdapter = this._wallhavenAdapter; break; case 3: this.imageSourceAdapter = this._genericJsonAdapter; @@ -223,9 +223,9 @@ var WallpaperController = new Lang.Class({ this._timer.begin(); // reset timer this._requestRandomImageFromAdapter((historyElement) => { - this.logger.info("Requesting image: " + historyElement.source.imageUrl); + this.logger.info("Requesting image: " + historyElement.source.imageDownloadUrl); - this._fetchFile(historyElement.source.imageUrl, (historyId, path) => { + this._fetchFile(historyElement.source.imageDownloadUrl, (historyId, path) => { historyElement.path = path; historyElement.id = historyId;