Wallpaper slideshow software that supports changing image size - Ask Ubuntu


i've found several software applications create slideshows, i've yet see 1 support changing image size (i.e. fit, stretch, fill width, fill height). there software supports this?

introduction

here's thing: if run in terminal dconf watch / , @ same time flip through options in ubuntu settings wallpaper size ( tile, scale, zoom, etc.) see this:

/org/gnome/desktop/background/picture-options   'zoom'  /org/gnome/desktop/background/picture-options   'wallpaper'  /org/gnome/desktop/background/picture-options   'centered'  /org/gnome/desktop/background/picture-options   'scaled'  /org/gnome/desktop/background/picture-options   'stretched'  /org/gnome/desktop/background/picture-options   'spanned' 

what mean ? means if have software can flip through wallpaper, should able flip through options, right ?

well, i've written wallpaper slide-show script time before. in past had required options. specific question, modified script deal size, made 1 option required -d corresponds directory slideshow images supposed live.

basic usage

the usage simple: give directory images, give size , , run. simple doing this:

 $ ./xml_wallpaper_maker.py -s zoom  -d ~/pictures/wallpapers/ 

you can use -h option show information options , in case forget usage:

$ ./xml_wallpaper_maker.py -h                                                                                                          usage: xml_wallpaper_maker.py [-h] -d directory [-t transition] [-l length]                               [-o] [-s size]  serg's xml slideshow creator  optional arguments:   -h, --help            show message , exit   -d directory, --directory directory                         directory images stored. required   -t transition, --transition transition                         transition time in seconds, default 2.5   -l length, --length length                         time length in seconds per image, default 1800   -o, --overlay         enables use of overlay transition   -s size, --size size  wallpaper,zoom,centered,scaled,stretched,or spanned 

script source

the script source available both here , on github. if have git, feel free run git clone https://github.com/sergkolo/sergrep.git or download repository files link above. if you're copying here, make sure save file xml_wallpaper_maker.py , make executable chmod +x xml_wallpaper_maker.py.

#!/usr/bin/env python3 # -*- coding: utf-8 -*-   # # author: serg kolo , contact: 1047481448@qq.com # date: september 2 , 2016 # purpose: program creates , launches xml slideshow #       # tested on: ubuntu 16.04 lts # # # licensed under mit license (mit). # see included license file or notice below. # # copyright © 2016 sergiy kolodyazhnyy # # permission hereby granted, free of charge, person obtaining copy # of software , associated documentation files (the "software"), deal # in software without restriction, including without limitation rights # use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of software, , permit persons whom software # furnished so, subject following conditions: # # above copyright notice , permission notice shall included # in copies or substantial portions of software. # # software provided "as is", without warranty of kind, express or # implied, including not limited warranties of merchantability, # fitness particular purpose , noninfringement. in no event shall # authors or copyright holders liable claim, damages or other # liability, whether in action of contract, tort or otherwise, arising from, # out of or in connection software or use or other dealings in # software.   gi.repository import gio import xml.etree.celementtree et import lxml.etree etree import argparse import sys import os  def gsettings_set(schema, path, key, value):     """set value of gsettings schema"""     if path 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 images stored. required',                                 type=str,                                 required=true                                 )          arg_parser.add_argument(                                 '-t','--transition',                                  type=float,                                 default=2.5,                                 help='transition time in seconds, default 2.5',                                 required=false                                 )           arg_parser.add_argument(                                 '-l','--length',                                  type=float,                                 default=1800.0,                                 help='time length in seconds per image, default 1800',                                 required=false                                 )          arg_parser.add_argument(                                 '-o','--overlay',                                  action='store_true',                                 help='enables use of overlay transition',                                 required=false                                 )          arg_parser.add_argument(                                 '-s','--size',                                  type=str,                                 help='wallpaper,zoom,centered,scaled,stretched,or spanned',                                 default='scaled',                                 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," not directory !")        sys.exit(1)      filepaths = [os.path.join(path,item) item in os.listdir(path) ]     images = [ img img in filepaths if os.path.isfile(img)]     filepaths = none     images.sort()     root = et.element("background")     previous = none      # write xml data of images , transitions     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 final image     image = et.subelement(root, "static")     et.subelement(image,"duration").text = str(duration)     et.subelement(image,"file").text = previous      # write out final xml data file     tree = et.elementtree(root)     tree.write(xml_file)      # pretty print data     data = etree.parse(xml_file)     formated_xml = etree.tostring(data, pretty_print = true)     open(xml_file,'w') f:         f.write(formated_xml.decode())       gsettings_set('org.gnome.desktop.background',none,'picture-options', args.size)     gsettings_set('org.gnome.desktop.background',none,'picture-uri','file://' + xml_file)  if __name__ == '__main__':     main() 

Comments

Popular posts from this blog

download - Firefox cannot save files (most of the time), how to solve? - Super User

windows - "-2146893807 NTE_NOT_FOUND" when repair certificate store - Super User