Created
February 12, 2024 11:46
-
-
Save MashukeAlam/a28e4384f26edd89bba69840ec9994a7 to your computer and use it in GitHub Desktop.
toggle theme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Function to get the current GNOME theme name | |
get_current_theme() { | |
gsettings get org.gnome.desktop.interface gtk-theme | awk -F\' '{print $2}' | |
} | |
# Function to toggle between light and dark themes | |
toggle_theme() { | |
current_theme=$(get_current_theme) | |
if [[ "$current_theme" == *"-Light-"* ]]; then | |
new_theme=${current_theme//-Light-/-Dark-} | |
gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark' | |
elif [[ "$current_theme" == *"-Dark-"* ]]; then | |
new_theme=${current_theme//-Dark-/-Light-} | |
gsettings set org.gnome.desktop.interface color-scheme 'default' | |
else | |
echo "Unsupported theme format: $current_theme" | |
exit 1 | |
fi | |
gsettings set org.gnome.desktop.interface gtk-theme "$new_theme" | |
echo "Theme toggled: $current_theme -> $new_theme" | |
} | |
toggle_theme |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
chmod +x <this_file.sh>
sudo mv <this_file.sh?> /usr/local/bin/toggle