Skip to content

Instantly share code, notes, and snippets.

@soulhotel
Last active July 5, 2024 00:41
Show Gist options
  • Save soulhotel/851ee4b91a659a416aeff2e926d96528 to your computer and use it in GitHub Desktop.
Save soulhotel/851ee4b91a659a416aeff2e926d96528 to your computer and use it in GitHub Desktop.
# Suggestion for https://www.gnome-look.org/p/2173282/ theme by dani ruiz
#!/bin/sh
# Save the current theme so the user can revert back to it with the uninstall.sh
current_theme=$(gsettings get org.gnome.desktop.interface gtk-theme)
# Print the current theme (optional)
# echo "Current theme: $current_theme"
# Write the current theme into uninstall.sh using a here-document with variable interpolation
cat <<EOL > uninstall.sh
#!/bin/sh
# The previously saved theme
previous_theme=$current_theme
# Check if the theme exists
if [ -d "/usr/share/themes/\$previous_theme" ] || [ -d "\$HOME/.themes/\$previous_theme" ]; then
gsettings set org.gnome.desktop.interface gtk-theme "\$previous_theme"
else
echo "Theme \$previous_theme not found. Reverting to default theme."
gsettings set org.gnome.desktop.interface gtk-theme 'Adwaita'
fi
# Remove the installed theme files
rm -rf \$HOME/.config/gtk-4.0/gtk.css \\
\$HOME/.config/gtk-4.0/assets \\
\$HOME/.themes/GNOME-4X/
EOL
# Make uninstall.sh executable
chmod +x uninstall.sh
# Proceed with setting the new theme
mkdir -p ~/.config/gtk-4.0/
cp -r -f libadwaita/* ~/.config/gtk-4.0/
mkdir -p ~/.themes/GNOME-4X
cp -a gtk-* ~/.themes/GNOME-4X/
gsettings set org.gnome.desktop.interface gtk-theme "GNOME-4X"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment