mirror of
https://github.com/dylanaraps/pywal.git
synced 2025-01-08 15:09:38 +01:00
General: Set the wallpaper
This commit is contained in:
parent
9d061fc083
commit
39e077c68b
35
wal.py
35
wal.py
@ -4,9 +4,12 @@ Created by Dylan Araps
|
||||
"""
|
||||
import argparse
|
||||
import re
|
||||
import subprocess
|
||||
import random
|
||||
import glob
|
||||
import shutil
|
||||
|
||||
import subprocess
|
||||
from subprocess import call
|
||||
|
||||
import os
|
||||
from os.path import expanduser
|
||||
@ -181,6 +184,35 @@ def send_sequences(colors):
|
||||
term_file.close()
|
||||
|
||||
|
||||
def set_wallpaper(img):
|
||||
"""Set the wallpaper."""
|
||||
if shutil.which("feh"):
|
||||
call(["feh", "--bg-fill", img])
|
||||
|
||||
elif shutil.which("nitrogen"):
|
||||
call(["nitrogen", "--set-zoom-fill", img])
|
||||
|
||||
elif shutil.which("bgs"):
|
||||
call(["bgs", img])
|
||||
|
||||
elif shutil.which("hsetroot"):
|
||||
call(["hsetroot", "-fill", img])
|
||||
|
||||
elif shutil.which("habak"):
|
||||
call(["habak", "-mS", img])
|
||||
|
||||
elif OS == "Darwin":
|
||||
call(["osascript", "-e", "'tell application \"Finder\" to set \
|
||||
desktop picture to POSIX file \"'\"", img, "\""])
|
||||
|
||||
else:
|
||||
call(["gsettings", "set", "org.gnome.desktop.background",
|
||||
"picture-uri", img])
|
||||
|
||||
print("wallpaper: Set the new wallpaper")
|
||||
return 0
|
||||
|
||||
|
||||
def main():
|
||||
"""Main script function."""
|
||||
args = get_args()
|
||||
@ -191,6 +223,7 @@ def main():
|
||||
|
||||
colors = get_colors(image)
|
||||
send_sequences(colors)
|
||||
set_wallpaper(image)
|
||||
|
||||
return 0
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user