summaryrefslogtreecommitdiff
path: root/bin/terminal-set-opacity
diff options
context:
space:
mode:
Diffstat (limited to 'bin/terminal-set-opacity')
-rwxr-xr-xbin/terminal-set-opacity32
1 files changed, 32 insertions, 0 deletions
diff --git a/bin/terminal-set-opacity b/bin/terminal-set-opacity
new file mode 100755
index 0000000..2fce324
--- /dev/null
+++ b/bin/terminal-set-opacity
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+set -euo pipefail
+
+increment="$1"
+
+_sed_i() {
+ if [[ "$(uname)" == "Darwin" ]]; then
+ sed -i '' "$@"
+ else
+ sed -i'' "$@"
+ fi
+}
+
+# Update Alacritty
+alacritty_config="$HOME/.config/alacritty/alacritty.toml"
+current="$(grep opacity "$alacritty_config" | awk '{ print $3 }' || echo 1)"
+changed="$(perl -MList::Util=min,max -e "print max(0, min(1, $current + $increment))")"
+_sed_i 's/^opacity = .*$/opacity = '"$changed"'/' "$alacritty_config"
+
+# Update Ghostty
+ghostty_config="$HOME/.config/ghostty/config"
+if [[ -f "$ghostty_config" ]]; then
+ _sed_i 's/^background-opacity = .*$/background-opacity = '"$changed"'/' "$ghostty_config"
+
+ # Trigger Ghostty reload
+ script_dir="$(cd "$(dirname "$0")" && pwd)"
+ "$script_dir/ghostty-reload"
+fi
+
+echo "$changed"
+