mirror of
https://github.com/dylanaraps/pywal.git
synced 2024-11-29 03:13:47 +01:00
Merge pull request #388 from robwaz/master
Issues #330 & #382: MacOS bug fixes
This commit is contained in:
commit
975c00f30e
@ -11,7 +11,7 @@ from . import util
|
||||
|
||||
def set_special(index, color, iterm_name="h", alpha=100):
|
||||
"""Convert a hex color to a special sequence."""
|
||||
if OS == "Darwin":
|
||||
if OS == "Darwin" and iterm_name:
|
||||
return "\033]P%s%s\033\\" % (iterm_name, color.strip("#"))
|
||||
|
||||
if index in [11, 708] and alpha != "100":
|
||||
@ -51,16 +51,16 @@ def create_sequences(colors, vte_fix=False):
|
||||
set_special(10, colors["special"]["foreground"], "g"),
|
||||
set_special(11, colors["special"]["background"], "h", alpha),
|
||||
set_special(12, colors["special"]["cursor"], "l"),
|
||||
set_special(13, colors["special"]["foreground"], "l"),
|
||||
set_special(17, colors["special"]["foreground"], "l"),
|
||||
set_special(19, colors["special"]["background"], "l"),
|
||||
set_special(13, colors["special"]["foreground"], "j"),
|
||||
set_special(17, colors["special"]["foreground"], "k"),
|
||||
set_special(19, colors["special"]["background"], "m"),
|
||||
set_color(232, colors["special"]["background"]),
|
||||
set_color(256, colors["special"]["foreground"])
|
||||
])
|
||||
|
||||
if not vte_fix:
|
||||
sequences.extend(
|
||||
set_special(708, colors["special"]["background"], "l", alpha)
|
||||
set_special(708, colors["special"]["background"], "", alpha)
|
||||
)
|
||||
|
||||
if OS == "Darwin":
|
||||
|
@ -109,7 +109,18 @@ def set_mac_wallpaper(img):
|
||||
"""Set the wallpaper on macOS."""
|
||||
db_file = "Library/Application Support/Dock/desktoppicture.db"
|
||||
db_path = os.path.join(HOME, db_file)
|
||||
subprocess.call(["sqlite3", db_path, "update data set value = '%s'" % img])
|
||||
img_dir, _ = os.path.split(img)
|
||||
|
||||
# Clear the existing picture data and write the image paths
|
||||
sql = "delete from data; "
|
||||
sql += "insert into data values(\"%s\"); " % img_dir
|
||||
sql += "insert into data values(\"%s\"); " % img
|
||||
|
||||
# Set all monitors/workspaces to the selected image
|
||||
sql += "update preferences set data_id=2 where key=1 or key=2 or key=3; "
|
||||
sql += "update preferences set data_id=1 where key=10 or key=20 or key=30;"
|
||||
|
||||
subprocess.call(["sqlite3", db_path, sql])
|
||||
|
||||
# Kill the dock to fix issues with cached wallpapers.
|
||||
# macOS caches wallpapers and if a wallpaper is set that shares
|
||||
|
Loading…
Reference in New Issue
Block a user