mirror of
https://github.com/duma799/hyprduma-config.git
synced 2026-05-14 14:41:00 +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
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import configparser
|
import configparser
|
||||||
|
import shlex
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
@@ -71,19 +72,19 @@ def ask_yn(prompt, default=True):
|
|||||||
return answer in ("y", "yes")
|
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:
|
if capture:
|
||||||
result = subprocess.run(
|
|
||||||
cmd, shell=True, capture_output=True, text=True, **kwargs
|
|
||||||
)
|
|
||||||
if check and result.returncode != 0:
|
if check and result.returncode != 0:
|
||||||
return None
|
return None
|
||||||
return result.stdout.strip()
|
return result.stdout.strip()
|
||||||
else:
|
if check:
|
||||||
result = subprocess.run(cmd, shell=True, **kwargs)
|
|
||||||
if check and result.returncode != 0:
|
|
||||||
return False
|
|
||||||
return result.returncode == 0
|
return result.returncode == 0
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def cmd_exists(name):
|
def cmd_exists(name):
|
||||||
@@ -380,12 +381,12 @@ def install_pywal(repo):
|
|||||||
|
|
||||||
if wallpaper.exists() and cmd_exists("wal"):
|
if wallpaper.exists() and cmd_exists("wal"):
|
||||||
print_info(f"Generating pywal colors from {wallpaper.name}...")
|
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")
|
print_ok("Generated initial pywal color scheme")
|
||||||
|
|
||||||
pywal_script = home / "pywal.sh"
|
pywal_script = home / "pywal.sh"
|
||||||
if pywal_script.exists():
|
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")
|
print_ok("Applied pywal colors to all components")
|
||||||
else:
|
else:
|
||||||
print_warn("pywal.sh had errors (normal if Hyprland isn't running yet)")
|
print_warn("pywal.sh had errors (normal if Hyprland isn't running yet)")
|
||||||
|
|||||||
Reference in New Issue
Block a user