Last active
April 5, 2021 15:30
-
-
Save nick3499/9e605fd061c460f94b1330426d92d104 to your computer and use it in GitHub Desktop.
Desktop Background Set: GNOME desktop background settings: subprocess.run(), os.listdir(), datetime, gsettings
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
#!/usr/bin/python3 | |
'''Gnome desktop background settings.''' | |
from subprocess import run | |
from os import listdir | |
from datetime import datetime | |
WALLPAPERS = listdir('/home/foo/Pictures/Wallpapers') | |
D = {} | |
for num, file_name in enumerate(WALLPAPERS): | |
D[num] = f'/home/foo/Pictures/Wallpapers/{file_name}' | |
if datetime.now().isocalendar()[1] % 2 == 0: | |
WKDAY = D[datetime.now().weekday()] | |
else: | |
WKDAY = D[datetime.now().weekday() + 7] | |
run(['gsettings', 'set', 'org.gnome.desktop.background', 'picture-options', | |
'"wallpaper"'], check=True) | |
run(['gsettings', 'set', 'org.gnome.desktop.background', 'picture-uri', | |
f'file://{WKDAY}'], check=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
WALLPAPERS
lists 14 images for desktop wallpaper in tile mode. So, depending on whether the week number is even or odd will determine which half of the/home/foo/Pictures/Wallpapers
directory the current background scheme will come from. Notice how7
will be added to the weekday value stored inWKDAY
if the week number value is odd.