varietywalls / variety

Wallpaper downloader and manager for Linux systems
http://peterlevi.com/variety
GNU General Public License v3.0
1.2k stars 143 forks source link

Bug: Wallpaper image not shown #240

Closed Cyb10101 closed 4 years ago

Cyb10101 commented 4 years ago

Version of Variety: 0.7.1

Describe the bug Images are downloaded which cannot be used for the desktop display. I suspect it will be loaded in a different file format. Since the image type is not supported, a black desktop is displayed.

Context It happens sometimes. Regardless of whether the computer is starting or not.

To Reproduce Randomly. Cannot be repoduced.

Attach Variety's log file Without variety -v! I've added -v in case it happens next time.

INFO: 2019-11-14 13:20:30,120: download_one() 'Downloading an image from Wallhaven.cc, https://wallhaven.cc/search?q=id%3A175&sorting=date_added&page=1'
INFO: 2019-11-14 13:20:30,120: download_one() 'Queue size: 0'
INFO: 2019-11-14 13:20:30,120: fill_queue() 'Filling wallhaven queue: https://wallhaven.cc/search?q=id%3A175&sorting=date_added&page=1'
INFO: 2019-11-14 13:20:30,120: search() 'Performing wallhaven search: url=https://wallhaven.cc/search?q=id%3A175&sorting=date_added&page=1'
INFO: 2019-11-14 13:20:30,768: fill_queue() '3962 wallpapers in result, using page 8'
INFO: 2019-11-14 13:20:30,768: search() 'Performing wallhaven search: url=https://wallhaven.cc/search?q=id%3A175&sorting=date_added&page=1&page=8'
INFO: 2019-11-14 13:20:31,353: fill_queue() 'Wallhaven queue populated with 12 URLs'
INFO: 2019-11-14 13:20:31,353: download_one() 'Wallpaper URL: https://wallhaven.cc/w/p8yw2j'
INFO: 2019-11-14 13:20:32,334: download_one() 'Image src URL: https://w.wallhaven.cc/full/p8/wallhaven-p8yw2j.png'
INFO: 2019-11-14 13:20:32,340: save_locally() 'Origin URL: https://wallhaven.cc/w/p8yw2j'
INFO: 2019-11-14 13:20:32,340: save_locally() 'Image URL: https://w.wallhaven.cc/full/p8/wallhaven-p8yw2j.png'
INFO: 2019-11-14 13:20:32,340: save_locally() 'Local name: /home/cyb10101/.config/variety/Downloaded/wallhaven_wallhaven_cc_search_q_id_3A175_sorting_date_added_page_1/wallhaven-p8yw2j.png'
INFO: 2019-11-14 13:20:35,238: regular_change_thread() 'regular_change changes wallpaper'
INFO: 2019-11-14 13:20:35,238: set_wallpaper() 'Calling set_wallpaper with /home/cyb10101/.../another.jpg'

Desktop environment and version Gnome 3.28.2

OS name and version

Ubuntu 18.04.3 LTS

NAME="Ubuntu"
VERSION="18.04.3 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.3 LTS"
VERSION_ID="18.04"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic

Screenshots The screen is black. The file is corrupted.

Attached files https://drive.google.com/file/d/17Wc5Mx0LZJ50B3chBm4QWdXk7zhLDMTz/view?usp=sharing

Additional context Part extract of the downloaded file.

