Skip to content

Instantly share code, notes, and snippets.

@sepastian
Created July 30, 2013 21:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sepastian/6117204 to your computer and use it in GitHub Desktop.
Save sepastian/6117204 to your computer and use it in GitHub Desktop.
Shell script for setting the the solarized theme to use, either 'dark' or 'light'.
#!/bin/bash
#
# Shell script for setting the the solarized theme to use,
# either 'dark' or 'light'.
#
# If no argument has been given, toggle between 'dark' and 'light'.
#
# Adapted from https://github.com/jouberthenk/dotfiles/blob/master/solarize.sh
#
# Solarized theme: http://ethanschoonover.com/solarized
declare -A styles
styles["#00002B2B3636"]="dark"
styles["#FDFDF6F6E3E3"]="light"
if [ "$#" -gt 1 ]; then
echo "usage: $(basename $0) [ dark | light ]"
echo "Use without an argument to toggle current theme."
exit 2
fi
# Find out what to do: set 'dark' or 'light' explicitly or toggle.
STYLE="$1"
if [ "$#" == 0 ]; then
CURRENT_BG_COLOR=$(gconftool-2 --get "/apps/gnome-terminal/profiles/Default/background_color")
STYLE="dark"
if [ ${styles["$CURRENT_BG_COLOR"]} == "dark" ]; then
STYLE="light"
fi
fi
if [[ ! $STYLE =~ (dark|light) ]]; then
echo "Argument must be one of 'dark' or 'light'."
exit 2
fi
# Use gconftool-2 to set the new theme.
if [ $STYLE == "dark" ]; then
PALETTE="#070736364242:#D3D301010202:#858599990000:#B5B589890000:#26268B8BD2D2:#D3D336368282:#2A2AA1A19898:#EEEEE8E8D5D5:#00002B2B3636:#CBCB4B4B1616:#58586E6E7575:#65657B7B8383:#838394949696:#6C6C7171C4C4:#9393A1A1A1A1:#FDFDF6F6E3E3"
BG_COLOR="#00002B2B3636"
FG_COLOR="#65657B7B8383"
else
PALETTE="#EEEEE8E8D5D5:#D3D301010202:#858599990000:#B5B589890000:#26268B8BD2D2:#D3D336368282:#2A2AA1A19898:#070736364242:#FDFDF6F6E3E3:#CBCB4B4B1616:#9393A1A1A1A1:#838394949696:#65657B7B8383:#6C6C7171C4C4:#58586E6E7575:#00002B2B3636"
BG_COLOR="#FDFDF6F6E3E3"
FG_COLOR="#838394949696"
fi
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/use_theme_background" --type bool false
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/use_theme_colors" --type bool false
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/palette" --type string "$PALETTE"
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/background_color" --type string "$BG_COLOR"
gconftool-2 --set "/apps/gnome-terminal/profiles/Default/foreground_color" --type string "$FG_COLOR"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment