11

I want my wallpaper to be a side-scroll of Super Mario World Yoshi's Island 1. Once the wallpaper scrolled all the way over, it would seamlessly loop back to the start.

Is there a program, or XML, that would accomplish this for me? I am using GNOME Shell.

Jorge Castro
  • 71,754
Aly
  • 265
  • 6
    So . . . you basically want to have an animated wallpaper ? – Sergiy Kolodyazhnyy Aug 28 '16 at 17:14
  • It is animated, but I couldn't find anything that could make it side scroll. – Aly Aug 28 '16 at 17:18
  • 3
    What I think can be done is to split that image into multiple "snapshots" and use XML file to set up transitions with set time period. So that way, it will be sort of like in old console games, where you have one "view" then you cross border and another view appears on screen, and so on. Think that would be a good idea ? – Sergiy Kolodyazhnyy Aug 28 '16 at 17:24
  • @Serg Yes, can you answer how to do that? The transitions need to be high quality though. (Dynamically, so it works with all images) – Aly Aug 28 '16 at 17:34
  • 2
    I am thinking of writing a script for that. Might take me couple of days. I'll let you know once i come up with some working code, OK ? – Sergiy Kolodyazhnyy Aug 28 '16 at 17:46
  • 1
    I would pass this request onto the developer of XScreenSaver. It sounds like a wonderful idea that I hope the developer would consider. It wouldn't be wallpaper as you requested but is an alternate solution to satisfy your "graphic desires". Similarly ones /Pictures folder could be queued up this way to scroll as well. I really like your request! – WinEunuuchs2Unix Aug 28 '16 at 22:33
  • I've posted an answer, the script for creating slideshow. It's configurable by the user , so you can set the length of transition that you want and duration of image on screen. The only thing I did not do is to cut down that imgur image that you posted, because I don't know its license and do not want to get in trouble for copying/editing it without permission. – Sergiy Kolodyazhnyy Sep 03 '16 at 01:15

1 Answers1

4

Update 10/22/16

The script has been updated to match requirements in this question : https://askubuntu.com/a/840381/295286

Transition and duration were made optional and having default values. -s option is also added for sizing of wallpapers ( same as Tile, Scale, Stretch options from System Settings ).


Just like I said in the comments, you would have to cut down the image into even sized or overlapping pieces and create a slideshow for it. I don't know the license of that specific image that you want, so I will leave it up to you to cut it(Hint).

However, here is an animated wallpaper generator script that I have written. Usage is very simple. As shown by -h option:

usage: xml_wallpaper_maker.py [-h] -d DIRECTORY -t TRANSITION -l LENGTH [-o]

Serg's XML slideshow creator

optional arguments:
  -h, --help            show this help message and exit
  -d DIRECTORY, --directory DIRECTORY
                        Directory where images stored
  -t TRANSITION, --transition TRANSITION
                        transition time in seconds
  -l LENGTH, --length LENGTH
                        Time length in seconds per image
  -o, --overlay         Enables use of overlay transition

Example:

./xml_wallpaper_maker.py -d Pictures/My_SideScroller_Images/ -t 5 -l 10 

Source code

Also available on GitHub

#!/usr/bin/env python3
# -*- coding: utf-8 -*- 

#
# Author: Serg Kolo , contact: 1047481448@qq.com
# Date: September 2 , 2016
# Purpose: A program that creates and launches XML slideshow
#      
# Tested on: Ubuntu 16.04 LTS
#
#
# Licensed under The MIT License (MIT).
# See included LICENSE file or the notice below.
#
# Copyright © 2016 Sergiy Kolodyazhnyy
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.


from gi.repository import Gio
import xml.etree.cElementTree as ET
import lxml.etree as etree
import argparse
import sys
import os

def gsettings_set(schema, path, key, value):
    """Set value of gsettings schema"""
    if path is None:
        gsettings = Gio.Settings.new(schema)
    else:
        gsettings = Gio.Settings.new_with_path(schema, path)
    if isinstance(value,list ):
        return gsettings.set_strv(key, value)
    if isinstance(value,int):
        return gsettings.set_int(key, value)
    if isinstance(value,str):
        return gsettings.set_string(key,value)

