Created
August 24, 2024 13:29
-
-
Save misterjupiter/688a16e1426cdac3fe32706843a8226c to your computer and use it in GitHub Desktop.
Example: setting a Chromecast live wallpaper on linux for the Gnome desktop with Python3, Selenium and Chromedriver
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# make sure you have Selenium installed: https://pypi.org/project/selenium/ | |
# make sure you have the latest chromedriver installed: https://googlechromelabs.github.io/chrome-for-testing/ | |
# save this file somewhere, change the paths as you need and make it autostart. enjoy. | |
from selenium import webdriver | |
from selenium.webdriver.chrome.options import Options | |
from selenium.webdriver.chrome.service import Service | |
import os | |
import time | |
import datetime | |
# Set path Selenium | |
DRIVER_PATH= '/PATH_TO_YOUR_CHROMEDRIVER' # change the path to the downloaded chromedriver executable | |
# url of your live wp | |
url = "https://clients5.google.com/cast/chromecast/home/" # change the url to your desired live wp | |
# make sure you start chromedriver as a service on linux | |
service = Service(executable_path=DRIVER_PATH) | |
# Options | |
options = Options() | |
options.add_argument("--headless") | |
options.add_argument("--start-maximized") | |
options.add_argument("--window-size=1920,1200") # Set the window size, e.g. the resolution of your screen to make the wp the right size | |
driver = webdriver.Chrome(options=options, service=service) | |
driver.get(url) | |
time.sleep(30) # wait 30 seconds, just to make sure | |
while True: | |
driver.get_screenshot_as_file("/home/YOUR_USERNAME/YOUR_WP_Dir/.tmp.png") | |
time.sleep(10) | |
os.system("gsettings set org.gnome.desktop.background picture-uri 'file:///home/YOUR_USERNAME/YOUR_WP_Dir/.tmp.png'") | |
time.sleep(20) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment