LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-31-2006, 08:33 AM   #1
geletine
Member
 
Registered: Apr 2005
Distribution: Slackware
Posts: 213
Blog Entries: 2

Rep: Reputation: 30
Random photo every two minutes recursively


I trying to find a script that can use fbsetbg and change the background ramdomly through directories

i found this python script and changed it to the following , but it gives me errors , i think its because there are directories in directories

here is my modified version
Code:
# Copyright 2005 Michael Rice
# errr (at) errr-online (dot) com
#
# This will set a random image. It will pull the image from a pool
# of as many dirs as you want and its timed and will change every 2 mins
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

import os,random
from time import sleep

def get_bgimgs():
    h = []
    #add your paths here no need to remove any if you dont want to
    #any path that isnt there will be skipped
    paths =["/mnt/allix/photos"]
    for imgpth in paths:
            try:
                imgs = os.listdir(os.path.expanduser(imgpth))
                for i in imgs:
                    i = i.replace(" ","/ ")
                    h.append(imgpth+"/"+i)
            except (OSError):
                pass
    os.system("fbsetbg -f "+ random.choice(h))
    sleep(240)
    #print random.choice(h)

if __name__ == "__main__":
    while 1:
        get_bgimgs()
 
Old 05-31-2006, 08:45 AM   #2
e5150
Member
 
Registered: Oct 2005
Location: Sweden
Distribution: Slackware and Alpine
Posts: 132

Rep: Reputation: 100Reputation: 100
Code:
import os,random, time
paths=['/mnt/allix/photos']
images=[]
for path in paths:
  if os.path.isdir(path)==False: continue
  for root,dirs,files in os.walk(path):
    for name in files:
      images.append(os.path.join(root,name))

while True:
  os.system('fbsetbg -f "%s"'%images[random.randint(0,len(images))])
  time.sleep(240)

havn't tested it, but I reckon it should work...

Last edited by e5150; 05-31-2006 at 08:56 AM.
 
Old 05-31-2006, 09:03 AM   #3
geletine
Member
 
Registered: Apr 2005
Distribution: Slackware
Posts: 213

Original Poster
Blog Entries: 2

Rep: Reputation: 30
thanks its working , i don't think it will start up if i put it in .fluxbox/init
apart from putting it on the menu, how would you suggest i automate it when the fluxbox loads?
 
Old 05-31-2006, 09:08 AM   #4
e5150
Member
 
Registered: Oct 2005
Location: Sweden
Distribution: Slackware and Alpine
Posts: 132

Rep: Reputation: 100Reputation: 100
if you add
#!/usr/bin/python
or wherever your python binary is located at the top of the script and
chmod 755 nameofscript.py
then you could just set
session.screen0.rootCommand: nameofscript.py
in your ~/.fluxbox/init
 
Old 05-31-2006, 10:07 AM   #5
geletine
Member
 
Registered: Apr 2005
Distribution: Slackware
Posts: 213

Original Poster
Blog Entries: 2

Rep: Reputation: 30
thanks, that works
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
rm dir recursively allelopath Linux - General 6 01-06-2006 11:37 AM
lowercase recursively cubax Linux - General 6 05-29-2005 04:20 PM
KSH: random pause of 1-15 minutes ReefShark Programming 2 11-03-2004 07:45 AM
any photo viewer with lossless photo rotation? zecodela Linux - Software 1 10-24-2004 10:22 PM
Creating random numbers from shell with /dev/random khermans Linux - General 1 07-13-2004 12:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration