#!/bin/zsh source "$HOME/.config/wryn/env.zsh" source $ZSH_COLOR_UTIL ##################################################################### GLOBAL_FONT_SIZE="$1" DMENU_FONT_SIZE="$2" BORDER_PIXEL_SIZE="$3" [ ! $GLOBAL_FONT_SIZE ] && GLOBAL_FONT_SIZE=$I3__GLOBAL_FONT_SIZE [ ! $DMENU_FONT_SIZE ] && DMENU_FONT_SIZE=$I3__DMENU_FONT_SIZE [ ! $BORDER_PIXEL_SIZE ] && BORDER_PIXEL_SIZE=$I3__BORDER_PIXEL_SIZE LOCAL_CONFIG="$HOME/.config/i3/config" MODEL_CONFIG="$DOTWRYN/config/i3.conf" REGEX_FONT='^\(font [^0-9]*\)\(.*\)' REGEX_DMENU="^\\(.*dmenu_run .*-fn '[^0-9]*\\)\\([0-9]*\\)'" REGEX_BORDER='^\(for_window.*border pixel \)\(.*\)' DEFAULT_GLOBAL_FONT_SIZE=$(sed -n "s/$REGEX_FONT/\\2/p" $MODEL_CONFIG) DEFAULT_DMENU_FONT_SIZE=$(sed -n "s/$REGEX_DMENU/\\2/p" $MODEL_CONFIG) DEFAULT_BORDER_PIXEL_SIZE=$(sed -n "s/$REGEX_BORDER/\\2/p" $MODEL_CONFIG) ##################################################################### RESET_CONFIG_TO_DEFAULT() { STATUS 'relinking default config' ln -s $MODEL_CONFIG $LOCAL_CONFIG } UPDATE_CONFIG() { [ ! $GLOBAL_FONT_SIZE ] && GLOBAL_FONT_SIZE=$DEFAULT_GLOBAL_FONT_SIZE [ ! $DMENU_FONT_SIZE ] && DMENU_FONT_SIZE=$DEFAULT_DMENU_FONT_SIZE [ ! $BORDER_PIXEL_SIZE ] && BORDER_PIXEL_SIZE=$DEFAULT_BORDER_PIXEL_SIZE STATUS 'updating config with the following settings:' MENU "GLOBAL_FONT_SIZE : $GLOBAL_FONT_SIZE" MENU "DMENU_FONT_SIZE : $DMENU_FONT_SIZE" MENU "BORDER_PIXEL_SIZE : $BORDER_PIXEL_SIZE" sed "\ s/$REGEX_FONT/\\1$GLOBAL_FONT_SIZE/;\ s/$REGEX_DMENU/\\1$DMENU_FONT_SIZE'/;\ s/$REGEX_BORDER/\\1$BORDER_PIXEL_SIZE/;\ " $MODEL_CONFIG > $LOCAL_CONFIG } ##################################################################### [ -f $LOCAL_CONFIG ] && rm $LOCAL_CONFIG [ ! $GLOBAL_FONT_SIZE ] && [ ! $DMENU_FONT_SIZE ] && [ ! $BORDER_PIXEL_SIZE ] \ && RESET_CONFIG_TO_DEFAULT 2>/dev/null \ || UPDATE_CONFIG 2>/dev/null \ ; return 0