yage
76a746a53e
===================================================================== Notice the major version change which comes with breaking changes to 2.x! Reconstructs "library" functions for both python and zsh scwrypts, with changes to virtualenv naming conventions (you'll need to refresh all virtualenv with the appropriate scwrypt). --- Changes ------------------------------ - changed a naming convention across zsh scripts, particularly removing underscores where there is no need to avoid naming clash (e.g. 'zsh/lib/utils/io.zsh' renames '__STATUS' to 'STATUS') - moved clients reliant on py.lib.http to the py.lib.http module - python scripts now rely on py.lib.scwrypts.execute - updated package.json in zx scripts to include `type = module` - 'scwrypts --list' commandline argument now includes additional relevant data for each scwrypt - environment variables no longer add themselves to be staged in the '.env.template' --- New Features ------------------------- - new 'use' syntax for disjoint import within zsh scripts; took me a very long time to convince myself this would be necessary - introduced scwrypt "groups" to allow portable module creation; (i.e. ability add your own scripts from another repo!) - py.lib.scwrypts.io provides a combined IO stream for quick, hybrid use of input/output files and stdin/stdout - py.lib.fzf provides a wrapper to provide similar functionality to zsh/utils/io.zsh including fzf_(head|tail) - improved efficiency of various scwrypts; notably reducing runtime of scwrypts/environment sync - improved scwrypts CLI by adding new options for exact scwrypt matching, better filtering, and prettier/more-detailed interfaces --- New Scripts -------------------------- - py/twilio ) basic SMS integration with twilio - send-sms - py/directus ) interactive directus GET query - get-items - py/discord ) post message to discord channel or webhook - post-message
103 lines
3.1 KiB
Bash
Executable File
103 lines
3.1 KiB
Bash
Executable File
#!/bin/zsh
|
|
DEPENDENCIES+=(
|
|
diff
|
|
)
|
|
REQUIRED_ENV+=(
|
|
I3__MODEL_CONFIG
|
|
)
|
|
|
|
CHECK_ENVIRONMENT
|
|
#####################################################################
|
|
|
|
REGEX_FONT='^\(font [^0-9]*\)\(.*\)'
|
|
REGEX_DMENU="^\\(.*dmenu_run .*-fn '[^0-9]*\\)\\([0-9]*\\)'"
|
|
REGEX_BORDER='^\(for_window.*border pixel \)\(.*\)'
|
|
|
|
INSTALL() {
|
|
local USAGE="
|
|
usage: [...options...]
|
|
|
|
options
|
|
-f, --force force replacement of existing i3config
|
|
-n, --no-link if output config and template are the same, don't create link
|
|
|
|
-h, --help print this message and exit
|
|
|
|
environment
|
|
I3__MODEL_CONFIG fully-qualified path to sourced i3config
|
|
I3__GLOBAL_FONT_SIZE global font size
|
|
I3__DMENU_FONT_SIZE (optional) font size for 'dmenu' command
|
|
I3__BORDER_PIXEL_SIZE (optional) pixel-width of window borders
|
|
|
|
I3 provides no way to include dynamic variables in your config.
|
|
The main difference I want between my i3 configurations is font-size
|
|
to match the current monitor. Since i3-msg provides no way to change
|
|
font size, I run this command to update those variables on a local
|
|
copy of my sourced config
|
|
"
|
|
local FORCE=0
|
|
local AUTOLINK=1
|
|
while [[ $# -gt 0 ]]
|
|
do
|
|
case $1 in
|
|
-f | --force ) FORCE=1 ;;
|
|
-n | --no-link ) AUTOLINK=0 ;;
|
|
-h | --help ) USAGE; exit 0 ;;
|
|
esac
|
|
shift 1
|
|
done
|
|
|
|
STATUS 'reading local i3config'
|
|
[[ ^$I3__MODEL_CONFIG$ =~ ^$HOME/.config/i3/config$ ]] && {
|
|
STATUS "model configuration is default configuration"
|
|
I3__MODEL_CONFIG="$I3__MODEL_CONFIG.template"
|
|
[ ! -f "$I3__MODEL_CONFIG" ] && {
|
|
STATUS "creating template"
|
|
cp "$HOME/.config/i3/config" "$I3__MODEL_CONFIG.template"
|
|
}
|
|
STATUS "referring to '$I3__MODEL_CONFIG'"
|
|
}
|
|
local CONFIG=$(cat "$I3__MODEL_CONFIG")
|
|
[ ! $CONFIG ] && FAIL 1 "failed to read config at '$I3__MODEL_CONFIG'"
|
|
|
|
local CONFIG_FILE="$HOME/.config/i3/config"
|
|
[ ! -d $(dirname "$CONFIG_FILE") ] && mkdir -p "$(dirname "$CONFIG_FILE")"
|
|
|
|
[ -f "$CONFIG_FILE" ] && mv "$CONFIG_FILE" "$CONFIG_FILE.bak"
|
|
|
|
[ $I3__GLOBAL_FONT_SIZE ] && {
|
|
STATUS "setting global font size to '$I3__GLOBAL_FONT_SIZE'"
|
|
CONFIG=$(echo $CONFIG | sed "s/$REGEX_FONT/\\1$I3__GLOBAL_FONT_SIZE/")
|
|
}
|
|
|
|
[ $I3__DMENU_FONT_SIZE ] && {
|
|
STATUS "setting dmenu font size to '$I3__DMENU_FONT_SIZE'"
|
|
CONFIG=$(echo $CONFIG | sed "s/$REGEX_DMENU/\\1$I3__DMENU_FONT_SIZE'/")
|
|
}
|
|
|
|
[ $I3__BORDER_PIXEL_SIZE ] && {
|
|
STATUS "setting border pixel size to '$I3__BORDER_PIXEL_SIZE'"
|
|
CONFIG=$(echo $CONFIG | sed "s/$REGEX_BORDER/\\1$I3__BORDER_PIXEL_SIZE/")
|
|
}
|
|
|
|
echo $CONFIG > "$CONFIG_FILE"
|
|
[ -f "$CONFIG_FILE.bak" ] \
|
|
&& diff "$CONFIG_FILE" "$CONFIG_FILE.bak" -q >/dev/null \
|
|
&& mv "$CONFIG_FILE.bak" "$CONFIG_FILE" \
|
|
&& INFO "no changes were made" \
|
|
;
|
|
|
|
[[ $AUTOLINK -eq 1 ]] \
|
|
&& diff "$CONFIG_FILE" "$I3__MODEL_CONFIG" -q >/dev/null \
|
|
&& rm "$CONFIG_FILE" \
|
|
&& ln -s "$I3__MODEL_CONFIG" "$CONFIG_FILE" \
|
|
&& INFO "output is the same as model, i3config has been linked to model" \
|
|
;
|
|
|
|
[[ $FORCE -eq 1 ]] && rm "$CONFIG.bak" >/dev/null 2>&1
|
|
return 0
|
|
}
|
|
|
|
#####################################################################
|
|
INSTALL $@
|