Skip to content

Instantly share code, notes, and snippets.

@LuisCardenasSolis
Created November 28, 2023 20:30
Show Gist options
  • Save LuisCardenasSolis/3b8b291822e08e2e645cf06a689c4e87 to your computer and use it in GitHub Desktop.
Save LuisCardenasSolis/3b8b291822e08e2e645cf06a689c4e87 to your computer and use it in GitHub Desktop.
Change Login background with custom image in ElementaryOS 7.1
#!/bin/bash
# Resources
# https://github.com/Blackmanx/elementaryOS-lockscreen-bgreplacer
if [ $(id -u) != 0 ];then
echo -e "Error: Run script as root user"
exit 1
fi
if [ -z "$1" ];then
echo -e "Error: Missing path image\n\n=> Usage: ./bg.sh /home/user/wallpaper.png\n"
exit 1
fi
if [ "$1" == "--reset" ];then
apt install -y --reinstall io.elementary.greeter
echo -e "\n=> SUCCESS: Background reset OK"
exit 0
fi
BG_IMAGE="$1"
if [ ! -f "$BG_IMAGE" ];then
echo -e "Error: File not found\n"
exit 1
else
echo "================== Start BG =================="
fi
dependencies_meson(){
apt install -y valac libaccountsservice-dev libgtk-3-dev libgranite-dev libhandy-1-dev liblightdm-gobject-1-dev libmutter-10-dev &> /dev/null
}
install_ninja(){
#python3 -m pip install ninja
if [ $(which ninja) ];then
echo "=> Ninja found : $(ninja --version)"
else
echo "=> Ninja not found (installing...)"
apt install -y ninja-build
fi
}
install_meson(){
if [ $(which meson) ];then
echo "=> Meson found : $(meson --version)"
else
echo "=> Meson not found (installing...)"
if [ ! $(which pip) ];then
apt install -y python3-pip &> /dev/null
fi
python3 -m pip install meson
fi
}
config_greeter(){
echo "=> Config greeter"
if [[ -d /tmp/greeter ]]; then
rm -rf /tmp/greeter
fi
# Download and configure greeter
git clone https://github.com/elementary/greeter.git /tmp/greeter &> /dev/null
rm -rf /tmp/greeter/data/texture.png
cp $BG_IMAGE /tmp/greeter/data/texture.png
# Replace path to new texture's path.
sed -i "s/resource\:\/\/\/io\/elementary\/desktop\/gala\/texture\.png/resource\:\/\/\/io\/elementary\/greeter\/texture\.png/" /tmp/greeter/compositor/SystemBackground.vala
}
build_greeter(){
config_greeter
echo "=> Build greeter"
cd /tmp/greeter
meson _build --prefix=/usr > /dev/null && ninja install -C _build > /dev/null
if [ $? != 0 ];then
echo -e "\n=> ERROR: Failed to build"
else
echo -e "\n=> SUCCESS: Background updated OK"
fi
}
install_ninja
install_meson
dependencies_meson
build_greeter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment