blob: 2fce3244920d2a4c861158612b61c126556cf41d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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"
|