all repos — dotfiles @ 4d217414127f7d4ff4256682a1087d86d68871bd

my *nix dotfiles

bin/palenight.sh (view raw)

  1#!/usr/bin/env bash
  2# Base16 - Gnome Terminal color scheme install script
  3
  4[[ -z "$PROFILE_NAME" ]] && PROFILE_NAME="palenight"
  5[[ -z "$PROFILE_SLUG" ]] && PROFILE_SLUG="base16-material-palenight"
  6[[ -z "$DCONF" ]] && DCONF=dconf
  7[[ -z "$UUIDGEN" ]] && UUIDGEN=uuidgen
  8
  9dset() {
 10    local key="$1"; shift
 11    local val="$1"; shift
 12
 13    if [[ "$type" == "string" ]]; then
 14        val="'$val'"
 15    fi
 16
 17    "$DCONF" write "$PROFILE_KEY/$key" "$val"
 18}
 19
 20# because dconf still doesn't have "append"
 21dlist_append() {
 22    local key="$1"; shift
 23    local val="$1"; shift
 24
 25    local entries="$(
 26        {
 27            "$DCONF" read "$key" | tr -d '[]' | tr , "\n" | fgrep -v "$val"
 28            echo "'$val'"
 29        } | head -c-1 | tr "\n" ,
 30    )"
 31
 32    "$DCONF" write "$key" "[$entries]"
 33}
 34
 35# Newest versions of gnome-terminal use dconf
 36if which "$DCONF" > /dev/null 2>&1; then
 37    [[ -z "$BASE_KEY_NEW" ]] && BASE_KEY_NEW=/org/gnome/terminal/legacy/profiles:
 38
 39    if [[ -n "`$DCONF list $BASE_KEY_NEW/`" ]]; then
 40        if which "$UUIDGEN" > /dev/null 2>&1; then
 41            PROFILE_SLUG=`uuidgen`
 42        fi
 43
 44        if [[ -n "`$DCONF read $BASE_KEY_NEW/default`" ]]; then
 45            DEFAULT_SLUG=`$DCONF read $BASE_KEY_NEW/default | tr -d \'`
 46        else
 47            DEFAULT_SLUG=`$DCONF list $BASE_KEY_NEW/ | grep '^:' | head -n1 | tr -d :/`
 48        fi
 49
 50        DEFAULT_KEY="$BASE_KEY_NEW/:$DEFAULT_SLUG"
 51        PROFILE_KEY="$BASE_KEY_NEW/:$PROFILE_SLUG"
 52
 53        # copy existing settings from default profile
 54        $DCONF dump "$DEFAULT_KEY/" | $DCONF load "$PROFILE_KEY/"
 55
 56        # add new copy to list of profiles
 57        dlist_append $BASE_KEY_NEW/list "$PROFILE_SLUG"
 58
 59        # update profile values with theme options
 60        dset visible-name "'$PROFILE_NAME'"
 61        dset palette "['#292d3e', '#f07178', '#c3e88d', '#ffcb6b', '#82aaff', '#c792ea', '#89ddff', '#d0d0d0', '#434758', '#ff8b92', '#ddffa7', '#ffe585', '#9cc4ff', '#e1acff', '#a3f7ff', '#ffffff']"
 62        dset background-color "'#292d3e'"
 63        dset foreground-color "'#959dcb'"
 64        dset bold-color "'#959dcb'"
 65        dset bold-color-same-as-fg "true"
 66        dset use-theme-colors "false"
 67        dset use-theme-background "false"
 68
 69        unset PROFILE_NAME
 70        unset PROFILE_SLUG
 71        unset DCONF
 72        unset UUIDGEN
 73        exit 0
 74    fi
 75fi
 76
 77# Fallback for Gnome 2 and early Gnome 3
 78[[ -z "$GCONFTOOL" ]] && GCONFTOOL=gconftool
 79[[ -z "$BASE_KEY" ]] && BASE_KEY=/apps/gnome-terminal/profiles
 80
 81PROFILE_KEY="$BASE_KEY/$PROFILE_SLUG"
 82
 83gset() {
 84    local type="$1"; shift
 85    local key="$1"; shift
 86    local val="$1"; shift
 87
 88    "$GCONFTOOL" --set --type "$type" "$PROFILE_KEY/$key" -- "$val"
 89}
 90
 91# Because gconftool doesn't have "append"
 92glist_append() {
 93    local type="$1"; shift
 94    local key="$1"; shift
 95    local val="$1"; shift
 96
 97    local entries="$(
 98        {
 99            "$GCONFTOOL" --get "$key" | tr -d '[]' | tr , "\n" | fgrep -v "$val"
100            echo "$val"
101        } | head -c-1 | tr "\n" ,
102    )"
103
104    "$GCONFTOOL" --set --type list --list-type $type "$key" "[$entries]"
105}
106
107# Append the Base16 profile to the profile list
108glist_append string /apps/gnome-terminal/global/profile_list "$PROFILE_SLUG"
109
110gset string visible_name "$PROFILE_NAME"
111gset string palette "#292d3e:#f07178:#c3e88d:#ffcb6b:#82aaff:#c792ea:#89ddff:#d0d0d0:#434758:#ff8b92:#ddffa7:#ffe585:#9cc4ff:#e1acff:#a3f7ff:#ffffff"
112gset string background_color "#292d3e"
113gset string foreground_color "#959dcb"
114gset string bold_color "#959dcb"
115gset bool   bold_color_same_as_fg "true"
116gset bool   use_theme_colors "false"
117gset bool   use_theme_background "false"
118
119unset PROFILE_NAME
120unset PROFILE_SLUG
121unset DCONF
122unset UUIDGEN