mirror of
https://github.com/Nexoniarz/nexoniarz-config-nixos.git
synced 2026-11-03 04:24:27 +00:00
nixos config
This commit is contained in:
commit
5dc9fb020e
46 changed files with 6194 additions and 0 deletions
30
modules/scripts/wallpaper-delete.sh
Normal file
30
modules/scripts/wallpaper-delete.sh
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env bash
|
||||
# Removes a wallpaper by moving it to the freedesktop.org trash
|
||||
# (~/.local/share/Trash), the same mechanism Thunar's own delete uses —
|
||||
# so it shows up in Thunar's Trash and can be restored from there,
|
||||
# instead of `rm` permanently destroying it with no way back.
|
||||
set -euo pipefail
|
||||
|
||||
path="${1:?usage: wallpaper-delete <path>}"
|
||||
[ -e "$path" ] || exit 0
|
||||
|
||||
trash_dir="$HOME/.local/share/Trash"
|
||||
mkdir -p "$trash_dir/files" "$trash_dir/info"
|
||||
|
||||
name="$(basename "$path")"
|
||||
dest="$trash_dir/files/$name"
|
||||
info="$trash_dir/info/$name.trashinfo"
|
||||
n=1
|
||||
while [ -e "$dest" ] || [ -e "$info" ]; do
|
||||
dest="$trash_dir/files/${name}.$n"
|
||||
info="$trash_dir/info/${name}.$n.trashinfo"
|
||||
n=$((n + 1))
|
||||
done
|
||||
|
||||
cat > "$info" <<EOF
|
||||
[Trash Info]
|
||||
Path=$path
|
||||
DeletionDate=$(date +%Y-%m-%dT%H:%M:%S)
|
||||
EOF
|
||||
|
||||
mv "$path" "$dest"
|
||||
Loading…
Reference in a new issue