Skip to content

Commit

Permalink
feat: adding helper script for toggling color scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
sminez committed Sep 15, 2024
1 parent b560b67 commit 1d30d9a
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 4 deletions.
37 changes: 37 additions & 0 deletions data/bin/cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash
# Set the colorscheme to either a light or dark theme
set -eou pipefail

function setColor() {
echo "set $1=#$2" | 9p write ad/ctl
}

[ -e "$HOME/.profile" ] && source ~/.profile

if [ "$1" = "light" ]; then
setColor bg-color ebdbb2
setColor fg-color 282828
setColor dot-bg-color d5c4a1
setColor bar-bg-color 83a598
setColor signcol-fg-color 458488
setColor minibuffer-hl-color 458488
setColor comment-color 624354
setColor keyword-color Bf616A
setColor control-flow-color 7E9CD8
setColor definition-color 957FB8
setColor punctuation-color DCA561
setColor string-color 61DCA5
else
setColor bg-color 1B1720
setColor fg-color E6D29E
setColor dot-bg-color 336677
setColor bar-bg-color 4E415C
setColor signcol-fg-color 544863
setColor minibuffer-hl-color 3E3549
setColor comment-color 624354
setColor keyword-color Bf616A
setColor control-flow-color 7E9CD8
setColor definition-color 957FB8
setColor punctuation-color DCA561
setColor string-color 61DCA5
fi
21 changes: 21 additions & 0 deletions data/init-rust.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,33 @@ set status-timeout=3
set minibuffer-lines=15
set find-command=fd -t f

# light color scheme
# set bg-color=#ebdbb2
# set fg-color=#282828
# set dot-bg-color=#d5c4a1
# set bar-bg-color=#83a598
# set signcol-fg-color=#458488
# set minibuffer-hl-color=#458488
# set comment-color=#624354
# set keyword-color=#Bf616A
# set control-flow-color=#7E9CD8
# set definition-color=#957FB8
# set punctuation-color=#DCA561
# set string-color=#61DCA5

# dark color scheme
set bg-color=#1B1720
set fg-color=#E6D29E
set dot-bg-color=#336677
set bar-bg-color=#4E415C
set signcol-fg-color=#544863
set minibuffer-hl-color=#3E3549
set comment-color=#624354
set keyword-color=#Bf616A
set control-flow-color=#7E9CD8
set definition-color=#957FB8
set punctuation-color=#DCA561
set string-color=#61DCA5

# Key mappings to programs that must be available on $PATH.
# ~/.ad/bin is auto-added to the path
Expand Down
21 changes: 21 additions & 0 deletions data/init.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,33 @@ set status-timeout=3
set minibuffer-lines=15
set find-command=fd -t f

# light color scheme
# set bg-color=#ebdbb2
# set fg-color=#282828
# set dot-bg-color=#d5c4a1
# set bar-bg-color=#83a598
# set signcol-fg-color=#458488
# set minibuffer-hl-color=#458488
# set comment-color=#624354
# set keyword-color=#Bf616A
# set control-flow-color=#7E9CD8
# set definition-color=#957FB8
# set punctuation-color=#DCA561
# set string-color=#61DCA5

# dark color scheme
set bg-color=#1B1720
set fg-color=#E6D29E
set dot-bg-color=#336677
set bar-bg-color=#4E415C
set signcol-fg-color=#544863
set minibuffer-hl-color=#3E3549
set comment-color=#624354
set keyword-color=#Bf616A
set control-flow-color=#7E9CD8
set definition-color=#957FB8
set punctuation-color=#DCA561
set string-color=#61DCA5

# Key mappings to programs that must be available on $PATH.
# ~/.ad/bin is auto-added to the path
Expand Down
10 changes: 6 additions & 4 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ impl Default for ColorScheme {
control_flow: "#7E9CD8".try_into().unwrap(),
definition: "#957FB8".try_into().unwrap(),
punctuation: "#DCA561".try_into().unwrap(),
// string: "#A6CC70".try_into().unwrap(),
// string: "#87C87C".try_into().unwrap(),
// string: "#C9D87A".try_into().unwrap(),
// string: "#9CD87E".try_into().unwrap(),
string: "#61DCA5".try_into().unwrap(),
}
}
Expand Down Expand Up @@ -162,6 +158,12 @@ impl Config {
"bar-bg-color" => self.colorscheme.bar_bg = parse_color(prop, val)?,
"signcol-fg-color" => self.colorscheme.signcol_fg = parse_color(prop, val)?,
"minibuffer-hl-color" => self.colorscheme.minibuffer_hl = parse_color(prop, val)?,
"comment-color" => self.colorscheme.comment = parse_color(prop, val)?,
"keyword-color" => self.colorscheme.keyword = parse_color(prop, val)?,
"control-flow-color" => self.colorscheme.control_flow = parse_color(prop, val)?,
"definition-color" => self.colorscheme.definition = parse_color(prop, val)?,
"punctuation-color" => self.colorscheme.punctuation = parse_color(prop, val)?,
"string-color" => self.colorscheme.string = parse_color(prop, val)?,

_ => return Err(format!("'{prop}' is not a known config property")),
}
Expand Down
3 changes: 3 additions & 0 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ pub(crate) fn run_command<I, S>(
let mut content = String::from_utf8(output.stdout).unwrap_or_default();
let stderr = String::from_utf8(output.stderr).unwrap_or_default();
content.push_str(&stderr);
if content.is_empty() {
return;
}
_ = tx.send(InputEvent::Action(Action::AppendToOutputBuffer {
bufid,
content,
Expand Down

0 comments on commit 1d30d9a

Please sign in to comment.