<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="XMP Core 4.4.0-Exiv2">
 <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <rdf:Description rdf:about=""
    xmlns:xmp="http://ns.adobe.com/xap/1.0/"
    xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/"
    xmlns:stEvt="http://ns.adobe.com/xap/1.0/sType/ResourceEvent#"
    xmlns:stRef="http://ns.adobe.com/xap/1.0/sType/ResourceRef#"
    xmlns:tiff="http://ns.adobe.com/tiff/1.0/"
    xmlns:exif="http://ns.adobe.com/exif/1.0/"
    xmlns:variety="https://launchpad.net/variety/"
   xmp:CreatorTool="Adobe Photoshop CC 2018 (Windows)"
   xmp:CreateDate="2018-09-02T19:41:33+03:00"
   xmp:MetadataDate="2019-07-10T07:35+03:00"
   xmp:ModifyDate="2019-07-10T07:35+03:00"
   photoshop:ColorMode="3"
   photoshop:ICCProfile="Adobe RGB (1998)"
   dc:format="image/png"
   xmpMM:InstanceID="xmp.iid:cfb7cc5f-a718-6145-ae07-aff7ff4f9216"
   xmpMM:DocumentID="adobe:docid:photoshop:45d2b111-05c0-a640-88b5-f00f84db3da5"
   xmpMM:OriginalDocumentID="xmp.did:fdacab8b-604b-da43-ae50-f3188a48e596"
   tiff:Orientation="1"
   tiff:XResolution="720000/10000"
   tiff:YResolution="720000/10000"
   tiff:ResolutionUnit="2"
   exif:ColorSpace="65535"
   exif:PixelXDimension="3840"
   exif:PixelYDimension="2160"
   variety:imageURL="https://w.wallhaven.cc/full/p8/wallhaven-p8yw2j.png"
   variety:sfwRating="100"
   variety:sourceLocation="https://wallhaven.cc/search?q=id%3A175&amp;sorting=date_added&amp;page=1"
   variety:sourceName="Wallhaven.cc"
   variety:sourceType="wallhaven"
   variety:sourceURL="https://wallhaven.cc/w/p8yw2j">
   <photoshop:TextLayers>
    <rdf:Bag>
     <rdf:li
      photoshop:LayerName="vk.com/raidyhd копия 2"
      photoshop:LayerText="vk.com/raidyhd"/>
    </rdf:Bag>
   </photoshop:TextLayers>
   <photoshop:DocumentAncestors>
    <rdf:Bag>
     <rdf:li>0</rdf:li>
     <rdf:li>0000A6C7815905497C2762FB3073AC1B</rdf:li>
     <rdf:li>0002E8BF3B9FFA2E128D4968EB5D18F6</rdf:li>
guss77 commented 4 years ago

Could this be related to the fact that the source is a PNG formatted image? I believe I have a similar problem with KDE: Support for Plasma works by copying the selected wallpaper to a local folder, and the resulting filename (for example: $HOME/Pictures/variety-wallpaper/variety-copied-wallpaper-cad84ad0c7d66778244130ec1707276e.jpg) always has a .jpg suffix even if the source file has a .png suffix. When Plasma tries to read the wallpaper file it complains:

Not a JPEG file: starts with 0x89 0x50
file:///usr/share/plasma/wallpapers/org.kde.slideshow/contents/ui/main.qml:114:9: QML Image: Error decoding: file:///XXXXX.jpg: Unable to read image data
guss77 commented 4 years ago

BTW, my workaround to this problem was to modify the Variety "set wallpaper" script at ~/.config/variety/scripts/set_wallpaper in the KDE part to do this (instead of the relevant part that it currently does):

EXT=$(file -b --extension "$WP" | cut -d/ -f1)
NEWWP="$(xdg-user-dir PICTURES)/variety-wallpaper/wallpaper-kde-$RANDOM.${EXT}"
cp "$WP" "$NEWWP"

The "change wallpaper" script triggers the gnome background change right at the beginning, but it should be relatively trivial to add the extension detection code and a copy command, similar to how KDE is supported, before the gsettings call.

Sparklytical commented 4 years ago

@guss77 noob question, but where should I place this line of the script? or do I need to replace some content in set_wallpaper file?

can you just send your config file?

guss77 commented 4 years ago

@EvilSpark - the current version I have installed (0.8.3) has a new set_wallpaper script than the one I was using. The new script uses the Plasma 5 DBUS API to set the wallpaper directly from the "variety-copied-wallpaper" file - without a specific KDE copy. So I had to change my workaround.

The current workaround looks like this (patch against current set_wallpaper script):

--- /usr/share/variety/scripts/set_wallpaper    2020-02-12 01:48:06.000000000 +0200
+++ /home/odeda/.config/variety/scripts/set_wallpaper   2020-04-17 16:41:25.457876850 +0300
@@ -28,7 +28,9 @@
 # In the end put the path to the actual final wallpaper image file in the WP variable.
 # The default is to simply set WP=$1.
 WP=$1
-
+EXT=$(file -b --extension "$WP" | cut -d/ -f1)
+mv "$WP" "${WP%.*}.${EXT}"
+WP="${WP%.*}.${EXT}"

 # Enlightenment
 # Needs Modules/System/DBus Extension loaded to work

I don't think this the right thing to do, so I won't submit this as a PR to the project - the problem is in the variety code that assumes that all images are JPEG files and there for should be copied to $(xdg-user-dir PICTURES)/variety-wallpaper/variety-copied-wallpaper-${GUID}.jpg. The program should check the mime type and create the appropriate extension.

guss77 commented 4 years ago

As I was looking at this (and I know a tiny bit of Python - enough to be dangerous ;-) ) I sent a PR with a real fix. Hopefully that will get accepted and we can put the lid on this issue.