mirror of
https://github.com/duma799/hyprduma-config.git
synced 2026-05-13 14:11:01 +00:00
Clean up install.py: fix run() semantics and add shlex.quote for paths
This commit is contained in:
+11
-10
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import configparser
|
||||
import shlex
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -71,19 +72,19 @@ def ask_yn(prompt, default=True):
|
||||
return answer in ("y", "yes")
|
||||
|
||||
|
||||
def run(cmd, check=True, capture=False, **kwargs):
|
||||
def run(cmd, capture=False, check=True, **kwargs):
|
||||
"""Run a shell command. Returns stdout string if capture=True (None on failure),
|
||||
or bool success if capture=False."""
|
||||
result = subprocess.run(
|
||||
cmd, shell=True, capture_output=capture, text=capture, **kwargs
|
||||
)
|
||||
if capture:
|
||||
result = subprocess.run(
|
||||
cmd, shell=True, capture_output=True, text=True, **kwargs
|
||||
)
|
||||
if check and result.returncode != 0:
|
||||
return None
|
||||
return result.stdout.strip()
|
||||
else:
|
||||
result = subprocess.run(cmd, shell=True, **kwargs)
|
||||
if check and result.returncode != 0:
|
||||
return False
|
||||
if check:
|
||||
return result.returncode == 0
|
||||
return True
|
||||
|
||||
|
||||
def cmd_exists(name):
|
||||
@@ -380,12 +381,12 @@ def install_pywal(repo):
|
||||
|
||||
if wallpaper.exists() and cmd_exists("wal"):
|
||||
print_info(f"Generating pywal colors from {wallpaper.name}...")
|
||||
run(f'wal -i "{wallpaper}"')
|
||||
run(f'wal -i {shlex.quote(str(wallpaper))}')
|
||||
print_ok("Generated initial pywal color scheme")
|
||||
|
||||
pywal_script = home / "pywal.sh"
|
||||
if pywal_script.exists():
|
||||
if run(f'bash "{pywal_script}"'):
|
||||
if run(f'bash {shlex.quote(str(pywal_script))}'):
|
||||
print_ok("Applied pywal colors to all components")
|
||||
else:
|
||||
print_warn("pywal.sh had errors (normal if Hyprland isn't running yet)")
|
||||
|
||||
Reference in New Issue
Block a user