如何设置侧卷墙纸?


10

我希望我的壁纸成为Super Mario World Yoshi's Island 1的侧卷。一旦墙纸一直滚动到整个位置,它将无缝地循环回到起点。

是否有程序或XML可以为我完成此任务?我正在使用GNOME Shell。


6
所以 。。您基本上想拥有动画墙纸吗?
Sergiy Kolodyazhnyy

它是动画的,但是我找不到任何可以使其横向滚动的东西。
索伦

3
我认为可以做的是将该图像拆分为多个“快照”,并使用XML文件在设置的时间段内设置过渡。这样一来,就好像在旧的主机游戏中一样,先有一个“视图”,然后越过边界,另一个视图出现在屏幕上,依此类推。认为这将是一个好主意吗?
Sergiy Kolodyazhnyy

2
我正在考虑为此编写脚本。可能要花我几天时间。我提出一些工作代码后,我会通知您,好吗?
Sergiy Kolodyazhnyy

1
我会将这个请求传递给XScreenSaver的开发人员。听起来这是一个很棒的主意,我希望开发人员会考虑。它不是您要求的墙纸,而是满足您“图形需求”的替代解决方案。类似地,/ Pictures文件夹也可以通过这种方式排队等待滚动。我真的很喜欢你的要求!
WinEunuuchs2Unix

Answers:


4

更新10/22/16

脚本已更新,可以满足此问题的要求:https : //askubuntu.com/a/840381/295286

过渡和持续时间设为可选,并具有默认值。-s还添加了用于调整墙纸尺寸的选项(与“系统设置”中的“平铺”,“缩放”,“拉伸”选项相同)。


就像我在评论中说的那样,您必须将图像切成均匀大小或重叠的部分,并为其创建幻灯片。我不知道您想要的特定图像的许可证,因此我将其留给您裁剪(提示)。

但是,这是我编写的动画墙纸生成器脚本。用法很简单。如-h选项所示:

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

例:

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

源代码

也可以在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()

您是否知道如何以编程方式将图像切割成n* n块,nn在每次切割时沿像素x和像素y 移动?例如,用于YI1壁纸的命令将是command 1920 1080 1 0并且会自行循环吗?
索伦

@moo_we_all_do实际上,这是之前被问过的:askubuntu.com/a/143501/295286
Sergiy Kolodyazhnyy

因此,要循环播放,我会拍摄第一个1920像素并将其复制到背面吗?
索伦

@moo_we_all_do你是什么意思环回?您需要做的就是将图像分成均匀的部分,将其放入文件夹中,然后告诉脚本路径到该文件夹​​。该XML壁纸将自动转换和循环回到第一形象
谢尔盖Kolodyazhnyy

循环是指滚动,我想通了,谢谢!:D
索伦
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.