1
0
Fork 0

replace remove_directory with trash

- `trash` moves files and directories to the trash directory
  instead of permanently deleting them
This commit is contained in:
Kim, Jimin 2022-06-03 23:53:37 +09:00
parent 826209a81f
commit 061c34b581
3 changed files with 9 additions and 6 deletions

View file

@ -21,6 +21,7 @@ def initialize():
Initialize before running any code.
"""
install_via_pacman("trash-cli")
install_via_pacman("flatpak")
install_via_pacman("pip")

View file

@ -1,4 +1,4 @@
from src.util import paru_install, copy_file, remove_directory
from src.util import paru_install, copy_file, trash
from src.constants import content_dir, home_dir
from src import log
@ -20,7 +20,7 @@ def setup():
log.log("Installing powerlevel10k theme")
p10k_path = f"{home_dir}/.oh-my-zsh/custom/themes/powerlevel10k"
remove_directory(p10k_path)
trash(p10k_path)
system(
f"git clone --depth=1 https://github.com/romkatv/powerlevel10k.git {p10k_path}"
)
@ -29,7 +29,7 @@ def setup():
zsh_syntax_highlighting_path = (
f"{home_dir}/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting"
)
remove_directory(zsh_syntax_highlighting_path)
trash(zsh_syntax_highlighting_path)
system(
f"git clone --depth=1 https://github.com/zsh-users/zsh-syntax-highlighting.git {zsh_syntax_highlighting_path}"
)

View file

@ -47,11 +47,13 @@ def smart_mkdir(path: str):
pass
def remove_directory(path):
def trash(path):
"""Moves a file or directory to freedesktop trash."""
try:
system(f"rm -rf {path}")
system(f"trash-put {path}")
except Exception as err:
print(f"Failed to remove directory: {path}")
print(f"Failed to remove: {path}")
raise err