def parse_args():
        """ Parses command-line arguments """
        arg_parser = argparse.ArgumentParser(
        description='Serg\'s XML slideshow creator',
        )

        arg_parser.add_argument(
                                '-d', '--directory',
                                help='Directory where images stored',
                                type=str,
                                required=True
                                )

        arg_parser.add_argument(
                                '-t','--transition', 
                                type=float,
                                help='transition time in seconds',
                                required=True
                                )


        arg_parser.add_argument(
                                '-l','--length', 
                                type=float,
                                help='Time length in seconds per image',
                                required=True
                                )

        arg_parser.add_argument(
                                '-o','--overlay', 
                                action='store_true',
                                help='Enables use of overlay transition',
                                required=False
                                )
        return arg_parser.parse_args()



def main():
    """ Program entry point"""
    args = parse_args()
    xml_file = os.path.join(os.path.expanduser('~'),'.local/share/slideshow.xml')
    path = os.path.abspath(args.directory)
    duration = args.length
    transition_time = args.transition

    if not os.path.isdir(path):
       print(path," is not a directory !")
       sys.exit(1)

    filepaths = [os.path.join(path,item) for item in os.listdir(path) ]
    images = [ img for img in filepaths if os.path.isfile(img)]
    filepaths = None
    images.sort()
    root = ET.Element("background")
    previous = None

    # Write the xml data of images and transitions
    for index,img in enumerate(images):

        if index == 0:
           previous = img
           continue

        image = ET.SubElement(root, "static")
        ET.SubElement(image,"duration").text = str(duration)
        ET.SubElement(image,"file").text = previous

        if args.overlay: 
            transition = ET.SubElement(root,"transition",type='overlay')
        else:
            transition = ET.SubElement(root,"transition")
        ET.SubElement(transition,"duration").text = str(transition_time)
        ET.SubElement(transition, "from").text = previous
        ET.SubElement(transition, "to").text = img

        previous = img

    # Write out the final image
    image = ET.SubElement(root, "static")
    ET.SubElement(image,"duration").text = str(duration)
    ET.SubElement(image,"file").text = previous

    # Write out the final xml data to file
    tree = ET.ElementTree(root)
    tree.write(xml_file)

    # pretty print the data
    data = etree.parse(xml_file)
    formated_xml = etree.tostring(data, pretty_print = True)
    with open(xml_file,'w') as f:
        f.write(formated_xml.decode())

    gsettings_set('org.gnome.desktop.background',None,'picture-uri','file://' + xml_file)

if __name__ == '__main__':
    main()
Sergiy Kolodyazhnyy
  • 105,154
  • 20
  • 279
  • 497
  • Do you know how to programmatically cut down an image into n*n pieces, moving along n pixels x and n pixels y at each cut? For example, the command for the YI1 wallpaper would be command 1920 1080 1 0 and it would loop on itself? – Aly Sep 03 '16 at 01:50
  • @moo_we_all_do actually, this has been asked before : http://askubuntu.com/a/143501/295286 – Sergiy Kolodyazhnyy Sep 03 '16 at 01:53
  • so to loop around I would take the first 1920 pixels and copy it to the back? – Aly Sep 03 '16 at 01:54
  • @moo_we_all_do what do you mean loop-around ? What you need to do is split that image into even parts, put them into folder, and just tell the script path to that folder. The xml wallpaper will automatically transition and loop back to first image – Sergiy Kolodyazhnyy Sep 03 '16 at 02:00
  • By loop I mean scroll, and I figured it out, thanks! :D – Aly Sep 03 '16 at 02:05
  • @moo_we_all_do You're very welcome :) I might update the script to add more stuff later, but that's essentially how it should function – Sergiy Kolodyazhnyy Sep 03 '16 at 02:09
  • @moo_we_all_do I've updated it slightly, to fix a small bug and include another option to use overlay transition, basically it's like one wallpaper becomes transparent and the other one appears – Sergiy Kolodyazhnyy Sep 03 '16 at 02:28
  • When I move my mouse up to "Activities" (I'm in GNOME Shell) the wallpaper goes back to the first frame for a second. – Aly Sep 05 '16 at 15:57
  • I found the problem, it goes 1, 10, 100, 1000, 10000, etc. – Aly Sep 05 '16 at 15:59