Hi, sorry to revive a long dead thread but it helped me in writing the following script that lets you...
1) Step forwards and backwards through your skydome folder (next/last)
2) Set a random skydome
3) Set the latest image
4) Delete an image from the skydome folder and replace it with the next one.
Hope someone finds this useful,
Cheers,
Roger
Code:
#!/usr/bin/python
# newsky.py - skydome image manager/changer for compiz cube under gnome
# v0.1, (c)2012 Roger Heathcote, GPL2 licensed, bugs etc to opensource@technicalbloke.com
# Usage newsky.py [latest(default)|next|last|random|kill]
# Edit these settings to suit...
skydome_folder = "/home/yourname/pictures/skydomes"
patterns = ["*.jpeg", "*.jpg", "*.png"]
mode = "latest"
# Don't edit below this line unless you really know what you are doing!...
import os, sys, code, glob, string, random, subprocess
current_image = None
# If argument is specified set mode to that
if sys.argv[1:2]:
mode = sys.argv[1]
# Grab lsit of picture file names from skydome folder
pictures = []
for pattern in patterns:
pictures = pictures + glob.glob( skydome_folder + os.sep + pattern )
if mode == "latest":
current_image = max( (os.stat(x)[9], x) for x in pictures )[1]
if mode == "random":
current_image = random.choice( pictures )
# Note next and prev are in OS order, not sorted by date. Kill removes current file and loads the next one.
if mode == "next" or mode == "prev" or mode == "kill":
# Retreive current image file path from gconf
if "check_output" in dir( subprocess ): # new in 2.7
current_image = subprocess.check_output(["gconftool-2", "-g", "/apps/compiz/plugins/cube/screen0/options/skydome_image"]).strip()
else: # for 2.6 and older - yuck!
current_image = subprocess.Popen(["gconftool-2", "-g", "/apps/compiz/plugins/cube/screen0/options/skydome_image"], stdout=subprocess.PIPE)
current_image = current_image.communicate()[0].strip()
# Process argument
try:
idx = pictures.index( current_image )
if mode == "kill":
os.remove( current_image )
mode = "next"
if mode == "next":
idx = idx + 1
if idx >= len( pictures ): idx = 0
if mode == "prev":
idx = idx - 1
if idx < 0: idx = len( pictures ) - 1
current_image = pictures[idx]
except IndexError:
print "Current pic not in skydomes folder, not changing:", current_image
# Change image or fail
if current_image:
subprocess.Popen(["gconftool-2", "-s", "-t", "string", "/apps/compiz/plugins/cube/screen0/options/skydome_image" , current_image])
else:
print "Fail. Valid options are: latest, random, next, prev, kill"
Bookmarks