Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check backup version #34

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions change-gdm-background
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,32 @@ if [ ! -x "$(command -v glib-compile-resources)" ]; then
fi

# Assign the default gdm theme file path.
if [ "$(lsb_release -i | awk '{print $3}')" == 'Ubuntu' ]; then
gdm3Resource=/usr/share/gnome-shell/theme/Yaru/gnome-shell-theme.gresource
elif [ "$(lsb_release -i | awk '{print $3}')" == 'Pop' ]; then
gdm3Resource=/usr/share/gnome-shell/theme/Yaru/gnome-shell-theme.gresource
lsbRelease="$(lsb_release -i | awk '{print $3}')"
if [ "$lsbRelease" == "Pop" ]; then
gdm3Resource=/usr/share/gnome-shell/theme/Pop/gnome-shell-theme.gresource
fi

# Check backup version, does it match with the os distro?
etcGdm=/etc/change-gdm-background.conf
currentVersion="$(lsb_release -r | cut -f 2)"
if [[ (! -f "$etcGdm") && (! -f "$gdm3Resource"~) ]]; then
echo "$currentVersion" > "$etcGdm"
fi
if [[ (! -f "$etcGdm") && -f "$gdm3Resource"~ ]]; then
echo "Is this script working fine previously? (y/n):"
read -p " " -n 1
if [[ "$REPLY" =~ ^[yY]$ ]]; then
echo "$currentVersion" > "$etcGdm"
fi
fi
etcGdmContent="$(head -1 "$etcGdm")"
if [[ "$currentVersion" != "$etcGdmContent" && -f "$gdm3Resource"~ ]]; then
echo "Force making new backup."
echo "$currentVersion" > "$etcGdm"
cp -f "$gdm3Resource" "$gdm3Resource~"
fi

# Create a backup file of the original theme if there isn't one.
[ ! -f "$gdm3Resource"~ ] && cp "$gdm3Resource" "$gdm3Resource~"

Expand Down