Advertisement
poetician

Avocado | gnome-terminal

Apr 7th, 2021
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.38 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. # Base16 oomox-avocado_2 - Gnome Terminal color scheme install script
  3. # oomox-avocado_2
  4.  
  5. [[ -z "$PROFILE_NAME" ]] && PROFILE_NAME="Base 16 oomox-avocado_2"
  6. [[ -z "$PROFILE_SLUG" ]] && PROFILE_SLUG="base-16-oomox-avocado_2"
  7. [[ -z "$DCONF" ]] && DCONF=dconf
  8. [[ -z "$UUIDGEN" ]] && UUIDGEN=uuidgen
  9.  
  10. dset() {
  11. local key="$1"; shift
  12. local val="$1"; shift
  13.  
  14. if [[ "$type" == "string" ]]; then
  15. val="'$val'"
  16. fi
  17.  
  18. "$DCONF" write "$PROFILE_KEY/$key" "$val"
  19. }
  20.  
  21. # Because dconf still doesn't have "append"
  22. dlist_append() {
  23. local key="$1"; shift
  24. local val="$1"; shift
  25.  
  26. local entries="$(
  27. {
  28. "$DCONF" read "$key" | tr -d '[]' | tr , "\n" | fgrep -v "$val"
  29. echo "'$val'"
  30. } | head -c-1 | tr "\n" ,
  31. )"
  32.  
  33. "$DCONF" write "$key" "[$entries]"
  34. }
  35.  
  36. # Newest versions of gnome-terminal use dconf
  37. if which "$DCONF" > /dev/null 2>&1; then
  38. # Check that uuidgen is available
  39. type $UUIDGEN >/dev/null 2>&1 || { echo >&2 "Requires uuidgen but it's not installed. Aborting!"; exit 1; }
  40.  
  41. [[ -z "$BASE_KEY_NEW" ]] && BASE_KEY_NEW=/org/gnome/terminal/legacy/profiles:
  42.  
  43. if [[ -n "`$DCONF list $BASE_KEY_NEW/`" ]]; then
  44. if which "$UUIDGEN" > /dev/null 2>&1; then
  45. PROFILE_SLUG=`uuidgen`
  46. fi
  47.  
  48. if [[ -n "`$DCONF read $BASE_KEY_NEW/default`" ]]; then
  49. DEFAULT_SLUG=`$DCONF read $BASE_KEY_NEW/default | tr -d \'`
  50. else
  51. DEFAULT_SLUG=`$DCONF list $BASE_KEY_NEW/ | grep '^:' | head -n1 | tr -d :/`
  52. fi
  53.  
  54. DEFAULT_KEY="$BASE_KEY_NEW/:$DEFAULT_SLUG"
  55. PROFILE_KEY="$BASE_KEY_NEW/:$PROFILE_SLUG"
  56.  
  57. # Copy existing settings from default profile
  58. $DCONF dump "$DEFAULT_KEY/" | $DCONF load "$PROFILE_KEY/"
  59.  
  60. # Add new copy to list of profiles
  61. dlist_append $BASE_KEY_NEW/list "$PROFILE_SLUG"
  62.  
  63. # Update profile values with theme options
  64. dset visible-name "'$PROFILE_NAME'"
  65. dset palette "['#d2e190', '#617b30', '#81a140', '#234f1e', '#74923a', '#a3bf45', '#234f1e', '#234f1e', '#7a9857', '#234f1e', '#001c00', '#001c00', '#e6f5a4', '#ECFBAA', '#2d5113', '#ECFBAA']"
  66. dset background-color "'#d2e190'"
  67. dset foreground-color "'#234f1e'"
  68. dset bold-color "'#234f1e'"
  69. dset bold-color-same-as-fg "true"
  70. dset cursor-colors-set "true"
  71. dset cursor-background-color "'#234f1e'"
  72. dset cursor-foreground-color "'#d2e190'"
  73. dset use-theme-colors "false"
  74. dset use-theme-background "false"
  75.  
  76. unset PROFILE_NAME
  77. unset PROFILE_SLUG
  78. unset DCONF
  79. unset UUIDGEN
  80. exit 0
  81. fi
  82. fi
  83.  
  84. # Fallback for Gnome 2 and early Gnome 3
  85. [[ -z "$GCONFTOOL" ]] && GCONFTOOL=gconftool
  86. [[ -z "$BASE_KEY" ]] && BASE_KEY=/apps/gnome-terminal/profiles
  87.  
  88. PROFILE_KEY="$BASE_KEY/$PROFILE_SLUG"
  89.  
  90. gset() {
  91. local type="$1"; shift
  92. local key="$1"; shift
  93. local val="$1"; shift
  94.  
  95. "$GCONFTOOL" --set --type "$type" "$PROFILE_KEY/$key" -- "$val"
  96. }
  97.  
  98. # Because gconftool doesn't have "append"
  99. glist_append() {
  100. local type="$1"; shift
  101. local key="$1"; shift
  102. local val="$1"; shift
  103.  
  104. local entries="$(
  105. {
  106. "$GCONFTOOL" --get "$key" | tr -d '[]' | tr , "\n" | fgrep -v "$val"
  107. echo "$val"
  108. } | head -c-1 | tr "\n" ,
  109. )"
  110.  
  111. "$GCONFTOOL" --set --type list --list-type $type "$key" "[$entries]"
  112. }
  113.  
  114. # Append the Base16 profile to the profile list
  115. glist_append string /apps/gnome-terminal/global/profile_list "$PROFILE_SLUG"
  116.  
  117. gset string visible_name "$PROFILE_NAME"
  118. gset string palette "#d2e190:#617b30:#81a140:#234f1e:#74923a:#a3bf45:#234f1e:#234f1e:#7a9857:#617b30:#81a140:#234f1e:#74923a:#a3bf45:#234f1e:#ECFBAA"
  119. gset string palette "['#d2e190', '#617b30', '#81a140', '#234f1e', '#74923a', '#a3bf45', '#234f1e', '#234f1e', '#7a9857', '#234f1e', '#001c00', '#001c00', '#e6f5a4', '#ECFBAA', '#2d5113', '#ECFBAA']"
  120. gset string background_color "#d2e190"
  121. gset string foreground_color "#234f1e"
  122. gset string bold_color "#234f1e"
  123. gset bool bold_color_same_as_fg "true"
  124. gset bool cursor-colors-set "true"
  125. gset string cursor-background-color "'#234f1e'"
  126. gset string cursor-foreground-color "'#d2e190'"
  127. gset bool use_theme_colors "false"
  128. gset bool use_theme_background "false"
  129.  
  130. unset PROFILE_NAME
  131. unset PROFILE_SLUG
  132. unset DCONF
  133. unset UUIDGEN
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement