You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
113 lines
4.4 KiB
113 lines
4.4 KiB
#!/bin/bash
|
|
|
|
# ▄█ █▄ ▄████████ ▄█ ▄█ ▄█ ▄████████ ▄██ ▄
|
|
# ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ██▄
|
|
# ███ ███ ███ ███ ███ ███ ███▌ ███ █▀ ███▄▄▄███
|
|
# ███ ███ ███ ███ ███ ███ ███▌ ▄███▄▄▄ ▀▀▀▀▀▀███
|
|
# ███ ███ ▀███████████ ███ ███ ███▌ ▀▀███▀▀▀ ▄██ ███
|
|
# ███ ███ ███ ███ ███ ███ ███ ███ ███ ███
|
|
# ███ ▄█▄ ███ ███ ███ ███▌ ▄ ███▌ ▄ ███ ███ ███ ███
|
|
# ▀███▀███▀ ███ █▀ █████▄▄██ █████▄▄██ █▀ ███ ▀█████▀
|
|
# ▀ ▀
|
|
|
|
# help()
|
|
#
|
|
# Print the help message
|
|
function help() {
|
|
echo "Usage: $0 [-h | -c | --uninstall]"
|
|
echo ""
|
|
echo "-h, --help Show this help"
|
|
echo "-c, --config Start the setup process"
|
|
echo "--uninstall Uninstall the software"
|
|
}
|
|
|
|
# uninstall()
|
|
#
|
|
# Uninstall Wallify. This function will remove the autostart file,
|
|
# the configuration file and the configuration directory.
|
|
function uninstall() {
|
|
start_time=$(date +%s%3N)
|
|
|
|
echo "Uninstalling..."
|
|
if [ -f ~/.config/autostart/wallify.sh.desktop ]; then
|
|
rm -f ~/.config/autostart/wallify.sh.desktop
|
|
else
|
|
echo "Error: ~/.config/autostart/wallify.sh.desktop does not exist."
|
|
fi
|
|
if [ -d ~/.config/Wallify ]; then
|
|
rm -rf ~/.config/Wallify
|
|
else
|
|
echo "Error: ~/.config/Wallify does not exist."
|
|
fi
|
|
echo "Done."
|
|
|
|
end_time=$(date +%s%3N)
|
|
duration=$((end_time - start_time))
|
|
echo "Uninstallation took $duration milliseconds."
|
|
}
|
|
|
|
# config()
|
|
#
|
|
# This function is used to configure Wallify. It will ask the user to select
|
|
# a wallpaper file and then create a configuration file, a start script and an
|
|
# autostart file. The configuration file will be saved in
|
|
# `~/.config/Wallify/wallpaper.conf` and will contain the path of the selected
|
|
# wallpaper. The start script will be saved in
|
|
# `~/.config/Wallify/start.sh` and will contain the command to launch the
|
|
# wallpaper with the selected options. The autostart file will be saved in
|
|
# `~/.config/autostart/wallify.sh.desktop` and will contain the command to launch
|
|
# the start script on startup.
|
|
function config() {
|
|
USER=$(whoami)
|
|
WALLPAPER_FILE=$(zenity --file-selection --title="Wallify - Select a wallpaper" --filename="" 2>/dev/null)
|
|
if [ $? -eq 0 ]; then
|
|
echo "Selected file: $WALLPAPER_FILE"
|
|
if [ -f "$WALLPAPER_FILE" ]; then
|
|
echo "+ Creating configuration directory"
|
|
mkdir -p ~/.config/Wallify
|
|
echo "+ Creating configuration file"
|
|
echo "WALLPAPER_FILE=$WALLPAPER_FILE" > ~/.config/Wallify/wallpaper.conf
|
|
echo "+ Creating start.sh script"
|
|
cat > ~/.config/Wallify/start.sh <<EOF
|
|
#!/bin/bash
|
|
user=$(whoami)
|
|
|
|
sleep 2
|
|
WALLPAPER_FILE=$(cat ~/.config/Wallify/wallpaper.conf | grep WALLPAPER_FILE | cut -d '=' -f2)
|
|
gsettings set org.gnome.desktop.background picture-uri file://$WALLPAPER_FILE
|
|
/home/UCA/machirat1/public/WallPaper/wallify -ni -fs -s -sp -st -b -nf -- mpv -wid WID --loop --no-audio $WALLPAPER_FILE &
|
|
EOF
|
|
chmod +x start.sh
|
|
echo "+ Creating autostart file"
|
|
cat > ~/.config/autostart/wallify.sh.desktop <<EOF
|
|
[Desktop Entry]
|
|
Version=1.0
|
|
Type=Application
|
|
Name=Wallify
|
|
Exec=/home/UCA/$USER/.config/Wallify/start.sh
|
|
Comment=Wallify
|
|
EOF
|
|
echo "Setup complete. You can restart your session to apply the changes."
|
|
else
|
|
zenity --error --text="Selected file is not a valid file"
|
|
fi
|
|
else
|
|
zenity --error --text="No file selected"
|
|
fi
|
|
}
|
|
|
|
case "$1" in
|
|
-h|--help)
|
|
help
|
|
;;
|
|
-c|--config)
|
|
config
|
|
;;
|
|
--uninstall)
|
|
uninstall
|
|
;;
|
|
*)
|
|
help
|
|
;;
|
|
esac
|