mirror of
https://gitlab.com/linuxstuff/dotfiles.git
synced 2026-08-19 22:59:27 +02:00
added xrdb fetcher
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
|
||||
###########
|
||||
# Update alacritty config to apply Xresources color scheme
|
||||
#
|
||||
|
||||
# Target file
|
||||
SKELETON_FILE="$HOME/.config/alacritty/alacritty.skeleton.yml"
|
||||
TARGET_FILE="$HOME/.config/alacritty/alacritty.yml"
|
||||
|
||||
# copy input file to temporary file for black magic fuckery
|
||||
# (alacritty applies colors when the config file is written, so we want to do it
|
||||
# all in one write)
|
||||
cp "$SKELETON_FILE" "$TARGET_FILE.tmp"
|
||||
|
||||
# Grab colors from Xresources
|
||||
xrdb ~/.Xresources
|
||||
|
||||
# Named colors
|
||||
foreground=$(xrdb -query | awk '/*.foreground/ { print substr($2,2) }')
|
||||
background=$(xrdb -query | awk '/*.background/ { print substr($2,2) }')
|
||||
sed -i "s/%foreground%/\x270x${foreground}\x27/g" "$TARGET_FILE.tmp"
|
||||
sed -i "s/%background%/\x270x${background}\x27/g" "$TARGET_FILE.tmp"
|
||||
|
||||
# Numbered colors
|
||||
for i in {0..15}
|
||||
do
|
||||
v=$(xrdb -query | awk '/*.color'"$i":'/ { print substr($2,2) }')
|
||||
eval "sed -i 's/%color${i}%/\x270x${v}\x27/g' $TARGET_FILE.tmp";
|
||||
done
|
||||
|
||||
|
||||
# Finally, replace target file with our updated one
|
||||
rm -f "$TARGET_FILE"
|
||||
mv "$TARGET_FILE.tmp" "$TARGET_FILE"
|
||||
Reference in New Issue
Block a user