2024-12-23 16:56:15 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2025-01-20 12:53:06 +01:00
|
|
|
print_help() {
|
|
|
|
echo "Usage: $0 [input-file]"
|
|
|
|
echo
|
|
|
|
echo "Changes your current wallpaper"
|
|
|
|
echo "Please note that this script is made to be used with the Atlas Desktop and will probably not work on most other desktops."
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ $# -ne 1 ]; then
|
|
|
|
print_help
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-12-23 16:56:15 +01:00
|
|
|
# Check if file exists
|
2025-01-20 12:53:06 +01:00
|
|
|
if [ -e "$1" ]; then
|
2024-12-23 16:56:15 +01:00
|
|
|
|
|
|
|
# Variables declaration
|
|
|
|
wallpaper_config=~/.config/hypr/hyprpaper.conf
|
|
|
|
wallpaper_path=~/.config/hypr/images/wallpaper # Doesn't contain file extension
|
|
|
|
file_extension="${1##*.}"
|
|
|
|
|
2025-01-20 12:53:06 +01:00
|
|
|
# In case file has no extension
|
|
|
|
if [ "${file_extension}" == "$1" ]; then
|
|
|
|
echo "Error: please provide a file extension (ex: .jpg, .png...)"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-12-23 16:56:15 +01:00
|
|
|
# Remove old wallpaper
|
|
|
|
rm $wallpaper_path*
|
|
|
|
|
|
|
|
# Copy file
|
2025-01-20 12:53:06 +01:00
|
|
|
cp "$1" "${wallpaper_path}.${file_extension}"
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
echo "Aborted."
|
|
|
|
exit 1
|
|
|
|
fi
|
2024-12-23 16:56:15 +01:00
|
|
|
|
|
|
|
# Update config
|
|
|
|
sed -i "s/wallpaper\.[^[:space:]]*/wallpaper.$file_extension/g" $wallpaper_config # Replace current extension by new extension
|
2025-01-20 12:53:06 +01:00
|
|
|
if [ $? != 0 ]; then
|
|
|
|
echo "Aborted."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-12-23 16:56:15 +01:00
|
|
|
# Reload Hyprpaper
|
|
|
|
pkill hyprpaper
|
2025-01-20 12:53:06 +01:00
|
|
|
hyprctl dispatch exec hyprpaper > /dev/null # Start hyprpaper and hide stdout output
|
|
|
|
# Or you can do the old fashioned way :
|
|
|
|
# nohup hyprpaper </dev/null >/dev/null 2>&1 &
|
2024-12-23 16:56:15 +01:00
|
|
|
|
|
|
|
echo "Done"
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
echo "Couldn't find '${1}': No such file or directory"
|
|
|
|
exit 1
|
|
|
|
fi
|