DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 963,864 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Cover image for Day 8 - Random Wallpaper Changer - 100 days 100 python scripts
Ganesh Raja
Ganesh Raja

Posted on

Day 8 - Random Wallpaper Changer - 100 days 100 python scripts

Day 8: update_gnome_wallpaper

This script will randomly select an image file from a folder of files and update the wallpaper in ubuntu

import os,random
import constants

WALLPAPER_DIR= constants.WALLPAPER_DIR # Wallpaper Location 

images=[item for item in os.listdir(WALLPAPER_DIR) if os.path.isfile(os.path.join(WALLPAPER_DIR,item)) and item.split(".")[-1].lower() in ["png",'jpg']]

if len(images) >0:
    wallpaper=random.choice(images)
    os.system("gsettings set org.gnome.desktop.background picture-uri file://"+os.path.join(WALLPAPER_DIR,wallpaper))
Enter fullscreen mode Exit fullscreen mode

Please Visit my Git Repo to check out all the previous day challenges.

https://github.com/ganeshraja10/automated-python-scripts

Top comments (0)

πŸ‘‹ Welcome the newest DEV members

Head over to our Welcome Thread and say hello!