Compare commits

...

15 Commits

25 changed files with 654 additions and 182 deletions

View File

@@ -11,7 +11,7 @@ Clone the repo with submodules
```
git clone --recurse-submodules https://git.sys42.net/dakedres/shchemes.git
```
Add symlink it to somewhere in your PATH. Pick your poison
Symlink to it somewhere in your PATH. Pick your poison
```sh
ln -s $PWD/shchemes ~/bin/shchemes
ln -s $PWD/shchemes ~/.local/bin/shchemes
@@ -55,8 +55,13 @@ Note you'll have to add all the comments for where to place the injections
See the [cookbook](./doc/cookbook.md) for some ideas on ways to use Shchemes.
You can read the manual [in your browser](./doc/manual.md) or by running `shchemes help`.
## Credits
This software is a work of opportunism
- [mo](https://github.com/tests-always-included/mo) - Mustache templates in bash. Shchemes wouldn't be possible without it.
- [tinted-theming/schemes](https://github.com/tinted-theming/schemes) - Pretty much all the base16 themes
- [tinted-theming/schemes](https://github.com/tinted-theming/schemes) - Several base16 themes
- [deathbeam/base16-discord](https://github.com/deathbeam/base16-discord) - The base16 `better-discord` target
- [mk12/base16-kitty](https://github.com/mk12/base16-kitty) - The base16 `kitty` target

View File

@@ -1,6 +0,0 @@
#!/bin/sh
awk -F ' *: *' '
/^#/ { print }
$1 ~ "palette" { p = 1; next }
p && /^ +/ { gsub(/ /, "", $1); print $1 "=" $2 }
' $1

View File

@@ -1,9 +0,0 @@
echo '
https://raw.githubusercontent.com/tinted-theming/base16-qutebrowser/main/templates/default.mustache qutebrowser
https://raw.githubusercontent.com/tinted-theming/base16-qutebrowser/main/templates/minimal.mustache qutebrowser-minimal
https://raw.githubusercontent.com/tinted-theming/base16-rofi/master/templates/default.mustache rofi
https://raw.githubusercontent.com/tinted-theming/base16-rofi/master/templates/minimal.mustache rofi-minimal
https://raw.githubusercontent.com/aarowill/base16-alacritty/master/templates/default.mustache alacritty
' | awk '
/^http/ { system("shchemes install_tinted_template " $1 " " $2) }
'

View File

@@ -1,7 +0,0 @@
#!/bin/sh
NAME=$1
URL=https://raw.githubusercontent.com/tinted-theming/schemes/master/base16/$NAME.yaml
cd $(dirname $(readlink -f $0))
curl $URL | sh ./convert_scheme.sh > ./schemes/$NAME.properties

View File

@@ -1,16 +0,0 @@
base00="141F2E"
base01="1e5c1e"
base02="273e5c"
base03="a0ffa0"
base04="1e5c1e"
base05="FFCC33"
base06="91CCFF"
base07="375780"
base08="fffab1"
base09="FF8080"
base0A="91CCFF"
base0B="80ff80"
base0C="80ff80"
base0D="a2cff5"
base0E="0099FF"
base0F="e7e7e7"

View File

@@ -1,16 +0,0 @@
base00="ffffff"
base01="f5f5f5"
base02="c8c8fa"
base03="969896"
base04="e8e8e8"
base05="333333"
base06="ffffff"
base07="ffffff"
base08="ed6a43"
base09="0086b3"
base0A="795da3"
base0B="183691"
base0C="183691"
base0D="795da3"
base0E="a71d5d"
base0F="333333"

View File

@@ -1,16 +0,0 @@
base00="190134"
base01="392551"
base02="5A496E"
base03="7B6D8B"
base04="9C92A8"
base05="BDB6C5"
base06="DEDAE2"
base07="FEFFFF"
base08="27D9D5"
base09="5BA2B6"
base0A="8F6C97"
base0B="C33678"
base0C="F80059"
base0D="BD0152"
base0E="82034C"
base0F="470546"

View File

@@ -1,16 +0,0 @@
base00="1C1E26"
base01="232530"
base02="2E303E"
base03="6F6F70"
base04="9DA0A2"
base05="CBCED0"
base06="DCDFE4"
base07="E3E6EE"
base08="E95678"
base09="FAB795"
base0A="FAC29A"
base0B="29D398"
base0C="59E1E3"
base0D="26BBD9"
base0E="EE64AC"
base0F="F09383"

View File

@@ -1,16 +0,0 @@
base00="F0F0F0"
base01="F0D848"
base02="FFF018"
base03="F01818"
base04="F00000"
base05="D80000"
base06="489000"
base07="30A860"
base08="487830"
base09="183048"
base0A="426395"
base0B="5C5C6A"
base0C="2C3C57"
base0D="001878"
base0E="900000"
base0F="140C0D"

View File

@@ -6,32 +6,32 @@ draw_bold_text_with_bright_colors = false
# Default colors
[colors.primary]
background = '0x{{base00}}'
foreground = '0x{{base05}}'
background = "#{{base00}}"
foreground = "#{{base05}}"
# Colors the cursor will use if `custom_cursor_colors` is true
[colors.cursor]
text = '0x{{base00}}'
cursor = '0x{{base05}}'
text = "#{{base00}}"
cursor = "#{{base05}}"
# Normal colors
[colors.normal]
black = '0x{{base00}}'
red = '0x{{base08}}'
green = '0x{{base0B}}'
yellow = '0x{{base0A}}'
blue = '0x{{base0D}}'
magenta = '0x{{base0E}}'
cyan = '0x{{base0C}}'
white = '0x{{base05}}'
black = "#{{base00}}"
red = "#{{base08}}"
green = "#{{base0B}}"
yellow = "#{{base0A}}"
blue = "#{{base0D}}"
magenta = "#{{base0E}}"
cyan = "#{{base0C}}"
white = "#{{base05}}"
# Bright colors
[colors.bright]
black = '0x{{base03}}'
red = '0x{{base09}}'
green = '0x{{base01}}'
yellow = '0x{{base02}}'
blue = '0x{{base04}}'
magenta = '0x{{base06}}'
cyan = '0x{{base0F}}'
white = '0x{{base07}}'
black = "#{{base03}}"
red = "#{{base09}}"
green = "#{{base01}}"
yellow = "#{{base02}}"
blue = "#{{base04}}"
magenta = "#{{base06}}"
cyan = "#{{base0F}}"
white = "#{{base07}}"

View File

@@ -0,0 +1,54 @@
/**
* @name base16 {{scheme-name}}
* @author {{scheme-author}}
* @version 1.0.0
* @description base16 {{scheme-name}} theme generated from https://github.com/tinted-theming/schemes
**/
:root {
--base00: #{{base00}}; /* Black */
--base01: #{{base01}}; /* Bright Black */
--base02: #{{base02}}; /* Grey */
--base03: #{{base03}}; /* Brighter Grey */
--base04: #{{base04}}; /* Bright Grey */
--base05: #{{base05}}; /* White */
--base06: #{{base06}}; /* Brighter White */
--base07: #{{base07}}; /* Bright White */
--base08: #{{base08}}; /* Red */
--base09: #{{base09}}; /* Orange */
--base0A: #{{base0A}}; /* Yellow */
--base0B: #{{base0B}}; /* Green */
--base0C: #{{base0C}}; /* Cyan */
--base0D: #{{base0D}}; /* Blue */
--base0E: #{{base0E}}; /* Purple */
--base0F: #{{base0F}}; /* Magenta */
--primary-630: var(--base00); /* Autocomplete background */
--primary-660: var(--base00); /* Search input background */
}
.theme-light, .theme-dark {
--search-popout-option-fade: none; /* Disable fade for search popout */
--bg-overlay-2: var(--base00); /* These 2 are needed for proper threads coloring */
--home-background: var(--base00);
--background-primary: var(--base00);
--background-secondary: var(--base01);
--background-secondary-alt: var(--base01);
--channeltextarea-background: var(--base01);
--background-tertiary: var(--base00);
--background-accent: var(--base0E);
--background-floating: var(--base01);
--background-modifier-selected: var(--base00);
--text-normal: var(--base05);
--text-secondary: var(--base00);
--text-muted: var(--base03);
--text-link: var(--base0C);
--interactive-normal: var(--base05);
--interactive-hover: var(--base0C);
--interactive-active: var(--base0A);
--interactive-muted: var(--base03);
--header-primary: var(--base06);
--header-secondary: var(--base03);
--scrollbar-thin-track: transparent;
--scrollbar-auto-track: transparent;
}

View File

@@ -1,3 +1,3 @@
bspc config normal_border_color "#{{base01}}"
bspc config active_border_color "#{{base04}}"
bspc config focused_border_color "#{{base0C}}"
bspc config normal_border_color "#{{base02}}"
bspc config active_border_color "#{{base03}}"
bspc config focused_border_color "#{{base04}}"

View File

@@ -0,0 +1,27 @@
# :root {
# --vii: #{{base01}};
# --vi: #{{base03}};
# --v: #{{base08}};
# --iv: #{{base05}};
# --iiv: #{{base07}};
# --a: #{{base0C}};
# }
:root {
--base00: #{{base00}};
--base01: #{{base01}};
--base02: #{{base02}};
--base03: #{{base03}};
--base04: #{{base04}};
--base05: #{{base05}};
--base06: #{{base06}};
--base07: #{{base07}};
--base08: #{{base08}};
--base09: #{{base09}};
--base0A: #{{base0A}};
--base0B: #{{base0B}};
--base0C: #{{base0C}};
--base0D: #{{base0D}};
--base0E: #{{base0E}};
--base0F: #{{base0F}};
}

View File

@@ -0,0 +1,45 @@
# Base16 {{scheme-name}} - kitty color config
# Scheme by {{scheme-author}}
visual_bell_color #{{darken base00 "5"}}
background #{{base00}}
foreground #{{base05}}
selection_background #{{base05}}
selection_foreground #{{base00}}
url_color #{{base0D}}
cursor #{{base0D}}
cursor_text_color #{{base00}}
active_border_color #{{base03}}
inactive_border_color #{{base01}}
active_tab_background #{{base00}}
active_tab_foreground #{{base05}}
inactive_tab_background #{{base01}}
inactive_tab_foreground #{{base04}}
# Normal
color0 #{{base00}}
color1 #{{base08}}
color2 #{{base0B}}
color3 #{{base0A}}
color4 #{{base0D}}
color5 #{{base0E}}
color6 #{{base0C}}
color7 #{{base05}}
# Bright (same as Normal except 8/15)
color8 #{{base03}}
color9 #{{base08}}
color10 #{{base0B}}
color11 #{{base0A}}
color12 #{{base0D}}
color13 #{{base0E}}
color14 #{{base0C}}
color15 #{{base07}}
# Other (like base16-shell)
color16 #{{base09}}
color17 #{{base0F}}
color18 #{{base01}}
color19 #{{base02}}
color20 #{{base04}}
color21 #{{base06}}

View File

@@ -0,0 +1,121 @@
/* Base16 {{scheme-name}}
* Scheme author: {{scheme-author}}
* Obsidian theme author: acidghost (https://github.com/acidghost)
*/
:root {
--font-monospace: 'Hack Nerd Font', 'Source Code Pro', monospace;
}
.theme-dark {
--background-primary: #{{base00}};
--background-primary-alt: #{{base01}};
--background-secondary: #{{base00}};
--background-secondary-alt: #{{base01}};
--background-modifier-border: #{{base03}};
--background-modifier-form-field: rgba(0, 0, 0, 0.3);
--background-modifier-form-field-highlighted: rgba(0, 0, 0, 0.22);
--background-modifier-box-shadow: rgba(0, 0, 0, 0.3);
--background-modifier-success: #{{base0B}};
--background-modifier-error: #{{base08}};
--background-modifier-error-rgb: {{rgb_r base08}}, {{rgb_g base08}}, {{rgb_b base08}};
/* --background-modifier-error-hover: #470000; */
--background-modifier-cover: rgba(0, 0, 0, 0.8);
--text-accent: #{{base0F}};
--text-accent-hover: #{{base0D}};
--text-normal: #{{base07}};
--text-muted: #{{base05}};
--text-muted-rgb: {{rgb_r base05}}, {{rgb_g base05}}, {{rgb_b base05}};
--text-faint: #{{base03}};
--text-error: #{{base0E}};
--text-error-hover: #{{base08}};
--text-highlight-bg: rgba(255, 255, 0, 0.4);
--text-highlight-bg-active: rgba(255, 128, 0, 0.4);
--text-selection: rgba(23, 48, 77, 0.99);
--text-on-accent: #dcddde;
--interactive-normal: #2a2a2a;
--interactive-hover: #303030;
--interactive-accent: #{{base0F}};
--interactive-accent-rgb: {{rgb_r base0F}}, {{rgb_g base0F}}, {{rgb_b base0F}};
--interactive-accent-hover: #{{base0E}};
--interactive-success: #197300;
--scrollbar-active-thumb-bg: rgba(255, 255, 255, 0.1);
--scrollbar-bg: rgba(255, 255, 255, 0.05);
--scrollbar-thumb-bg: rgba(255, 255, 255, 0.1);
--highlight-mix-blend-mode: lighten;
}
.CodeMirror-lines {
font-family: var(--font-monospace);
}
.graph-view.color-fill,
.graph-view.color-circle,
.graph-view.color-line,
.graph-view.color-text,
.graph-view.color-arrow {
color: var(--text-accent);
}
.graph-view.color-fill-highlight,
.graph-view.color-line-highlight {
color: var(--text-accent-hover);
}
.graph-view.color-fill-unresolved {
color: #600;
}
.workspace-tabs .workspace-leaf {
background-color: var(--background-primary);
}
.workspace-tab-header-container {
background-color: var(--background-primary);
}
.workspace-tab-header.is-active {
background-color: var(--background-primary);
color: var(--text-accent);
}
.workspace-tab-header.is-after-active .workspace-tab-header-inner,
.workspace-tab-header.is-before-active .workspace-tab-header-inner {
background-color: var(--background-primary);
}
.workspace-tab-container-before.is-before-active .workspace-tab-header-inner,
.workspace-tab-container-after.is-after-active .workspace-tab-header-inner,
.workspace-tab-header.is-before-active .workspace-tab-header-inner,
.workspace-tab-header.is-after-active .workspace-tab-header-inner {
background-color: var(--background-primary);
}
.workspace-split.mod-root > .workspace-leaf:last-of-type .workspace-leaf-content {
border-top-right-radius: 0;
}
.workspace-split.mod-root > .workspace-leaf:first-of-type .workspace-leaf-content {
border-top-left-radius: 0;
}
.workspace-split.mod-left-split .workspace-tabs .workspace-leaf {
border-top-left-radius: 0;
}
.workspace-split.mod-right-split .workspace-tabs .workspace-leaf {
border-top-right-radius: 0;
}
.suggestion-item.is-selected {
background-color: var(--background-primary-alt);
}
.markdown-preview-view.is-readable-line-width .markdown-preview-sizer {
max-width: 900px;
}
.markdown-source-view.is-readable-line-width .CodeMirror,
.markdown-source-view.mod-cm6.is-line-wrap.is-readable-line-width .cm-content,
.markdown-source-view.mod-cm6.is-line-wrap.is-readable-line-width .cm-line:not(.HyperMD-table-row),
.markdown-source-view.mod-cm6.is-readable-line-width:not(.is-rtl) .cm-contentContainer {
max-width: 900px;
}

View File

@@ -0,0 +1,18 @@
BG={{base05}}
FG={{base00}}
HDR_BG={{base04}}
HDR_FG={{base01}}
SEL_BG={{base00}}
SEL_FG={{base0D}}
TXT_BG={{base06}}
TXT_FG={{base01}}
BTN_BG={{base03}}
BTN_FG={{base07}}
HDR_BTN_BG={{base05}}
HDR_BTN_FG={{base01}}
WM_BORDER_FOCUS={{base0D}}
WM_BORDER_UNFOCUS={{base04}}
GRADIENT=0.0
ROUNDNESS=2
SPACING=3

View File

@@ -0,0 +1,18 @@
BG={{base00}}
FG={{base05}}
HDR_BG={{base01}}
HDR_FG={{base04}}
SEL_BG={{base0D}}
SEL_FG={{base00}}
TXT_BG={{base01}}
TXT_FG={{base06}}
BTN_BG={{base02}}
BTN_FG={{base07}}
HDR_BTN_BG={{base05}}
HDR_BTN_FG={{base01}}
WM_BORDER_FOCUS={{base0D}}
WM_BORDER_UNFOCUS={{base04}}
GRADIENT=0.0
ROUNDNESS=2
SPACING=3

View File

@@ -0,0 +1,95 @@
/*******************************************************************************
* ROFI SQUARED THEME USING THE NORD PALETTE
* User : LR-Tech
* Theme Repo : https://github.com/lr-tech/rofi-themes-collection
*******************************************************************************/
* {
font: "FiraCode Nerd Font Medium 12";
bg0: #{{base00}};
bg1: #{{base01}};
fg0: #{{base07}};
accent-color: #{{base0C}};
urgent-color: #{{base08}};
background-color: transparent;
text-color: @fg0;
margin: 0;
padding: 0;
spacing: 0;
}
window {
location: center;
width: 480;
background-color: @bg0;
}
inputbar {
spacing: 8px;
padding: 8px;
background-color: @bg1;
}
prompt, entry, element-icon, element-text {
vertical-align: 0.5;
}
prompt {
text-color: @accent-color;
}
textbox {
padding: 8px;
background-color: @bg1;
}
listview {
padding: 4px 0;
lines: 8;
columns: 1;
fixed-height: false;
}
element {
padding: 8px;
spacing: 8px;
}
element normal normal {
text-color: @fg0;
}
element normal urgent {
text-color: @urgent-color;
}
element normal active {
text-color: @accent-color;
}
element selected {
text-color: @bg0;
}
element selected normal, element selected active {
background-color: @accent-color;
}
element selected urgent {
background-color: @urgent-color;
}
element-icon {
size: 0.8em;
}
element-text {
text-color: inherit;
}

View File

@@ -0,0 +1,8 @@
ColorForeground=#{{base05}}
ColorBackground=#{{base00}}
ColorCursor=#{{base0C}}
ColorSelection=#{{base00}}
ColorBold=#{{base05}}
ColorBoldUseDefault=FALSE
ColorPalette=#{{base00}};#{{base08}};#{{base0B}};#{{base0A}};#{{base0D}};#{{base0E}};#{{base0C}};#{{base05}};#{{base03}};#{{base08}};#{{base0B}};#{{base0A}};#{{base0D}};#{{base0E}};#{{base0C}};#{{base07}}
TabActivityColor=#{{base0A}}

View File

@@ -1,24 +0,0 @@
base00="151515"
base01="202020"
base02="303030"
base03="505050"
base04="b0b0b0"
base05="d0d0d0"
base06="e0e0e0"
base07="f5f5f5"
base08="fa859c"
base09="ea9971"
base0A="ddb26f"
base0B="a1bb54"
base0C="10bcad"
base0D="5ab9ed"
base0E="db8fea"
base0F="deaf8f"
base10="0b0b0b"
base11="060606"
base12="fb9fb1"
base13="eda987"
base14="acc267"
base15="12cfc0"
base16="6fc2ef"
base17="e1a3ee"

View File

@@ -1,13 +1,24 @@
# Cookbook
This document is a collection of ways to use shchemes. While many of these examples are useful for creating scripts to [automatically change your whole desktop's color scheme](#change-scheme-script), many of the examples given are meant to be ran in the terminal, to grow a greater familiarity with the techniques used.
## Qutebrowser
## GTK
### Oomox
Shchemes can generate colors for [oomox-gtk-theme](https://github.com/themix-project/oomox-gtk-theme), allowing your theme to spread to most of your desktop, providing it uses the GTK toolkit. `oomox-gtk-theme` includes a script we can call with the theme Shchemes generates to install a GTK theme with your colors.
### Remotely reloading your Qutebrowser configuration
Qutebrowser can be remotely reloaded by sending it a SIGHUP signal.
```sh
pkill -HUP qutebrowser
"./change_color.sh" -o shchemes <(shchemes create_theme oomox-gtk -s=base16:horizon-terminal-dark)
```
Note on older versions (<=3.1.0) this will simply kill Qutebrowser.
This will install the theme to `~/.themes/shchemes`.
### Reload XFCE theme
If you're generating an Oomox theme, as detailed above, you may want some way of automatically setting or refreshing the GTK theme XFCE uses.
```sh
xfconf-query -c xsettings -p /Net/ThemeName -r
xfconf-query -c xsettings -p /Net/ThemeName -s shchemes
```
You may need to replace `shchemes` with the name of your theme in `~/.themes`
## ImageMagick
Shchemes can create [ImageMagick pixel enumeration files](https://imagemagick.org/Usage/files/#txt), with a vertical strip of all the colors in the scheme. This is optimal for getting the color data into an image, or simply displaying the palette.
@@ -49,3 +60,52 @@ You'll need to call it from your bspwmrc
```sh
"$(dirname $0)/colors"
```
## Reloading configs
### Remotely reloading your Qutebrowser configuration
Qutebrowser can be remotely reloaded by sending it a HUP signal.
```sh
pkill -HUP qutebrowser
```
Note on older versions (<=3.1.0) this will simply kill Qutebrowser.
### Remotely reloading your Kitty configuration
Kitty will reload it's configuration on a USR1 signal.
```sh
pkill -USR1 kitty
```
## Creating an script to automatically theme your whole desktop {#change-scheme-script}
This is the use case that shchemes was designed to fulfill.
### `SCHEME` environment variable
To avoid having to use `-s` or `--scheme` in every command of your script, shchemes will also read a `SCHEME` environment variable if those flags aren't set.
This is a useful pattern to put at the top of a script.
```bash
export SCHEME=$1
```
### Automatically installing a `tinted-theming` scheme
This snippet will automatically install your scheme from the [tinted-theming collection](https://github.com/tinted-theming/schemes) and exit if it can't be found.
```sh
if ! shchemes install_tinted_scheme ; then
exit 1
fi
```
### `.profile` injection
Sometimes you have other scripts that need to know what theme is currently applied on your system. One way to do this is to set the `SCHEME` environment variable in your `.profile`.
```sh
echo '#START SHCHEMES BLOCK : printf "SCHEME=\"%s\"\n" "$SCHEME"' > ~/.profile
```
And in your script:
```sh
shchemes inject "$HOME/.profile"
```
> [!CAUTION]
> Shchemes injection is literally one Awk script. While lots of care has been taken, we are not liable for it mangling your configuration files, and we give no guarantees. It is recommended you backup your configs, preferably in something with version control in case you don't realise something's gone wrong until later.

View File

@@ -50,7 +50,7 @@ shchemes create_theme alacritty --format=base24
## METHODS
## create_theme
## create_theme {#create_theme}
Apply the color scheme to the template for a given app
```
@@ -66,7 +66,9 @@ In the given file, looks for a comment that indicates a Shchemes injection block
shchemes inject PATH
```
## install_tinted_scheme
See also: [`create_theme`](#create_theme)
## install_tinted_scheme {#install_tinted_scheme}
Installs a color scheme from the [tinted-theming/schemes](https://github.com/tinted-theming/schemes).
You can find a gallery of the base16 themes here:
@@ -75,7 +77,40 @@ You can find a gallery of the base16 themes here:
shchemes install_tinted_scheme
```
See also: [`SCHEME`](#SCHEME) [`--scheme`](#scheme)
See also: [`SCHEME`](#SCHEME) [`--scheme`](#scheme) [`convert_tinted_scheme`](#convert_tinted_scheme)
## convert_tinted_scheme {#convert_tinted_scheme}
Converts a tinted-theming scheme to a .properties format for use in shchemes.
```
shchemes convert_tinted_scheme pico.yaml
cat pico.yaml > shchemes convert_tinted_scheme
```
See also: [`install_tinted_scheme`](#install_tinted_scheme)
## install_tinted_template {#install_tinted_template}
Downloads, converts, and installs a tinted-theming template from a given url.
```
shchemes install_tinted_template https://raw.githubusercontent.com/tinted-theming/base16-emacs/main/templates/default.mustache
```
It is recommended that you use already-maintained shchemes templates rather than just installing and converting third party ones.
See also: [`convert_tinted_template`](#convert_tinted_template)
## convert_tinted_template {#convert_tinted_template}
Converts a tinted-theming .mustache template to a shchemes template.
```
shchemes convert_tinted_template default.mustache > ~/shchemes/base16/templates/emacs.mustache
```
See also: [`install_tinted_template`](#install_tinted_template)
## manual, man, help
Opens this manual
# AUTHOR

View File

@@ -75,6 +75,8 @@ pipes the stdout into the content of the injection block.
shchemes inject PATH
\f[R]
.fi
.PP
See also: \f[V]create_theme\f[R]
.SS install_tinted_scheme
.PP
Installs a color scheme from the
@@ -90,6 +92,49 @@ shchemes install_tinted_scheme
.fi
.PP
See also: \f[V]SCHEME\f[R] \f[V]--scheme\f[R]
\f[V]convert_tinted_scheme\f[R]
.SS convert_tinted_scheme
.PP
Converts a tinted-theming scheme to a .properties format for use in
shchemes.
.IP
.nf
\f[C]
shchemes convert_tinted_scheme pico.yaml
cat pico.yaml > shchemes convert_tinted_scheme
\f[R]
.fi
.PP
See also: \f[V]install_tinted_scheme\f[R]
.SS install_tinted_template
.PP
Downloads, converts, and installs a tinted-theming template from a given
url.
.IP
.nf
\f[C]
shchemes install_tinted_template https://raw.githubusercontent.com/tinted-theming/base16-emacs/main/templates/default.mustache
\f[R]
.fi
.PP
It is recommended that you use already-maintained shchemes templates
rather than just installing and converting third party ones.
.PP
See also: \f[V]convert_tinted_template\f[R]
.SS convert_tinted_template
.PP
Converts a tinted-theming .mustache template to a shchemes template.
.IP
.nf
\f[C]
shchemes convert_tinted_template default.mustache > \[ti]/shchemes/base16/templates/emacs.mustache
\f[R]
.fi
.PP
See also: \f[V]install_tinted_template\f[R]
.SS manual, man, help
.PP
Opens this manual
.SH AUTHOR
.PP
Shchemes is written by Dakedres

View File

@@ -20,6 +20,41 @@ rgb_b() {
printf "$((0x${MO_FUNCTION_ARGS[0]:4:4}))"
}
rgb() {
rgb_r; printf " "
rgb_g; printf " "
rgb_b; printf " "
}
clamp() {
if [[ $1 -lt 0 ]]; then
printf "0"
else
if [[ $1 -gt 255 ]]; then
printf "255"
else
printf "%s" "$1"
fi
fi
}
lighten() {
mod="${MO_FUNCTION_ARGS[1]}"
parts=("$(rgb_r)" "$(rgb_g)" "$(rgb_b)")
vars=""
for part in "${parts[@]}"; do
let var=$part+$mod
vars=$vars"$(clamp "$var") "
done
printf "%02x%02x%02x" $vars
}
darken() {
MO_FUNCTION_ARGS[1]="-${MO_FUNCTION_ARGS[1]}"
lighten
}
set -a # All variables after this will be exported
source $SCHEME
mo "$TEMPLATE"

View File

@@ -130,17 +130,18 @@ inject() {
parse_scheme
check_scheme_path
parse_comment_pattern
tmp=$(mktemp)
if [ "$comment_start" == "" ]; then
comment_start="#"
fi
awk -i inplace \
-v blockstart="${comment_start}START SHCHEMES BLOCK" \
awk -v blockstart="${comment_start}START SHCHEMES BLOCK" \
-v blockend="${comment_start}END SHCHEMES BLOCK" \
-v commentend="$comment_end" \
-v scheme="$scheme" \
-v shchemes="$shchemes_path" \
-v sq="'" \
-v nl="\n" \
-F ":" '
!inblock { print }
inblock {
@@ -153,39 +154,54 @@ $1 ~ blockstart {
system("/usr/bin/env bash -c " sq "SCHEME=\"" scheme "\";" command sq);
next
}
$1 ~ blockend {
$1 == blockend && inblock {
inblock = 0;
print;
next
print nl blockend commentend;
next;
}
ENDFILE {
if(inblock) {
print blockend commentend;
for(i=1;i<=bi;i++) {
print lines[i];
}
}
ENDFILE {
if(inblock) {
print nl blockend commentend;
for(i=1;i<=bi;i++) {
print lines[i];
}
}
}
' "$path"
' "$path" > "$tmp" && mv "$tmp" "$path"
}
convert_tinted_template() {
# TODO: multiple format support, check that line actually has multiple fields
merge() {
path=$1
sed -r \
-e 's/\{\{base([0-9A-F]+)-hex\}\}/{{base\1}}/' \
-e 's/\{\{base([0-9A-F]+)-rgb-r\}\}/{{rgb_r base\1}}/' \
-e 's/\{\{base([0-9A-F]+)-rgb-g\}\}/{{rgb_g base\1}}/' \
-e 's/\{\{base([0-9A-F]+)-rgb-b\}\}/{{rgb_b base\1}}/'
tmp=$(mktemp)
awk -F "=" '
FILENAME == "-" {
a[$1] = $2
next
}
a[$1] {
print $1 "=" a[$1]
next
}
{ print }
' - "$path" > "$tmp" && mv "$tmp" "$path"
}
convert_tinted_scheme() {
path=$1
tmp=$(mktemp)
awk -i inplace -F ' *: *' '
awk -F ' *: *' '
/^#/ { print }
$1 ~ "palette" { p = 1; next }
p && /^ +/ { gsub(/ /, "", $1); print $1 "=" $2 }
' "$path"
p && /^ +/ {
gsub(/ /, "", $1);
gsub(/^"#/, "", $2);
gsub(/"$/, "", $2);
print $1 "=\"" $2 "\""
}
' "$path" > "$tmp" && mv -f "$tmp" "$path"
}
install_tinted_scheme() {
@@ -216,11 +232,23 @@ install_tinted_scheme() {
echo "Installed ${scheme}"
}
convert_tinted_template() {
path=$1
sed -r \
-e 's/\{\{base([0-9A-F]+)-hex\}\}/{{base\1}}/' \
-e 's/\{\{base([0-9A-F]+)-rgb-r\}\}/{{rgb_r base\1}}/' \
-e 's/\{\{base([0-9A-F]+)-rgb-g\}\}/{{rgb_g base\1}}/' \
-e 's/\{\{base([0-9A-F]+)-rgb-b\}\}/{{rgb_b base\1}}/' "$path"
}
install_tinted_template() {
url=$1
target=$2
tmp=$(mktemp)
curl "$url" | convert_tinted_template > "${shchemes_dir}/base16/templates/${target}.mustache"
curl "$url" > "$tmp"
convert_tinted_template "$tmp" > "${shchemes_dir}/base16/templates/${target}.mustache"
rm "$tmp"
}
manual() {
@@ -237,6 +265,10 @@ if [ "$method" != "" ]; then
inject "${args[1]}" "${args[2]}"
;;
merge)
merge "${args[1]}" "${args[2]}"
;;
convert_tinted_template)
convert_tinted_template "${args[1]}"
;;