This repository has been archived on 2024-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/os-specific/arch-linux/scripts/get-fonts.bash

23 lines
1.1 KiB
Bash
Raw Normal View History

#!/usr/bin/env sh
XRES_FILE="$HOME/.Xresources"
if [ -a "$HOME/.Xresources.env" ]; then
XRES_FILE="$HOME/.Xresources.env"
fi
PRIMARY_FONT_XRESOURCES=$(grep "^\*font: xft:" "$XRES_FILE" | grep -v "/\*" | head -n 1)
export PRIMARY_FONT_FAMILY_WITH_SIZE=${PRIMARY_FONT_XRESOURCES:11}
export PRIMARY_FONT_FAMILY=$(echo $PRIMARY_FONT_FAMILY_WITH_SIZE | sed 's/\-.*//')
export PRIMARY_FONT_SIZE=$(echo $PRIMARY_FONT_FAMILY_WITH_SIZE | sed 's/.*\-//')
SECONDARY_FONT_XRESOURCES=$(grep "^#define secondaryfont xft:" "$XRES_FILE" | grep -v "/\*" | head -n 1)
export SECONDARY_FONT_FAMILY_WITH_SIZE=${SECONDARY_FONT_XRESOURCES:26}
export SECONDARY_FONT_FAMILY=$(echo $SECONDARY_FONT_FAMILY_WITH_SIZE | sed 's/\-.*//')
export SECONDARY_FONT_SIZE=$(echo $SECONDARY_FONT_FAMILY_WITH_SIZE | sed 's/.*\-//')
ICON_FONT_XRESOURCES=$(grep "^#define iconfont xft:" "$XRES_FILE" | grep -v "/\*" | head -n 1)
export ICON_FONT_FAMILY_WITH_SIZE=${ICON_FONT_XRESOURCES:21}
export ICON_FONT_FAMILY=$(echo $ICON_FONT_FAMILY_WITH_SIZE | sed 's/\-.*//')
export ICON_FONT_SIZE=$(echo $ICON_FONT_FAMILY_WITH_SIZE | sed 's/.*\-//')