dotwryn scwrypts v5 refactor
This commit is contained in:
parent
1b70e44700
commit
f11c6dfad6
44
scwrypts/dotwryn/desktop/colorscheme/alacritty.module.zsh
Normal file
44
scwrypts/dotwryn/desktop/colorscheme/alacritty.module.zsh
Normal file
@ -0,0 +1,44 @@
|
||||
_COLORSCHEME_FILE__alacritty="${DOTWRYN}/config/user/alacritty/theme.toml"
|
||||
|
||||
_GENERATE_THEME__alacritty() {
|
||||
echo "# do not edit; generated by scwrypts
|
||||
# theme : ${THEME_NAME}
|
||||
[colors.cursor]
|
||||
cursor = '0x$(_GET_HEX .alacritty.cursor cursor)'
|
||||
|
||||
[colors.primary]
|
||||
background = '0x$(_GET_HEX .alacritty.background .background)'
|
||||
foreground = '0x$(_GET_HEX .alacritty.foreground .foreground)'
|
||||
|
||||
[colors.normal]
|
||||
black = '0x$(_GET_HEX .ansi.gray.black)'
|
||||
red = '0x$(_GET_HEX .ansi.red.regular)'
|
||||
green = '0x$(_GET_HEX .ansi.green.regular)'
|
||||
yellow = '0x$(_GET_HEX .ansi.yellow.regular)'
|
||||
blue = '0x$(_GET_HEX .ansi.blue.regular)'
|
||||
magenta = '0x$(_GET_HEX .ansi.magenta.regular)'
|
||||
cyan = '0x$(_GET_HEX .ansi.cyan.regular)'
|
||||
white = '0x$(_GET_HEX .ansi.gray.white)'
|
||||
|
||||
[colors.bright]
|
||||
black = '0x$(_GET_HEX .ansi.gray.regular)'
|
||||
red = '0x$(_GET_HEX .ansi.red.bright)'
|
||||
green = '0x$(_GET_HEX .ansi.green.bright)'
|
||||
yellow = '0x$(_GET_HEX .ansi.yellow.bright)'
|
||||
blue = '0x$(_GET_HEX .ansi.blue.bright)'
|
||||
magenta = '0x$(_GET_HEX .ansi.magenta.bright)'
|
||||
cyan = '0x$(_GET_HEX .ansi.cyan.bright)'
|
||||
white = '0x$(_GET_HEX .ansi.gray.bright)'
|
||||
" | sed '$d' > "${_COLORSCHEME_FILE__alacritty}"
|
||||
|
||||
local TRANSPARENCY_OVERRIDE=$(cat "${SOURCE_THEME}" | utils.yq -r '.alacritty.transparency' | grep -v '^null$')
|
||||
[ ${TRANSPARENCY_OVERRIDE} ] && {
|
||||
printf "[window]\nopacity = ${TRANSPARENCY_OVERRIDE}\n" >> "${_COLORSCHEME_FILE__alacritty}"
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
_SET_THEME__alacritty() {
|
||||
return 0 # theme is referenced explicitly after generation
|
||||
}
|
@ -1,30 +1,30 @@
|
||||
#####################################################################
|
||||
|
||||
_COLORSCHEME_DIR="$DOTWRYN/colorschemes"
|
||||
_COLORSCHEME_DIR="${DOTWRYN}/config/colorschemes"
|
||||
|
||||
ACTIVE_THEME_PATH="$_COLORSCHEME_DIR/active"
|
||||
ACTIVE_THEME_SOURCE="$ACTIVE_THEME_PATH/source.yaml"
|
||||
ACTIVE_THEME_PATH="${_COLORSCHEME_DIR}/active"
|
||||
ACTIVE_THEME_SOURCE="${ACTIVE_THEME_PATH}/source.yaml"
|
||||
|
||||
use desktop/colorscheme/alacritty --group dotwryn
|
||||
use desktop/colorscheme/flameshot --group dotwryn
|
||||
use desktop/colorscheme/getty --group dotwryn
|
||||
use desktop/colorscheme/kitty --group dotwryn
|
||||
use desktop/colorscheme/polybar --group dotwryn
|
||||
use desktop/colorscheme/rofi --group dotwryn
|
||||
use --group dotwryn desktop/colorscheme/alacritty
|
||||
use --group dotwryn desktop/colorscheme/flameshot
|
||||
use --group dotwryn desktop/colorscheme/getty
|
||||
use --group dotwryn desktop/colorscheme/kitty
|
||||
use --group dotwryn desktop/colorscheme/polybar
|
||||
use --group dotwryn desktop/colorscheme/rofi
|
||||
|
||||
COLORSCHEME__SUPPORTED_CONFIG_TYPES=($(typeset -f + | sed -n 's/^_GENERATE_THEME__//p'))
|
||||
|
||||
DEFAULT_MATERIAL_REFERENCES="$ACTIVE_THEME_PATH/default.yaml"
|
||||
DEFAULT_MATERIAL_REFERENCES="${ACTIVE_THEME_PATH}/default.yaml"
|
||||
|
||||
DEPENDENCIES+=(sed yq)
|
||||
|
||||
__CHECK_ENV_VAR DESKTOP__WALLPAPER_PATH --optional
|
||||
utils.environment.check DESKTOP__WALLPAPER_PATH --optional
|
||||
|
||||
#####################################################################
|
||||
|
||||
MAX_LOOKUP_RECURSION=10
|
||||
GET_COLORSCHEME_HEX() {
|
||||
[ ! $USAGE ] && USAGE="
|
||||
${scwryptsmodule}.get-hex() {
|
||||
[ ! ${USAGE} ] && USAGE="
|
||||
usage: ...args... [...options...]
|
||||
|
||||
options:
|
||||
@ -45,7 +45,7 @@ GET_COLORSCHEME_HEX() {
|
||||
"
|
||||
|
||||
local THEME_NAME='current active theme'
|
||||
local THEME_SOURCE="$ACTIVE_THEME_SOURCE"
|
||||
local THEME_SOURCE="${ACTIVE_THEME_SOURCE}"
|
||||
local ARGS=()
|
||||
local LOOKUPS=()
|
||||
while [[ $# -gt 0 ]]
|
||||
@ -53,9 +53,9 @@ GET_COLORSCHEME_HEX() {
|
||||
case $1 in
|
||||
-t | --theme )
|
||||
THEME_NAME=$2; shift 1
|
||||
THEME_SOURCE="$_COLORSCHEME_DIR/$THEME_NAME.yaml"
|
||||
[ -f "$THEME_SOURCE" ] \
|
||||
|| ERROR "no such theme '$THEME_NAME' exists"
|
||||
THEME_SOURCE="${_COLORSCHEME_DIR}/${THEME_NAME}.yaml"
|
||||
[ -f "${THEME_SOURCE}" ] \
|
||||
|| echo.error "no such theme '${THEME_NAME}' exists"
|
||||
;;
|
||||
|
||||
-l | --list-themes ) _LIST_THEMES; return 0 ;;
|
||||
@ -74,9 +74,9 @@ GET_COLORSCHEME_HEX() {
|
||||
done
|
||||
|
||||
[[ ${#LOOKUPS[@]} -gt 0 ]] \
|
||||
|| ERROR 'must provide at least one color lookup'
|
||||
|| echo.error 'must provide at least one color lookup'
|
||||
|
||||
CHECK_ERRORS --no-fail || return 1
|
||||
utils.check-errors || return 1
|
||||
|
||||
##########################################
|
||||
|
||||
@ -84,38 +84,37 @@ GET_COLORSCHEME_HEX() {
|
||||
local I INIT
|
||||
for LOOKUP in ${LOOKUPS[@]}
|
||||
do
|
||||
I=0 INIT=$LOOKUP
|
||||
I=0 INIT=${LOOKUP}
|
||||
while true
|
||||
do
|
||||
((I+=1))
|
||||
VALUE=$(YQ eval-all '. as $item ireduce ({}; . * $item)' "$DEFAULT_MATERIAL_REFERENCES" "$THEME_SOURCE" | YQ -r $LOOKUP)
|
||||
DEBUG "looking up $LOOKUP : $VALUE"
|
||||
case $VALUE in
|
||||
.* ) LOOKUP=$VALUE ;;
|
||||
VALUE=$(utils.yq eval-all '. as $item ireduce ({}; . * $item)' "${DEFAULT_MATERIAL_REFERENCES}" "${THEME_SOURCE}" | utils.yq -r ${LOOKUP})
|
||||
case ${VALUE} in
|
||||
.* ) LOOKUP=${VALUE} ;;
|
||||
* ) break ;;
|
||||
esac
|
||||
[[ $I -ge $MAX_LOOKUP_RECURSION ]] && {
|
||||
[[ ${I} -ge ${MAX_LOOKUP_RECURSION} ]] && {
|
||||
VALUE=null
|
||||
WARNING "max recursive depth reached for '$INIT'"
|
||||
WARNING "max recursive depth reached for '${INIT}'"
|
||||
break
|
||||
}
|
||||
done
|
||||
|
||||
[[ $VALUE =~ null ]] && continue
|
||||
[[ $VALUE =~ ^$ ]] && continue
|
||||
[[ ${VALUE} =~ null ]] && continue
|
||||
[[ ${VALUE} =~ ^$ ]] && continue
|
||||
break
|
||||
done
|
||||
|
||||
[[ $VALUE =~ null ]] && {
|
||||
ERROR "color lookup error for '$LOOKUPS'"
|
||||
[[ ${VALUE} =~ null ]] && {
|
||||
echo.error "color lookup error for '${LOOKUPS}'"
|
||||
return 1
|
||||
}
|
||||
|
||||
echo $VALUE | sed 's/^#//'
|
||||
echo ${VALUE} | sed 's/^#//'
|
||||
}
|
||||
|
||||
SET_THEME() {
|
||||
[ ! $USAGE ] && USAGE="
|
||||
[ ! ${USAGE} ] && USAGE="
|
||||
usage: [...options...]
|
||||
|
||||
options:
|
||||
@ -123,7 +122,7 @@ SET_THEME() {
|
||||
-l, --list-themes show available color themes and exit
|
||||
|
||||
--only only set the theme for a specific terminal/application
|
||||
($COLORSCHEME__SUPPORTED_CONFIG_TYPES)
|
||||
(${COLORSCHEME__SUPPORTED_CONFIG_TYPES})
|
||||
|
||||
-h, --help show this dialogue and exit
|
||||
|
||||
@ -148,50 +147,50 @@ SET_THEME() {
|
||||
--only )
|
||||
UPDATE_ACTIVE_THEME=false
|
||||
CONFIG_TYPE=$2; shift 1
|
||||
command -v _SET_THEME__$CONFIG_TYPE >/dev/null 2>&1 \
|
||||
|| ERROR "configuration for '$CONFIG_TYPE' not supported"
|
||||
command -v _SET_THEME__${CONFIG_TYPE} >/dev/null 2>&1 \
|
||||
|| echo.error "configuration for '${CONFIG_TYPE}' not supported"
|
||||
;;
|
||||
|
||||
-h | --help ) USAGE; return 0 ;;
|
||||
|
||||
* ) [ ! $THEME_NAME ] \
|
||||
* ) [ ! ${THEME_NAME} ] \
|
||||
&& THEME_NAME=$1 \
|
||||
|| ERROR "unknown argument '$1'" \
|
||||
|| echo.error "unknown argument '$1'" \
|
||||
;
|
||||
esac
|
||||
shift 1
|
||||
done
|
||||
|
||||
CHECK_ERRORS --no-fail || return 1
|
||||
utils.check-errors --no-fail || return 1
|
||||
|
||||
##########################################
|
||||
|
||||
[ $THEME_NAME ] || THEME_NAME=$(_LIST_THEMES | FZF 'select a theme')
|
||||
[ $THEME_NAME ] || ABORT
|
||||
[ ${THEME_NAME} ] || THEME_NAME=$(_LIST_THEMES | utils.fzf 'select a theme')
|
||||
[ ${THEME_NAME} ] || ABORT
|
||||
|
||||
local SOURCE_THEME="$_COLORSCHEME_DIR/$THEME_NAME.yaml"
|
||||
[ -f "$SOURCE_THEME" ] \
|
||||
|| ERROR "no such theme '$THEME_NAME'" \
|
||||
local SOURCE_THEME="${_COLORSCHEME_DIR}/${THEME_NAME}.yaml"
|
||||
[ -f "${SOURCE_THEME}" ] \
|
||||
|| echo.error "no such theme '${THEME_NAME}'" \
|
||||
|| return 1
|
||||
|
||||
##########################################
|
||||
|
||||
[[ $UPDATE_ACTIVE_THEME =~ true ]] && {
|
||||
mkdir -p "$ACTIVE_THEME_PATH" &>/dev/null
|
||||
STATUS "updating active theme" \
|
||||
&& ln -sf "$SOURCE_THEME" "$ACTIVE_THEME_SOURCE" \
|
||||
&& SUCCESS "active theme set to '$THEME_NAME'" \
|
||||
|| ERROR "unable to set active theme to '$THEME_NAME'" \
|
||||
[[ ${UPDATE_ACTIVE_THEME} =~ true ]] && {
|
||||
mkdir -p "${ACTIVE_THEME_PATH}" &>/dev/null
|
||||
echo.status "updating active theme" \
|
||||
&& ( cd -- "${ACTIVE_THEME_PATH}"; ln -sf -- "../$(basename -- "${SOURCE_THEME}")" "./$(basename -- "${ACTIVE_THEME_SOURCE}")"; ) \
|
||||
&& echo.success "active theme set to '${THEME_NAME}'" \
|
||||
|| echo.error "unable to set active theme to '${THEME_NAME}'" \
|
||||
|| return 2
|
||||
}
|
||||
|
||||
local CONFIG_TYPES=()
|
||||
[ $CONFIG_TYPE ] \
|
||||
&& CONFIG_TYPES=($CONFIG_TYPE) \
|
||||
|| CONFIG_TYPES=($COLORSCHEME__SUPPORTED_CONFIG_TYPES) \
|
||||
[ ${CONFIG_TYPE} ] \
|
||||
&& CONFIG_TYPES=(${CONFIG_TYPE}) \
|
||||
|| CONFIG_TYPES=(${COLORSCHEME__SUPPORTED_CONFIG_TYPES}) \
|
||||
;
|
||||
|
||||
_GET_HEX() { GET_COLORSCHEME_HEX --theme $THEME_NAME $@; }
|
||||
_GET_HEX() { dotwryn.desktop.colorscheme.get-hex --theme ${THEME_NAME} $@; }
|
||||
# allow simple ANSI-color reference
|
||||
local BLACK=$(_GET_HEX .ansi.gray.black )
|
||||
local BRIGHT_BLACK=$(_GET_HEX .ansi.gray.regular )
|
||||
@ -215,32 +214,32 @@ SET_THEME() {
|
||||
|
||||
for CONFIG_TYPE in ${CONFIG_TYPES[@]}
|
||||
do
|
||||
STATUS "updating $CONFIG_TYPE theme" \
|
||||
&& _GENERATE_THEME__$CONFIG_TYPE \
|
||||
&& _SET_THEME__$CONFIG_TYPE \
|
||||
&& SUCCESS "emulator $CONFIG_TYPE successfully updated to $THEME_NAME" \
|
||||
|| ERROR "error setting theme $THEME_NAME for $CONFIG_TYPE"
|
||||
echo.status "updating ${CONFIG_TYPE} theme" \
|
||||
&& _GENERATE_THEME__${CONFIG_TYPE} \
|
||||
&& _SET_THEME__${CONFIG_TYPE} \
|
||||
&& echo.success "emulator ${CONFIG_TYPE} successfully updated to ${THEME_NAME}" \
|
||||
|| echo.error "error setting theme ${THEME_NAME} for ${CONFIG_TYPE}"
|
||||
|
||||
[[ $CONFIG_TYPE =~ ^getty$ ]] && [[ $TERM =~ ^linux$ ]] && {
|
||||
STATUS 'loading getty theme now' \
|
||||
&& NO_CLEAR=1 source "$ACTIVE_THEME_PATH/getty.sh" \
|
||||
&& SUCCESS 'getty theme loaded' \
|
||||
|| ERROR 'getty theme loading error (see above)'
|
||||
[[ ${CONFIG_TYPE} =~ ^getty$ ]] && [[ ${TERM} =~ ^linux$ ]] && {
|
||||
echo.status 'loading getty theme now' \
|
||||
&& NO_CLEAR=1 source "${ACTIVE_THEME_PATH}/getty.sh" \
|
||||
&& echo.success 'getty theme loaded' \
|
||||
|| echo.error 'getty theme loading error (see above)'
|
||||
}
|
||||
done
|
||||
|
||||
local WALLPAPER="$(find "$DESKTOP__WALLPAPER_PATH" -type f -name $THEME_NAME.\* 2>/dev/null | head -n1)"
|
||||
[ "$WALLPAPER" ] && command -v feh &>/dev/null \
|
||||
&& feh --no-fehbg --bg-fill "$WALLPAPER"
|
||||
local WALLPAPER="$(find "${DESKTOP__WALLPAPER_PATH}" -type f -name ${THEME_NAME}.\* 2>/dev/null | head -n1)"
|
||||
[ "${WALLPAPER}" ] && command -v feh &>/dev/null \
|
||||
&& feh --no-fehbg --bg-fill "${WALLPAPER}"
|
||||
|
||||
CHECK_ERRORS --no-usage \
|
||||
&& echo "$THEME_NAME" > "$ACTIVE_THEME_PATH/name.txt"
|
||||
utils.check-errors --no-usage \
|
||||
&& echo "${THEME_NAME}" > "${ACTIVE_THEME_PATH}/name.txt"
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
|
||||
_LIST_THEMES() {
|
||||
ls "$_COLORSCHEME_DIR" | sed -n 's/.yaml$//p'
|
||||
ls "${_COLORSCHEME_DIR}" | sed -n 's/.yaml$//p'
|
||||
}
|
||||
|
||||
_GET_YAML_LOOKUP_FOR_ANSI_COLOR() {
|
||||
@ -261,5 +260,5 @@ _GET_YAML_LOOKUP_FOR_ANSI_COLOR() {
|
||||
13: .ansi.magenta.bright
|
||||
14: .ansi.cyan.bright
|
||||
15: .ansi.gray.bright
|
||||
" | YQ -r ".$1"
|
||||
" | utils.yq -r ".$1"
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
_COLORSCHEME_FILE__flameshot="$DOTWRYN/config/flameshot.ini"
|
||||
_COLORSCHEME_FILE__flameshot="${DOTWRYN}/config/user/flameshot/flameshot.ini"
|
||||
|
||||
_GENERATE_THEME__flameshot() {
|
||||
local C1="#$(_GET_HEX .flameshot.color1 .material.primary.200 .ansi.reg.bright )"
|
||||
@ -14,13 +14,13 @@ _GENERATE_THEME__flameshot() {
|
||||
local UI_PRIMARY="#$(_GET_HEX .flameshot.primary .material.primary.600 .ansi.magenta.bright)"
|
||||
local UI_SECONDARY="#$(_GET_HEX .flameshot.secondary .material.secondary.400 .ansi.green.bright)"
|
||||
|
||||
local PICKER="picker, $C1, $C2, $C3, $C4, $C5, $C6, $C7, $C8, $C9"
|
||||
local PICKER="picker, ${C1}, ${C2}, ${C3}, ${C4}, ${C5}, ${C6}, ${C7}, ${C8}, ${C9}"
|
||||
|
||||
sed -i "
|
||||
s/^userColors=.*$/userColors=${PICKER}/
|
||||
s/^uiColor=.*/uiColor=${UI_PRIMARY}/
|
||||
s/^contrastUiColor=.*/contrastUiColor=${UI_SECONDARY}/
|
||||
" "$_COLORSCHEME_FILE__flameshot"
|
||||
" "${_COLORSCHEME_FILE__flameshot}"
|
||||
}
|
||||
|
||||
_SET_THEME__flameshot() {
|
@ -3,5 +3,5 @@ use desktop/colorscheme --group dotwryn
|
||||
#####################################################################
|
||||
|
||||
MAIN() {
|
||||
GET_COLORSCHEME_HEX $@
|
||||
dotwryn.desktop.colorscheme.get-hex $@
|
||||
}
|
||||
|
@ -9,6 +9,6 @@ USAGE__description+='
|
||||
#####################################################################
|
||||
|
||||
MAIN() {
|
||||
cat "$ACTIVE_THEME_PATH/name.txt" 2>/dev/null \
|
||||
cat "${ACTIVE_THEME_PATH}/name.txt" 2>/dev/null \
|
||||
|| ERROR 'theme name not available'
|
||||
}
|
||||
|
36
scwrypts/dotwryn/desktop/colorscheme/getty.module.zsh
Normal file
36
scwrypts/dotwryn/desktop/colorscheme/getty.module.zsh
Normal file
@ -0,0 +1,36 @@
|
||||
_COLORSCHEME_FILE__getty="${ACTIVE_THEME_PATH}/getty.sh"
|
||||
|
||||
_GENERATE_THEME__getty() {
|
||||
echo "#!/bin/sh
|
||||
# do not edit; generated by scwrypts
|
||||
# theme : ${THEME_NAME}
|
||||
#
|
||||
# source this file to apply colorscheme to linux getty
|
||||
#
|
||||
[[ \"\$TERM\" =~ ^linux$ ]] || return 0
|
||||
/bin/echo -e \" \
|
||||
\\e]P0${BACKGROUND} \
|
||||
\\e]P1${RED} \
|
||||
\\e]P2${GREEN} \
|
||||
\\e]P3${YELLOW} \
|
||||
\\e]P4${BLUE} \
|
||||
\\e]P5${MAGENTA} \
|
||||
\\e]P6${CYAN} \
|
||||
\\e]P7${FOREGROUND} \
|
||||
\\e]P8${BRIGHT_RED} \
|
||||
\\e]P9${BRIGHT_GREEN} \
|
||||
\\e]PA${BRIGHT_YELLOW} \
|
||||
\\e]PB${BRIGHT_BLUE} \
|
||||
\\e]PC${BRIGHT_MAGENTA} \
|
||||
\\e]PD${BRIGHT_CYAN} \
|
||||
\\e]PE${WHITE} \
|
||||
\\e]PF${BRIGHT_WHITE} \
|
||||
\"
|
||||
[ ! \$NO_CLEAR ] && clear
|
||||
return 0
|
||||
" sed '$d' > "${_COLORSCHEME_FILE__getty}"
|
||||
}
|
||||
|
||||
_SET_THEME__getty() {
|
||||
return 0 # theme is referenced explicitly after generation
|
||||
}
|
32
scwrypts/dotwryn/desktop/colorscheme/kitty.module.zsh
Normal file
32
scwrypts/dotwryn/desktop/colorscheme/kitty.module.zsh
Normal file
@ -0,0 +1,32 @@
|
||||
_COLORSCHEME_FILE__kitty="${DOTWRYN}/config/user/kitty/theme.conf"
|
||||
|
||||
_GENERATE_THEME__kitty() {
|
||||
echo "# do not edit; generated by scwrypts
|
||||
# theme : ${THEME_NAME}
|
||||
color0 #${BLACK}
|
||||
color1 #${RED}
|
||||
color2 #${GREEN}
|
||||
color3 #${YELLOW}
|
||||
color4 #${BLUE}
|
||||
color5 #${MAGENTA}
|
||||
color6 #${CYAN}
|
||||
color7 #${WHITE}
|
||||
color8 #${BRIGHT_BLACK}
|
||||
color9 #${BRIGHT_RED}
|
||||
color10 #${BRIGHT_GREEN}
|
||||
color11 #${BRIGHT_YELLOW}
|
||||
color12 #${BRIGHT_BLUE}
|
||||
color13 #${BRIGHT_MAGENTA}
|
||||
color14 #${BRIGHT_CYAN}
|
||||
color15 #${BRIGHT_WHITE}
|
||||
cursor #${CURSOR}
|
||||
background #${BACKGROUND}
|
||||
foreground #${FOREGROUND}
|
||||
selection_background #${SELECTION_BACKGROUND}
|
||||
selection_foreground #${SELECTION_FOREGROUND}
|
||||
" | sed '$d' > "${_COLORSCHEME_FILE__kitty}"
|
||||
}
|
||||
|
||||
_SET_THEME__kitty() {
|
||||
return 0 # theme is referenced explicitly after generation
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
_COLORSCHEME_FILE__polybar="$ACTIVE_THEME_PATH/polybar.ini"
|
||||
_COLORSCHEME_FILE__polybar="${DOTWRYN}/config/user/polybar/theme.ini"
|
||||
|
||||
_GENERATE_THEME__polybar() {
|
||||
echo "# do not edit; generated by scwrypts
|
||||
# theme : $THEME_NAME
|
||||
# theme : ${THEME_NAME}
|
||||
[colors]
|
||||
background = #$(_GET_HEX .polybar.background .background)
|
||||
foreground = #$(_GET_HEX .polybar.foreground .foreground)
|
||||
@ -24,7 +24,7 @@ secondary-gradient-1 = #$(_GET_HEX .polybar.secondary-gradient-1 .material.sec
|
||||
secondary-gradient-2 = #$(_GET_HEX .polybar.secondary-gradient-2 .material.secondary.500 .ansi.blue.regular )
|
||||
secondary-gradient-3 = #$(_GET_HEX .polybar.secondary-gradient-3 .material.secondary.400 .ansi.blue.regular )
|
||||
secondary-gradient-4 = #$(_GET_HEX .polybar.secondary-gradient-4 .material.secondary.300 .ansi.blue.regular )
|
||||
" | sed '$d' > "$_COLORSCHEME_FILE__polybar"
|
||||
" | sed '$d' > "${_COLORSCHEME_FILE__polybar}"
|
||||
}
|
||||
|
||||
_SET_THEME__polybar() {
|
@ -1,9 +1,9 @@
|
||||
_COLORSCHEME_FILE__rofi="$ACTIVE_THEME_PATH/rofi.rasi"
|
||||
_COLORSCHEME_FILE__rofi="${ACTIVE_THEME_PATH}/rofi.rasi"
|
||||
|
||||
_GENERATE_THEME__rofi() {
|
||||
echo "/**
|
||||
* do not edit; generated by scwrypts
|
||||
* theme : $THEME_NAME
|
||||
* theme : ${THEME_NAME}
|
||||
**/
|
||||
|
||||
*{
|
@ -8,7 +8,7 @@ USAGE__options+="
|
||||
-l, --list-themes show available color themes and exit
|
||||
|
||||
--only only set the theme for a specific terminal/application
|
||||
($COLORSCHEME__SUPPORTED_CONFIG_TYPES)
|
||||
(${COLORSCHEME__SUPPORTED_CONFIG_TYPES})
|
||||
"
|
||||
|
||||
USAGE__args+='
|
||||
@ -48,9 +48,9 @@ MAIN() {
|
||||
|| ERROR 'failed to set theme (see above)' \
|
||||
|| return 1
|
||||
|
||||
[[ $UPDATE_I3_CONFIG =~ true ]] || return 0
|
||||
[[ ${UPDATE_I3_CONFIG} =~ true ]] || return 0
|
||||
|
||||
I3__GENERATE_CUSTOM_CONFIG \
|
||||
dotwryn.desktop.xorg.i3.generate-config \
|
||||
|| ERROR 'failed to update i3 config (see above)' \
|
||||
|| return 1
|
||||
}
|
||||
|
@ -1,45 +0,0 @@
|
||||
#!/bin/zsh
|
||||
use desktop/notify --group dotwryn
|
||||
use media/audio --group dotwryn
|
||||
|
||||
DEPENDENCIES+=(pactl)
|
||||
|
||||
source $HOME/.config/wryn/env.zsh
|
||||
#####################################################################
|
||||
|
||||
MAIN() {
|
||||
local DEVICE="$1"
|
||||
local COMMAND="$2"
|
||||
|
||||
case $DEVICE in
|
||||
sink ) AMIXER_DEVICE=Master ;;
|
||||
source ) AMIXER_DEVICE=Capture ;;
|
||||
* ) NOTIFY_FAIL 1 "Unsupported device '$DEVICE'" ;;
|
||||
esac
|
||||
|
||||
local DEFAULT_DEVICE="@DEFAULT_$(echo $DEVICE | tr '[:lower:]' '[:upper:]')@"
|
||||
case $COMMAND in
|
||||
up )
|
||||
pactl set-$DEVICE-volume $DEFAULT_DEVICE +10% \
|
||||
|| NOTIFY_ERROR "pactl error with set-$DEVICE-volume"
|
||||
|
||||
MEDIA__PLAY_SFX volume
|
||||
;;
|
||||
|
||||
down )
|
||||
pactl set-$DEVICE-volume $DEFAULT_DEVICE -10% \
|
||||
|| NOTIFY_ERROR "pactl error with set-$DEVICE-volume"
|
||||
|
||||
MEDIA__PLAY_SFX volume
|
||||
;;
|
||||
|
||||
mute )
|
||||
pactl set-$DEVICE-mute $DEFAULT_DEVICE toggle \
|
||||
&& NOTIFY_SUCCESS "default $DEVICE" "$(amixer sget $AMIXER_DEVICE | grep -q '\[on\]' && echo unmuted || echo muted)" \
|
||||
|| NOTIFY_ERROR "pactl error with set-$DEVICE-mute"
|
||||
MEDIA__PLAY_SFX mute
|
||||
;;
|
||||
|
||||
* ) NOTIFY_FAIL 1 "Unsupported command '$COMMAND'" ;;
|
||||
esac
|
||||
}
|
@ -1,39 +1,41 @@
|
||||
#!/bin/zsh
|
||||
use desktop/notify --group dotwryn
|
||||
use notify
|
||||
|
||||
__CHECK_ENV_VAR DESKTOP__BACKLIGHT_DEVICE --optional
|
||||
utils.environment.check DESKTOP__BACKLIGHT_DEVICE --optional
|
||||
|
||||
#####################################################################
|
||||
|
||||
MAIN() {
|
||||
local SCWRYPTS_NOTIFICATION_ENGINES=(echo notify.desktop)
|
||||
local UTIL
|
||||
|
||||
for UTIL in enlighten gmux_backlight xbacklight
|
||||
do
|
||||
command -v $UTIL >/dev/null 2>&1 && break
|
||||
command -v ${UTIL} >/dev/null 2>&1 && break
|
||||
done
|
||||
|
||||
[[ $UTIL =~ ^enlighten$ ]] && {
|
||||
CURRENT_PERCENT=$(enlighten | sed 's/.*(//;s/%.*//')
|
||||
[[ $CURRENT_PERCENT -gt 60 ]] && DELTA=40
|
||||
[[ $CURRENT_PERCENT -le 60 ]] && DELTA=20
|
||||
[[ $CURRENT_PERCENT -le 40 ]] && DELTA=10
|
||||
[[ $CURRENT_PERCENT -le 10 ]] && DELTA=5
|
||||
[[ ${UTIL} =~ ^enlighten$ ]] && {
|
||||
CURRENT_PERCENT=$(BACKLIGHT_DEVICE=${DESKTOP__BACKLIGHT_DEVICE} enlighten | sed 's/.*(//;s/%.*//')
|
||||
[[ ${CURRENT_PERCENT} -gt 60 ]] && DELTA=40
|
||||
[[ ${CURRENT_PERCENT} -le 60 ]] && DELTA=20
|
||||
[[ ${CURRENT_PERCENT} -le 40 ]] && DELTA=10
|
||||
[[ ${CURRENT_PERCENT} -le 10 ]] && DELTA=5
|
||||
}
|
||||
|
||||
case $1 in
|
||||
up )
|
||||
case $UTIL in
|
||||
case ${UTIL} in
|
||||
xbacklight ) xbacklight -inc 10 ;;
|
||||
gmux_backlight ) gmux_backlight +100 ;;
|
||||
|
||||
enlighten )
|
||||
[[ $CURRENT_PERCENT -ge 99 ]] && NOTIFY_SEND 'at maximum brightness' && exit 0
|
||||
BACKLIGHT_DEVICE=$DESKTOP__BACKLIGHT_DEVICE enlighten +${DELTA}%
|
||||
[[ ${CURRENT_PERCENT} -ge 99 ]] && notify.status 'at maximum brightness' && exit 0
|
||||
BACKLIGHT_DEVICE=${DESKTOP__BACKLIGHT_DEVICE} enlighten +${DELTA}%
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
down )
|
||||
case $UTIL in
|
||||
case ${UTIL} in
|
||||
xbacklight )
|
||||
[[ $(xbacklight -get) -le 10 ]] \
|
||||
&& xbacklight -set 1 \
|
||||
@ -44,36 +46,36 @@ MAIN() {
|
||||
gmux_backlight ) gmux_backlight -100 ;;
|
||||
|
||||
enlighten )
|
||||
[[ $CURRENT_PERCENT -le 1 ]] && NOTIFY_SEND 'at minimum brightness' && exit 0
|
||||
[[ $CURRENT_PERCENT -le 2 ]] && ARGS='=1%' || ARGS="-${DELTA}%"
|
||||
BACKLIGHT_DEVICE=$DESKTOP__BACKLIGHT_DEVICE enlighten "$ARGS"
|
||||
[[ ${CURRENT_PERCENT} -le 1 ]] && notify.status 'at minimum brightness' && exit 0
|
||||
[[ ${CURRENT_PERCENT} -le 2 ]] && ARGS='=1%' || ARGS="-${DELTA}%"
|
||||
BACKLIGHT_DEVICE=${DESKTOP__BACKLIGHT_DEVICE} enlighten "${ARGS}"
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
set )
|
||||
[ ! $2 ] && FAIL 1 'no value provided to set'
|
||||
case $UTIL in
|
||||
case ${UTIL} in
|
||||
xbacklight ) xbacklight -set $2 ;;
|
||||
gmux_backlight ) gmux_backlight $2 ;;
|
||||
enlighten ) BACKLIGHT_DEVICE=$DESKTOP__BACKLIGHT_DEVICE enlighten "=$2" ;;
|
||||
enlighten ) BACKLIGHT_DEVICE=${DESKTOP__BACKLIGHT_DEVICE} enlighten "=$2" ;;
|
||||
esac
|
||||
;;
|
||||
min | minimum )
|
||||
case $UTIL in
|
||||
enlighten ) BACKLIGHT_DEVICE=$DESKTOP__BACKLIGHT_DEVICE enlighten '=1%' ;;
|
||||
case ${UTIL} in
|
||||
enlighten ) BACKLIGHT_DEVICE=${DESKTOP__BACKLIGHT_DEVICE} enlighten '=1%' ;;
|
||||
esac
|
||||
;;
|
||||
max | maximum )
|
||||
case $UTIL in
|
||||
enlighten ) BACKLIGHT_DEVICE=$DESKTOP__BACKLIGHT_DEVICE enlighten '=100%' ;;
|
||||
case ${UTIL} in
|
||||
enlighten ) BACKLIGHT_DEVICE=${DESKTOP__BACKLIGHT_DEVICE} enlighten '=100%' ;;
|
||||
esac
|
||||
;;
|
||||
query | '' )
|
||||
case $UTIL in
|
||||
enlighten ) NOTIFY_SUCCESS "current brightness : $(BACKLIGHT_DEVICE=$DESKTOP__BACKLIGHT_DEVICE enlighten)" ;;
|
||||
case ${UTIL} in
|
||||
enlighten ) notify.success "current brightness : $(BACKLIGHT_DEVICE=${DESKTOP__BACKLIGHT_DEVICE} enlighten)" ;;
|
||||
esac
|
||||
;;
|
||||
|
||||
* ) NOTIFY_FAIL 1 "operation '$1' not supported" ;;
|
||||
* ) notify.error "operation '$1' not supported"; return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
@ -1,94 +0,0 @@
|
||||
#!/bin/zsh
|
||||
DEPENDENCIES+=(diff)
|
||||
REQUIRED_ENV+=(I3__MODEL_CONFIG)
|
||||
#####################################################################
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
"
|
||||
|
||||
#####################################################################
|
||||
|
||||
REGEX_FONT='^\(font [^0-9]*\)\(.*\)'
|
||||
REGEX_DMENU="^\\(.*dmenu_run .*-fn '[^0-9]*\\)\\([0-9]*\\)'"
|
||||
REGEX_BORDER='^\(for_window.*border pixel \)\(.*\)'
|
||||
|
||||
MAIN() {
|
||||
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" \
|
||||
&& DEBUG "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" \
|
||||
&& DEBUG "output is the same as model, i3config has been linked to model" \
|
||||
;
|
||||
|
||||
[[ $FORCE -eq 1 ]] && rm "$CONFIG.bak" >/dev/null 2>&1
|
||||
return 0
|
||||
}
|
@ -3,10 +3,10 @@ use desktop/xorg/i3 --group dotwryn
|
||||
|
||||
#####################################################################
|
||||
|
||||
I3__GENERATE_CUSTOM_CONFIG__USAGE
|
||||
dotwryn.desktop.xorg.i3.generate-config.parse.usage
|
||||
|
||||
MAIN() {
|
||||
I3__GENERATE_CUSTOM_CONFIG
|
||||
dotwryn.desktop.xorg.i3.generate-config
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
|
@ -6,59 +6,30 @@ DEPENDENCIES+=(basename readlink sed yq)
|
||||
|
||||
#####################################################################
|
||||
|
||||
I3__GENERATE_CUSTOM_CONFIG__USAGE() {
|
||||
USAGE__options+="
|
||||
--safe preserve old config (or fail if old conf does not exist)
|
||||
--override-file fully qualified path to the override yaml file (default ~/.config/i3/local.yaml)
|
||||
"
|
||||
${scwryptsmodule}() {
|
||||
eval "$(utils.parse.autosetup)"
|
||||
##########################################
|
||||
|
||||
USAGE__description+="
|
||||
Since i3wm does not provide a way to load config values dynamically,
|
||||
I run this script to generate colorscheme values and other per-machine
|
||||
overrides.
|
||||
|
||||
Uses the current, active colorscheme and local overrides specified in
|
||||
~/.config/i3/local.yaml
|
||||
"
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
|
||||
I3__GENERATE_CUSTOM_CONFIG() {
|
||||
local SAFE=false
|
||||
local CONFIG_DEFAULT_FILE="$DOTWRYN/config/i3.config.yaml"
|
||||
local CONFIG_OVERRIDE_FILE="$HOME/.config/i3/local.yaml"
|
||||
|
||||
while [[ $# -gt 0 ]]
|
||||
do
|
||||
case $1 in
|
||||
--safe ) SAFE=true ;;
|
||||
--override-file )
|
||||
[ -f "$2" ] || ERROR "no file '$2' can be found"
|
||||
CONFIG_OVERRIDE_FILE="$2"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
CHECK_ERRORS
|
||||
|
||||
[ -f "$CONFIG_OVERRIDE_FILE" ] || {
|
||||
mkdir -p "$(dirname $CONFIG_OVERRIDE_FILE)"
|
||||
echo '---' > "$CONFIG_OVERRIDE_FILE"
|
||||
}
|
||||
|
||||
local CONFIG="$(YQ eval-all '. as $item ireduce ({}; . * $item)' "$CONFIG_DEFAULT_FILE" "$CONFIG_OVERRIDE_FILE")"
|
||||
local CONFIG="$(utils.yq eval-all '. as $item ireduce ({}; . * $item)' "$CONFIG_DEFAULT_FILE" "$CONFIG_OVERRIDE_FILE")"
|
||||
[ $CONFIG ] \
|
||||
|| ERROR "unable to retrieve i3 config yaml (see above)" \
|
||||
|| return 1 \
|
||||
;
|
||||
|
||||
GET() { echo "$CONFIG" | YQ -r $@; }
|
||||
COLOR() { GET_COLORSCHEME_HEX $@; }
|
||||
GET() { echo "$CONFIG" | utils.yq -r $@; }
|
||||
COLOR() { dotwryn.desktop.colorscheme.get-hex $@; }
|
||||
|
||||
local I3_CONFIG="$HOME/.config/i3/config"
|
||||
: \
|
||||
&& STATUS "generating configuration" \
|
||||
&& echo.status "generating configuration" \
|
||||
&& {
|
||||
echo "# i3 config file (v4)"
|
||||
echo "# generated by 'scwrypts generate i3 config' (do not edit directly)"
|
||||
@ -73,7 +44,7 @@ I3__GENERATE_CUSTOM_CONFIG() {
|
||||
echo 'bar { status_command i3status }'
|
||||
;;
|
||||
polybar )
|
||||
echo "exec_always --no-startup-id $DOTWRYN/bin/polybar &"
|
||||
echo "exec_always --no-startup-id $DOTWRYN/config/bin/polybar &"
|
||||
echo "exec --no-startup-id i3-msg workspace 1"
|
||||
;;
|
||||
esac
|
||||
@ -94,7 +65,7 @@ I3__GENERATE_CUSTOM_CONFIG() {
|
||||
s/^\(gaps inner\) .*$/\1 $(GET .gaps.inner)/
|
||||
s/^\(gaps outer\) .*$/\1 $(GET .gaps.outer)/
|
||||
|
||||
s/^\(# color settings\).*$/\1 (theme '$(basename $(readlink -f "$DOTWRYN/colorschemes/active/main.conf") | sed 's/\.conf//')')/
|
||||
s/^\(# color settings\).*$/\1 (theme '$(basename $(readlink -f "$DOTWRYN/config/colorschemes/active/main.conf") | sed 's/\.conf//')')/
|
||||
|
||||
s/\(^set \$FOCUSED_\(BORDER\|BACKGROUND\|CHILD_BORDER\).*#\).*/\1$(COLOR .i3.focused.border .material.secondary.500 .ansi.green.bright)/
|
||||
s/\(^set \$FOCUSED_INDICATOR.*#\).*/\1$(COLOR .i3.focused.indicator .material.secondary.700 .ansi.green.regular)/
|
||||
@ -122,7 +93,7 @@ I3__GENERATE_CUSTOM_CONFIG() {
|
||||
&& grep -v "^\(bindsym\|set\|font\) " "$I3_CONFIG.temp2" >> "$I3_CONFIG.temp" \
|
||||
&& { GET '.i3configs[]' 2>/dev/null >> "$I3_CONFIG.temp"; true }\
|
||||
&& rm "$I3_CONFIG.temp2" \
|
||||
&& STATUS "validating config" \
|
||||
&& echo.status "validating config" \
|
||||
&& i3 -C -c "$I3_CONFIG.temp" \
|
||||
|| ERROR "unable to produce config, or produced an invalid config (see above or '$I3_CONFIG.temp')" \
|
||||
|| return 1
|
||||
@ -136,7 +107,7 @@ I3__GENERATE_CUSTOM_CONFIG() {
|
||||
done
|
||||
|
||||
mv "$I3_CONFIG" "$BACKUP_FILE" && {
|
||||
SUCCESS "saved old config to '$BACKUP_FILE'"
|
||||
echo.success "saved old config to '$BACKUP_FILE'"
|
||||
} || {
|
||||
WARNING 'failed to preserve old config'
|
||||
yN 'any existing config will be overwritten; continue?'
|
||||
@ -145,7 +116,7 @@ I3__GENERATE_CUSTOM_CONFIG() {
|
||||
|
||||
: \
|
||||
&& mv "$I3_CONFIG.temp" "$I3_CONFIG" \
|
||||
&& SUCCESS "successfully generated i3 config" \
|
||||
&& echo.success "successfully generated i3 config" \
|
||||
|| ERROR "something went wrong when moving config (check '$(dirname $I3_CONFIG)')" \
|
||||
|| return 1 \
|
||||
;
|
||||
@ -153,8 +124,45 @@ I3__GENERATE_CUSTOM_CONFIG() {
|
||||
: \
|
||||
&& pgrep i3 &>/dev/null \
|
||||
&& i3-msg restart &>/dev/null \
|
||||
&& STATUS 'reloaded config for current session' \
|
||||
&& echo.status 'reloaded config for current session' \
|
||||
;
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
|
||||
|
||||
${scwryptsmodule}.parse() {
|
||||
local PARSED=0
|
||||
|
||||
case $1 in
|
||||
--safe ) SAFE=true ;;
|
||||
--override-file )
|
||||
[ -f "$2" ] || ERROR "no file '$2' can be found"
|
||||
CONFIG_OVERRIDE_FILE="$2"
|
||||
;;
|
||||
esac
|
||||
|
||||
return ${PARSED}
|
||||
}
|
||||
|
||||
${scwryptsmodule}.parse.locals() {
|
||||
local SAFE=false
|
||||
}
|
||||
|
||||
${scwryptsmodule}.parse.usage() {
|
||||
USAGE__options+="
|
||||
--safe preserve old config (or fail if old conf does not exist)
|
||||
--override-file fully qualified path to the override yaml file (default ~/.config/i3/local.yaml)
|
||||
"
|
||||
|
||||
USAGE__description+="
|
||||
Since i3wm does not provide a way to load config values dynamically,
|
||||
I run this script to generate colorscheme values and other per-machine
|
||||
overrides.
|
||||
|
||||
Uses the current, active colorscheme and local overrides specified in
|
||||
~/.config/i3/local.yaml
|
||||
"
|
||||
}
|
7
scwrypts/dotwryn/desktop/xorg/i3/i3.module.zsh
Normal file
7
scwrypts/dotwryn/desktop/xorg/i3/i3.module.zsh
Normal file
@ -0,0 +1,7 @@
|
||||
#
|
||||
# manipulate i3 and i3config
|
||||
#
|
||||
|
||||
|
||||
# customize source-controlled i3 config with advanced local overrides
|
||||
use desktop/xorg/i3/generate-config --group dotwryn
|
@ -1,5 +1,5 @@
|
||||
#!/bin/zsh
|
||||
use system/desktop/notify
|
||||
use notify
|
||||
|
||||
DEPENDENCIES+=(i3-msg xdotool xrandr)
|
||||
#####################################################################
|
||||
@ -38,7 +38,7 @@ USAGE__description="
|
||||
#####################################################################
|
||||
|
||||
MAIN() {
|
||||
DEBUG $@
|
||||
local SCWRYPTS_NOTIFICATION_ENGINES=(echo notify.desktop)
|
||||
local APPLICATION CLIENT_CLASS
|
||||
|
||||
local XFFSET=0.0
|
||||
@ -80,12 +80,11 @@ MAIN() {
|
||||
|
||||
[ $APPLICATION ] && {
|
||||
__CHECK_DEPENDENCY $APPLICATION || {
|
||||
ERROR "$APPLICATION is not installed"
|
||||
NOTIFY "ERROR: $APPLICATION not found"
|
||||
notify.error "$APPLICATION not found"
|
||||
}
|
||||
}
|
||||
|
||||
CHECK_ERRORS
|
||||
utils.check-errors --fail
|
||||
|
||||
xrandr | grep primary | awk '{print $4;}' | grep -q '^[0-9x+]\+$' || {
|
||||
xrandr --output $(xrandr | grep ' connected' | awk '{print $1;}' | head -n1) --primary
|
||||
@ -94,16 +93,16 @@ MAIN() {
|
||||
local CURRENTLY_ACTIVE=$(xdotool search --onlyvisible --classname $CLIENT_CLASS 2>/dev/null | wc -l)
|
||||
|
||||
local LAUNCH_APP=$ALWAYS_LAUNCH
|
||||
STATUS "looking for window process ids"
|
||||
echo.status "looking for window process ids"
|
||||
xdotool search --class $CLIENT_CLASS || LAUNCH_APP=1
|
||||
|
||||
[[ $LAUNCH_APP -eq 1 ]] && {
|
||||
STATUS 'launching application'
|
||||
echo.status 'launching application'
|
||||
i3-msg "exec --no-startup-id $APPLICATION;"
|
||||
sleep .5
|
||||
}
|
||||
|
||||
STATUS 'getting target window size'
|
||||
echo.status 'getting target window size'
|
||||
WINDOW_SIZE=$(\
|
||||
xrandr \
|
||||
| grep 'connected primary' \
|
||||
@ -111,21 +110,21 @@ MAIN() {
|
||||
| awk -v f=$SCALE -v x=$XFFSET -v y=$YFFSET \
|
||||
'{print int($1*f+x)," ",int($2*f+y);}'\
|
||||
)
|
||||
DEBUG "window size: $WINDOW_SIZE"
|
||||
echo.debug "window size: $WINDOW_SIZE"
|
||||
|
||||
STATUS 'moving window to scratchpad'
|
||||
echo.status 'moving window to scratchpad'
|
||||
i3-msg "[class=$CLIENT_CLASS] move scratchpad"
|
||||
|
||||
[[ $RESIZE -eq 1 ]] \
|
||||
&& STATUS 'resizing window' \
|
||||
&& echo.status 'resizing window' \
|
||||
&& i3-msg "[class=$CLIENT_CLASS] resize set $WINDOW_SIZE"
|
||||
|
||||
[[ $CURRENTLY_ACTIVE -lt $MIN_ACTIVE ]] && {
|
||||
STATUS 'pulling window from scratchpad to foreground'
|
||||
echo.status 'pulling window from scratchpad to foreground'
|
||||
i3-msg "[class=$CLIENT_CLASS] scratchpad show"
|
||||
}
|
||||
|
||||
STATUS 'moving window to center of current screen'
|
||||
echo.status 'moving window to center of current screen'
|
||||
[[ $MOVE -eq 1 ]] && i3-msg "[class=$CLIENT_CLASS] move position center"
|
||||
|
||||
return 0
|
||||
|
@ -1,11 +1,13 @@
|
||||
#!/bin/zsh
|
||||
|
||||
use notify
|
||||
use desktop/colorscheme --group dotwryn
|
||||
use desktop/notify --group dotwryn
|
||||
|
||||
DEPENDENCIES+=(i3lock)
|
||||
#####################################################################
|
||||
|
||||
MAIN() {
|
||||
local SCWRYPTS_NOTIFICATION_ENGINES=(echo notify.desktop)
|
||||
local ARGS=(
|
||||
--ignore-empty-password
|
||||
--force-clock
|
||||
@ -16,22 +18,22 @@ MAIN() {
|
||||
--verif-text=''
|
||||
--wrong-text=''
|
||||
--blur=11
|
||||
--insidever-color=$(GET_COLORSCHEME_HEX 6)
|
||||
--ringver-color=$(GET_COLORSCHEME_HEX 10)
|
||||
--insidewrong-color=$(GET_COLORSCHEME_HEX 1)
|
||||
--ringwrong-color=$(GET_COLORSCHEME_HEX 9)
|
||||
--inside-color=$(GET_COLORSCHEME_HEX 0)
|
||||
--ring-color=$(GET_COLORSCHEME_HEX 2)
|
||||
--time-color=$(GET_COLORSCHEME_HEX 7)
|
||||
--date-color=$(GET_COLORSCHEME_HEX 15)
|
||||
--keyhl-color=$(GET_COLORSCHEME_HEX 11)
|
||||
--bshl-color=$(GET_COLORSCHEME_HEX 13)
|
||||
--insidever-color=$(dotwryn.desktop.colorscheme.get-hex 6)
|
||||
--ringver-color=$(dotwryn.desktop.colorscheme.get-hex 10)
|
||||
--insidewrong-color=$(dotwryn.desktop.colorscheme.get-hex 1)
|
||||
--ringwrong-color=$(dotwryn.desktop.colorscheme.get-hex 9)
|
||||
--inside-color=$(dotwryn.desktop.colorscheme.get-hex 0)
|
||||
--ring-color=$(dotwryn.desktop.colorscheme.get-hex 2)
|
||||
--time-color=$(dotwryn.desktop.colorscheme.get-hex 7)
|
||||
--date-color=$(dotwryn.desktop.colorscheme.get-hex 15)
|
||||
--keyhl-color=$(dotwryn.desktop.colorscheme.get-hex 11)
|
||||
--bshl-color=$(dotwryn.desktop.colorscheme.get-hex 13)
|
||||
)
|
||||
|
||||
local RADIUS=$(xrandr | grep 'connected primary' | sed 's/.* \([0-9]\+\)x.*/\1/' | awk '{print int($1*0.08)}')
|
||||
[ $RADIUS ] && ARGS+=(--radius=$RADIUS)
|
||||
|
||||
i3lock ${ARGS[@]} \
|
||||
|| NOTIFY_ERROR 'i3lock-color' 'something went wrong; unable to lock' \
|
||||
|| notify.error 'something went wrong; unable to lock' \
|
||||
;
|
||||
}
|
||||
|
@ -1,13 +1,14 @@
|
||||
#!/bin/zsh
|
||||
use desktop/notify --group dotwryn
|
||||
use notify
|
||||
|
||||
DEPENDENCIES+=(i3-nagbar)
|
||||
#####################################################################
|
||||
|
||||
MAIN() {
|
||||
local SCWRYPTS_NOTIFICATION_ENGINES=(echo notify.desktop)
|
||||
i3-nagbar \
|
||||
-t warning \
|
||||
-m 'Do you really want to exit i3?' \
|
||||
-B 'Yes' "notify-send 'system' 'exiting i3...' -i face-tired; i3-msg exit" \
|
||||
|| NOTIFY_ERROR 'unable to launch i3-nagbar'
|
||||
|| notify.error 'unable to launch i3-nagbar'
|
||||
}
|
||||
|
@ -1,51 +1,61 @@
|
||||
#!/bin/zsh
|
||||
use desktop/notify --group dotwryn
|
||||
#####################################################################
|
||||
|
||||
use notify
|
||||
|
||||
DEPENDENCIES+=(xset)
|
||||
|
||||
#####################################################################
|
||||
|
||||
MAIN() {
|
||||
local SCWRYPTS_NOTIFICATION_ENGINES=(echo notify.desktop)
|
||||
case $1 in
|
||||
enable | disable | query | toggle ) ACTION="$1" ;;
|
||||
* )
|
||||
[ ! $1 ] && ACTION=toggle
|
||||
echo $ACTION
|
||||
echo ${ACTION}
|
||||
;;
|
||||
esac
|
||||
|
||||
[[ $ACTION =~ ^toggle$ ]] && {
|
||||
[[ ${ACTION} =~ ^toggle$ ]] && {
|
||||
xset -q | grep -qi 'prefer blanking: *no' \
|
||||
&& ACTION='enable' || ACTION='disable'
|
||||
}
|
||||
|
||||
[ ! $ACTION ] && NOTIFY_FAIL 1 "unknown screen blank action '$1'"
|
||||
[ ${ACTION} ] \
|
||||
|| notify.error "unknown screen blank action '$1'" \
|
||||
|| return 1
|
||||
|
||||
case $ACTION in
|
||||
case ${ACTION} in
|
||||
enable ) : \
|
||||
&& STATUS 'enabling screen blank' \
|
||||
&& echo.status 'enabling screen blank' \
|
||||
&& xset +dpms \
|
||||
&& xset s blank \
|
||||
&& xset s on \
|
||||
&& NOTIFY_SUCCESS 'enabled screen blank' \
|
||||
|| NOTIFY_FAIL 2 'error enabling screen blank'
|
||||
&& notify.success 'enabled screen blank' \
|
||||
|| notify.error 'error enabling screen blank' \
|
||||
|| return 2
|
||||
;;
|
||||
|
||||
disable ) : \
|
||||
&& STATUS 'disabling screen blank' \
|
||||
&& echo.status 'disabling screen blank' \
|
||||
&& xset dpms 0 0 0 \
|
||||
&& xset s noblank \
|
||||
&& xset s off \
|
||||
&& NOTIFY_SUCCESS 'disabled screen blank' \
|
||||
|| NOTIFY_FAIL 2 'error disabling screen blank'
|
||||
&& notify.success 'disabled screen blank' \
|
||||
|| notify.error 'error disabling screen blank' \
|
||||
|| return 2
|
||||
;;
|
||||
|
||||
query )
|
||||
xset -q | grep -qi 'prefer blanking: *no' \
|
||||
&& CURRENT_STATE='disabled' || CURRENT_STATE='enabled'
|
||||
|
||||
[ ! $CURRENT_STATE ] && NOTIFY_FAIL 3 'unable to determine current setting'
|
||||
[ ${CURRENT_STATE} ] \
|
||||
|| notify.error 'unable to determine current setting' \
|
||||
|| return 3
|
||||
|
||||
NOTIFY_SUCCESS "screen blank is currently \\033[0;34m$CURRENT_STATE"
|
||||
notify.success "screen blank is currently $(utils.colors.print blue "${CURRENT_STATE}")"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
@ -8,9 +8,9 @@ REQUIRED_ENV+=()
|
||||
#####################################################################
|
||||
|
||||
XRANDR__DISCONNECT_ALL_DISPLAYS() {
|
||||
STATUS 'disconnecting all displays' \
|
||||
echo.status 'disconnecting all displays' \
|
||||
&& xrandr $(xrandr | grep ' connected' | awk '{print "--output "$1" --off"}') \
|
||||
&& sleep 1 \
|
||||
&& SUCCESS 'all displays disconnected' \
|
||||
&& echo.success 'all displays disconnected' \
|
||||
|| { ERROR 'unable to disconnect displays'; return 1; }
|
||||
}
|
@ -1,6 +1,31 @@
|
||||
SCWRYPTS_GROUPS+=(dotwryn)
|
||||
[ $DOTWRYN ] || source "$HOME/.config/wryn/env.zsh"
|
||||
readonly ${scwryptsgroup}__type=zsh
|
||||
readonly ${scwryptsgroup}__color=$(utils.colors.red)
|
||||
|
||||
export SCWRYPTS_TYPE__dotwryn=zsh
|
||||
export SCWRYPTS_ROOT__dotwryn="$DOTWRYN/scwrypts/dotwryn"
|
||||
export SCWRYPTS_COLOR__dotwryn='\033[0;31m'
|
||||
#####################################################################
|
||||
|
||||
[ "${DOTWRYN}" ] \
|
||||
|| export DOTWRYN=$(git -C "${0:a:h}" rev-parse --show-toplevel 2>/dev/null)
|
||||
|
||||
export DOTWRYN_HOSTNAME=$(hostnamectl --static)
|
||||
|
||||
[ "${XDG_CONFIG_HOME}" ] \
|
||||
|| export XDG_CONFIG_HOME="${HOME}/.config"
|
||||
|
||||
[ "${XDG_DATA_HOME}" ] \
|
||||
|| export XDG_DATA_HOME="${HOME}/.local/share"
|
||||
|
||||
##########################################
|
||||
|
||||
for DOTWRYN_REQUIRED_VAR in \
|
||||
DOTWRYN \
|
||||
DOTWRYN_HOSTNAME \
|
||||
;
|
||||
do
|
||||
[ "${(P)DOTWRYN_REQUIRED_VAR}" ] \
|
||||
|| echo.error "cannot determine ${DOTWRYN_REQUIRED_VAR}" \
|
||||
|| return 1
|
||||
done
|
||||
|
||||
unset DOTWRYN_REQUIRED_VAR
|
||||
|
||||
#####################################################################
|
||||
|
@ -14,10 +14,10 @@ CHECK_SESSION() {
|
||||
}
|
||||
|
||||
UPDATE_ALL() {
|
||||
STATUS "starting '$@'"
|
||||
echo.status "starting '$@'"
|
||||
for SERVER in ${WRYN__SERVER_HOSTNAMES[@]}; do UPDATE $SERVER "$@"; done
|
||||
WAIT_FOR_UPDATES \
|
||||
&& SUCCESS "'$@' finished across all servers" \
|
||||
&& echo.success "'$@' finished across all servers" \
|
||||
|| FAIL 69 'user abort' \
|
||||
;
|
||||
}
|
||||
@ -60,7 +60,7 @@ MAIN() {
|
||||
tmux new -d -s $SESSION "echo 'updating all systems'; echo '(leave this window open)'; while true; do sleep 30; done"
|
||||
|
||||
yN 'after update, do you want to reboot all machines?' && REBOOT=1 || REBOOT=0
|
||||
REMINDER "
|
||||
echo.reminder "
|
||||
manual action is required; (in another tab) connect to tmux:
|
||||
tmux a -t $SESSION
|
||||
|
||||
@ -69,7 +69,7 @@ MAIN() {
|
||||
"
|
||||
|
||||
[ $CURRENT_SESSION ] && {
|
||||
SUCCESS 'currently in a tmux session; opening new window...'
|
||||
echo.success 'currently in a tmux session; opening new window...'
|
||||
tmux new-window -t $CURRENT_SESSION "unset TMUX; tmux a -t $SESSION"
|
||||
}
|
||||
|
||||
@ -85,7 +85,7 @@ MAIN() {
|
||||
tmux kill-session -t $SESSION >/dev/null 2>&1
|
||||
CHECK_SESSION && WARNING "unable to close tmux session '$SESSION'"
|
||||
|
||||
SUCCESS " \nfinished system update accross all servers\n "
|
||||
echo.success " \nfinished system update accross all servers\n "
|
||||
|
||||
[[ $REBOOT -eq 1 ]] && { STATUS 'rebooting host machine'; sleep 3; reboot || sudo reboot; }
|
||||
[[ $REBOOT -eq 1 ]] && { echo.status 'rebooting host machine'; sleep 3; reboot || sudo reboot; }
|
||||
}
|
||||
|
@ -1,77 +0,0 @@
|
||||
_COLORSCHEME_FILE__alacritty_toml="$ACTIVE_THEME_PATH/alacritty.toml"
|
||||
_COLORSCHEME_FILE__alacritty_yaml="$ACTIVE_THEME_PATH/alacritty.yaml"
|
||||
|
||||
_GENERATE_THEME__alacritty() {
|
||||
echo "# do not edit; generated by scwrypts
|
||||
# theme : $THEME_NAME
|
||||
[colors.cursor]
|
||||
cursor = '0x$(_GET_HEX .alacritty.cursor cursor)'
|
||||
|
||||
[colors.primary]
|
||||
background = '0x$(_GET_HEX .alacritty.background .background)'
|
||||
foreground = '0x$(_GET_HEX .alacritty.foreground .foreground)'
|
||||
|
||||
[colors.normal]
|
||||
black = '0x$(_GET_HEX .ansi.gray.black)'
|
||||
red = '0x$(_GET_HEX .ansi.red.regular)'
|
||||
green = '0x$(_GET_HEX .ansi.green.regular)'
|
||||
yellow = '0x$(_GET_HEX .ansi.yellow.regular)'
|
||||
blue = '0x$(_GET_HEX .ansi.blue.regular)'
|
||||
magenta = '0x$(_GET_HEX .ansi.magenta.regular)'
|
||||
cyan = '0x$(_GET_HEX .ansi.cyan.regular)'
|
||||
white = '0x$(_GET_HEX .ansi.gray.white)'
|
||||
|
||||
[colors.bright]
|
||||
black = '0x$(_GET_HEX .ansi.gray.regular)'
|
||||
red = '0x$(_GET_HEX .ansi.red.bright)'
|
||||
green = '0x$(_GET_HEX .ansi.green.bright)'
|
||||
yellow = '0x$(_GET_HEX .ansi.yellow.bright)'
|
||||
blue = '0x$(_GET_HEX .ansi.blue.bright)'
|
||||
magenta = '0x$(_GET_HEX .ansi.magenta.bright)'
|
||||
cyan = '0x$(_GET_HEX .ansi.cyan.bright)'
|
||||
white = '0x$(_GET_HEX .ansi.gray.bright)'
|
||||
" | sed '$d' > "$_COLORSCHEME_FILE__alacritty_toml"
|
||||
|
||||
# backwards yaml compatibility
|
||||
echo "--- # yamllint disable rule:colons
|
||||
# do not edit; generated by scwrypts
|
||||
# theme : $THEME_NAME
|
||||
colors:
|
||||
primary:
|
||||
background: '0x$BACKGROUND'
|
||||
foreground: '0x$FOREGROUND'
|
||||
cursor:
|
||||
cursor: '0x$CURSOR'
|
||||
normal:
|
||||
black: '0x$BLACK'
|
||||
red: '0x$RED'
|
||||
green: '0x$GREEN'
|
||||
yellow: '0x$YELLOW'
|
||||
blue: '0x$BLUE'
|
||||
magenta: '0x$MAGENTA'
|
||||
cyan: '0x$CYAN'
|
||||
white: '0x$WHITE'
|
||||
bright:
|
||||
black: '0x$BRIGHT_BLACK'
|
||||
red: '0x$BRIGHT_RED'
|
||||
green: '0x$BRIGHT_GREEN'
|
||||
yellow: '0x$BRIGHT_YELLOW'
|
||||
blue: '0x$BRIGHT_BLUE'
|
||||
magenta: '0x$BRIGHT_MAGENTA'
|
||||
cyan: '0x$BRIGHT_CYAN'
|
||||
white: '0x$BRIGHT_WHITE'
|
||||
" | sed '$d' > "$_COLORSCHEME_FILE__alacritty_yaml"
|
||||
|
||||
local TRANSPARENCY_OVERRIDE=$(cat "$SOURCE_THEME" | YQ -r '.alacritty.transparency' | grep -v '^null$')
|
||||
[ $TRANSPARENCY_OVERRIDE ] && {
|
||||
printf "[window]\nopacity = $TRANSPARENCY_OVERRIDE\n" >> "$_COLORSCHEME_FILE__alacritty_toml"
|
||||
printf "window:\n opacity: 0.8" >> "$_COLORSCHEME_FILE__alacritty_yaml"
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
_SET_THEME__alacritty() {
|
||||
ln -sf "$_COLORSCHEME_FILE__alacritty_toml" "$HOME/.config/alacritty/theme.toml"
|
||||
ln -sf "$_COLORSCHEME_FILE__alacritty_yaml" "$HOME/.config/alacritty/theme.yml"
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
_COLORSCHEME_FILE__getty="$ACTIVE_THEME_PATH/getty.sh"
|
||||
|
||||
_GENERATE_THEME__getty() {
|
||||
echo "#!/bin/sh
|
||||
# do not edit; generated by scwrypts
|
||||
# theme : $THEME_NAME
|
||||
#
|
||||
# source this file to apply colorscheme to linux getty
|
||||
#
|
||||
[[ \"\$TERM\" =~ ^linux$ ]] || return 0
|
||||
/bin/echo -e \" \
|
||||
\\e]P0$BACKGROUND \
|
||||
\\e]P1$RED \
|
||||
\\e]P2$GREEN \
|
||||
\\e]P3$YELLOW \
|
||||
\\e]P4$BLUE \
|
||||
\\e]P5$MAGENTA \
|
||||
\\e]P6$CYAN \
|
||||
\\e]P7$FOREGROUND \
|
||||
\\e]P8$BRIGHT_RED \
|
||||
\\e]P9$BRIGHT_GREEN \
|
||||
\\e]PA$BRIGHT_YELLOW \
|
||||
\\e]PB$BRIGHT_BLUE \
|
||||
\\e]PC$BRIGHT_MAGENTA \
|
||||
\\e]PD$BRIGHT_CYAN \
|
||||
\\e]PE$WHITE \
|
||||
\\e]PF$BRIGHT_WHITE \
|
||||
\"
|
||||
[ ! \$NO_CLEAR ] && clear
|
||||
return 0
|
||||
" sed '$d' > "$_COLORSCHEME_FILE__getty"
|
||||
}
|
||||
|
||||
_SET_THEME__getty() {
|
||||
return 0 # theme is referenced explicitly after generation
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
_COLORSCHEME_FILE__kitty="$ACTIVE_THEME_PATH/kitty.conf"
|
||||
|
||||
_GENERATE_THEME__kitty() {
|
||||
echo "# do not edit; generated by scwrypts
|
||||
# theme : $THEME_NAME
|
||||
color0 #$BLACK
|
||||
color1 #$RED
|
||||
color2 #$GREEN
|
||||
color3 #$YELLOW
|
||||
color4 #$BLUE
|
||||
color5 #$MAGENTA
|
||||
color6 #$CYAN
|
||||
color7 #$WHITE
|
||||
color8 #$BRIGHT_BLACK
|
||||
color9 #$BRIGHT_RED
|
||||
color10 #$BRIGHT_GREEN
|
||||
color11 #$BRIGHT_YELLOW
|
||||
color12 #$BRIGHT_BLUE
|
||||
color13 #$BRIGHT_MAGENTA
|
||||
color14 #$BRIGHT_CYAN
|
||||
color15 #$BRIGHT_WHITE
|
||||
cursor #$CURSOR
|
||||
background #$BACKGROUND
|
||||
foreground #$FOREGROUND
|
||||
selection_background #$SELECTION_BACKGROUND
|
||||
selection_foreground #$SELECTION_FOREGROUND
|
||||
" | sed '$d' > "$_COLORSCHEME_FILE__kitty"
|
||||
}
|
||||
|
||||
_SET_THEME__kitty() {
|
||||
ln -sf "$_COLORSCHEME_FILE__kitty" "$HOME/.config/kitty/theme.conf"
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
#####################################################################
|
||||
|
||||
DEPENDENCIES+=(
|
||||
notify-send
|
||||
)
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
#####################################################################
|
||||
|
||||
NOTIFY_SEND() { notify-send "$SCWRYPT_GROUP : $SCWRYPT_NAME" "$1"; }
|
||||
|
||||
_NOTIFY() {
|
||||
NOTIFY_SEND "$1 : ${*:2}"
|
||||
$1 ${@:2}
|
||||
}
|
||||
|
||||
NOTIFY_SUCCESS() { _NOTIFY SUCCESS $@; }
|
||||
NOTIFY_ERROR() { _NOTIFY ERROR $@; }
|
||||
NOTIFY_FAIL() { _NOTIFY FAIL $@; }
|
@ -1,65 +0,0 @@
|
||||
#####################################################################
|
||||
|
||||
DEPENDENCIES+=(
|
||||
pactl
|
||||
yq
|
||||
)
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
#####################################################################
|
||||
|
||||
PA__SET_DEFAULT_AUDIO() {
|
||||
local USAGE="
|
||||
usage: CARD_PATTERN [...options...]
|
||||
|
||||
options
|
||||
-p, --profile change profile of card (requires -i)
|
||||
-i, --id when changing profile (-p), the id of the card to change
|
||||
|
||||
--hdmi-wait wait for the hdmi card to be available before changing default
|
||||
"
|
||||
local CARD_PATTERN=()
|
||||
local CARD_PROFILE CARD_ID
|
||||
|
||||
local HDMI_WAIT=0
|
||||
|
||||
while [[ $# -gt 0 ]]
|
||||
do
|
||||
case $1 in
|
||||
--hdmi-wait ) HDMI_WAIT=1 ;;
|
||||
|
||||
--profile ) CARD_PROFILE="$2"; shift 1 ;;
|
||||
--id ) CARD_ID="$2"; shift 1 ;;
|
||||
|
||||
* ) CARD_PATTERN+=($1) ;;
|
||||
esac
|
||||
shift 1
|
||||
done
|
||||
|
||||
##########################################
|
||||
|
||||
[[ ${#CARD_PATTERN[@]} -gt 0 ]] || ERROR "no card pattern specified"
|
||||
|
||||
CHECK_ERRORS -n || return 1
|
||||
|
||||
##########################################
|
||||
|
||||
[[ $CARD_PATTERN =~ hdmi ]] && HDMI_WAIT=1
|
||||
|
||||
[[ $HDMI_WAIT -eq 1 ]] \
|
||||
&& STATUS 'waiting for hdmi sink to be available...' \
|
||||
&& until echo $(pactl list sinks 2>/dev/null | grep 'Name.*hdmi'); do sleep 1; done \
|
||||
&& SUCCESS 'hdmi sink ready!' \
|
||||
;
|
||||
|
||||
[ $CARD_ID ] && [ $CARD_PROFILE ] \
|
||||
&& STATUS "setting profile $CARD_PROFILE for card#$CARD_ID" \
|
||||
&& pactl set-card-profile $CARD_ID $CARD_PROFILE \
|
||||
&& SUCCESS "profile set" \
|
||||
;
|
||||
|
||||
STATUS "setting default audio sink to '$CARD_PATTERN'"
|
||||
pactl set-default-sink $(pactl list sinks 2>/dev/null | grep "Name.*$CARD_PATTERN" | sed 's/^\s*//' | yq -r .Name) \
|
||||
&& SUCCESS "default sink set to '$CARD_PATTERN'" \
|
||||
|| { ERROR "unable to set sink to '$CARD_PATTERN'" ; return 1; }
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
#####################################################################
|
||||
|
||||
use desktop/notify --group dotwryn
|
||||
|
||||
DEPENDENCIES+=(canberra-gtk-play)
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
#####################################################################
|
||||
|
||||
MEDIA__PLAY_SFX() {
|
||||
local SFX_FILE
|
||||
case $1 in
|
||||
volume ) SFX_FILE=$DESKTOP__SFX_PATH/yaru-message.oga ;;
|
||||
mute ) SFX_FILE=$DESKTOP__SFX_PATH/smooth-dialog-warning.oga ;;
|
||||
backlight ) SFX_FILE=$DESKTOP__SFX_PATH/yaru-audio-volume-change.oga ;;
|
||||
login ) SFX_FILE=$DESKTOP__SFX_PATH/yaru-desktop-login.oga ;;
|
||||
logout ) SFX_FILE=$DESKTOP__SFX_PATH/smooth-desktop-login.oga ;;
|
||||
notify ) SFX_FILE=$DESKTOP__SFX_PATH/yaru-complete.oga ;;
|
||||
undock ) SFX_FILE=$DESKTOP__SFX_PATH/yaru-desktop-login.oga ;;
|
||||
homedock ) SFX_FILE=$DESKTOP__SFX_PATH/homedock.oga ;;
|
||||
gamedock ) SFX_FILE=$DESKTOP__SFX_PATH/gamedock.oga ;;
|
||||
|
||||
* ) SFX_FILE="$1"
|
||||
;;
|
||||
esac
|
||||
|
||||
[ ! -f $SFX_FILE ] && SFX_FILE="$DESKTOP__SFX_PATH/$SFX_FILE"
|
||||
|
||||
[ -f $SFX_FILE ] \
|
||||
&& STATUS "detected file '$SFX_FILE'" \
|
||||
|| NOTIFY_FAIL 1 "unable to locate sfx file '$1'" \
|
||||
;
|
||||
|
||||
STATUS 'starting playback'
|
||||
canberra-gtk-play -f "$SFX_FILE" \
|
||||
&& SUCCESS "finished output of '$SFX_FILE'" \
|
||||
|| NOTIFY_FAIL 1 "something went wrong playing file '$SFX_FILE'"
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
#####################################################################
|
||||
|
||||
DEPENDENCIES+=(hostnamectl)
|
||||
REQUIRED_ENV+=(DOTWRYN)
|
||||
|
||||
#####################################################################
|
||||
|
||||
${SCWRYPTS_MODULE}setup() {
|
||||
STATUS "configuring system applications"
|
||||
local \
|
||||
APPLICATION \
|
||||
CONFIG \
|
||||
SOURCE_DIR SOURCE_CONFIG \
|
||||
SYSTEM_DIR SYSTEM_CONFIG \
|
||||
;
|
||||
|
||||
for SOURCE_DIR in $({
|
||||
find "${DOTWRYN}/config/system/" -mindepth 1 -maxdepth 1 -type d
|
||||
find "${DOTWRYN}/config/system/$(hostnamectl --static)/" -mindepth 1 -maxdepth 1 -type d
|
||||
} 2>/dev/null | sort -u)
|
||||
do
|
||||
APPLICATION="$(echo "${SOURCE_DIR}" | sed 's|.*/||')"
|
||||
case ${APPLICATION} in
|
||||
( ssh | udev )
|
||||
SYSTEM_DIR=/etc/${APPLICATION}
|
||||
;;
|
||||
( xinit )
|
||||
SYSTEM_DIR=/etc/X11/xinit/xinitrc.d/
|
||||
;;
|
||||
( * )
|
||||
SYSTEM_DIR=''
|
||||
;;
|
||||
esac
|
||||
|
||||
[ "${SYSTEM_DIR}" ] && sudo [ -d "${SYSTEM_DIR}" ] \
|
||||
|| continue
|
||||
|
||||
for CONFIG in $(cd -- "${SOURCE_DIR}"; find . -mindepth 1 -type f | sed 's|^\./||')
|
||||
do
|
||||
SOURCE_CONFIG="${SOURCE_DIR}/${CONFIG}"
|
||||
SYSTEM_CONFIG="${SYSTEM_DIR}/${CONFIG}"
|
||||
|
||||
sudo [ -f "${SYSTEM_CONFIG}" ] && {
|
||||
STATUS "already linked '${APPLICATION}/${CONFIG}'"
|
||||
continue
|
||||
}
|
||||
|
||||
sudo ln -s "${SOURCE_CONFIG}" "${SYSTEM_CONFIG}" \
|
||||
&& STATUS "linked '${APPLICATION}/${CONFIG}'" \
|
||||
|| WARNING "cannot link '${APPLICATION}/${CONFIG}'" \
|
||||
;
|
||||
done
|
||||
done
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
#
|
||||
# provides system setup utilities
|
||||
#
|
||||
|
||||
SCWRYPTS_MODULE=dotwryn.system.
|
||||
|
||||
use system/config --group dotwryn
|
23
scwrypts/dotwryn/office/latex/build-pdf
Executable file
23
scwrypts/dotwryn/office/latex/build-pdf
Executable file
@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env zsh
|
||||
use office/latex
|
||||
#####################################################################
|
||||
|
||||
MAIN() {
|
||||
[ ! $1 ] && utils.fail 1 'must provide filename'
|
||||
local FILENAME=$(dotwryn.office.latex.get-main-filename "$1")
|
||||
|
||||
local ARGS=(-interaction=nonstopmode)
|
||||
ARGS+=("$FILENAME")
|
||||
|
||||
cd "$(dirname $FILENAME)"
|
||||
|
||||
echo.status 'running compile (1/2)'
|
||||
pdflatex ${ARGS[@]} \
|
||||
|| utils.fail 2 'first compile failed (see above)'
|
||||
|
||||
echo.status 'running compile (2/2)'
|
||||
pdflatex ${ARGS[@]} >/dev/null 2>&1 \
|
||||
|| utils.fail 3 'second compile failed :c'
|
||||
|
||||
echo.success "created '$(echo $FILENAME | sed 's/\.[^.]*$/.pdf/')'"
|
||||
}
|
15
scwrypts/dotwryn/office/latex/cleanup
Executable file
15
scwrypts/dotwryn/office/latex/cleanup
Executable file
@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env zsh
|
||||
use office/latex
|
||||
#####################################################################
|
||||
|
||||
MAIN() {
|
||||
local DIRECTORY=$(SCWRYPTS__GET_REALPATH ".")
|
||||
[ $1 ] && DIRECTORY="$(dirname "$(dotwryn.office.latex.get-main-filename "$1")")"
|
||||
[ $DIRECTORY ] && [ -d $DIRECTORY ] \
|
||||
|| utils.fail 1 'unable to parse valid directory'
|
||||
|
||||
cd $DIRECTORY
|
||||
rm $(ls | grep '\.\(aux\)\|\(log\)\|\(pdf\)\|\(out\)\|\(dvi\)$')
|
||||
|
||||
echo.success "cleaned up latex artifacts in '$DIRECTORY'"
|
||||
}
|
59
scwrypts/dotwryn/office/latex/create-new
Executable file
59
scwrypts/dotwryn/office/latex/create-new
Executable file
@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env zsh
|
||||
use office/latex
|
||||
#####################################################################
|
||||
|
||||
TEMPLATE_DIR="${0:a:h}/templates"
|
||||
|
||||
MAIN() {
|
||||
local DOCUMENT_DIR="$EXECUTION_DIR"
|
||||
local TEMPLATE=$(GET_TEMPLATES | utils.fzf 'select a template')
|
||||
[ ! $TEMPLATE ] && user.abort
|
||||
echo.success "selected template '$TEMPLATE'"
|
||||
|
||||
INPUT DOC_TITLE 'document title' || user.abort
|
||||
|
||||
local DOCUMENT_FILE="$DOCUMENT_DIR/$(SLUGIFY_TITLE).tex"
|
||||
[ -f "$DOCUMENT_FILE" ] && utils.fail 1 "'$(basename $DOCUMENT_FILE)' already exists"
|
||||
|
||||
INPUT DOC_ID 'document id/subtitle'
|
||||
INPUT AUTHOR 'author name'
|
||||
INPUT AUTHOR_ID 'author id/title'
|
||||
|
||||
{
|
||||
PRINT_TITLE_INFO
|
||||
cat "$TEMPLATE_DIR/$TEMPLATE/template.tex"
|
||||
} > "$DOCUMENT_FILE"
|
||||
cp "$TEMPLATE_DIR/gitignore" "$DOCUMENT_DIR/.gitignore"
|
||||
for FILE in $(find "$TEMPLATE_DIR/$TEMPLATE" -type f | grep -v '/template.tex$')
|
||||
do
|
||||
cp "$FILE" "$DOCUMENT_DIR/" || return 2
|
||||
done
|
||||
[[ ! $TEMPLATE =~ ^basic$ ]] \
|
||||
&& mkdir "$DOCUMENT_DIR/sections" "$DOCUMENT_DIR/graphics"
|
||||
|
||||
echo.success "finished generating '$(basename $DOCUMENT_FILE)' from '$TEMPLATE'"
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
|
||||
GET_TEMPLATES() {
|
||||
find "$TEMPLATE_DIR" -type d | sed "s^$TEMPLATE_DIR/*^^; /^$/d"
|
||||
}
|
||||
|
||||
PRINT_TITLE_INFO() {
|
||||
local DATESTRING=$(date '+%B %_d, %Y' | sed 's/ \{1,\}/ /g')
|
||||
sed "
|
||||
s^LATEX-DOC-TITLE^$DOC_TITLE^
|
||||
s^LATEX-DOC-DATE^$DATESTRING^
|
||||
s^LATEX-DOC-ID^$DOC_ID^
|
||||
s^LATEX-AUTHOR-NAME^$AUTHOR^
|
||||
s^LATEX-AUTHOR-ID^$AUTHOR_ID^
|
||||
" "$TEMPLATE_DIR/main.tex"
|
||||
}
|
||||
|
||||
SLUGIFY_TITLE() {
|
||||
echo $DOC_TITLE | sed "s^['\"\\/,\!@#\$%^&*()]*^^g; s^\s\+^-^g;"
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
MAIN $@
|
@ -1,7 +1,7 @@
|
||||
#!/bin/zsh
|
||||
use desktop/pulse-audio --group dotwryn
|
||||
#!/usr/bin/env zsh
|
||||
use office/latex
|
||||
#####################################################################
|
||||
|
||||
MAIN() {
|
||||
PA__SET_DEFAULT_AUDIO $@
|
||||
dotwryn.office.latex.get-pdf $@
|
||||
}
|
44
scwrypts/dotwryn/office/latex/latex.module.zsh
Normal file
44
scwrypts/dotwryn/office/latex/latex.module.zsh
Normal file
@ -0,0 +1,44 @@
|
||||
#####################################################################
|
||||
|
||||
DEPENDENCIES+=(
|
||||
rg
|
||||
pdflatex
|
||||
)
|
||||
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
#####################################################################
|
||||
|
||||
${scwryptsmodule}.get-main-filename() {
|
||||
local FILENAME=$(SCWRYPTS__GET_REALPATH "$1")
|
||||
local DIRNAME="$FILENAME"
|
||||
|
||||
for _ in {1..3}
|
||||
do
|
||||
CHECK_IS_MAIN_LATEX_FILE && return 0
|
||||
DIRNAME="$(dirname "$FILENAME")"
|
||||
echo.status "checking '$DIRNAME'"
|
||||
[[ $DIRNAME =~ ^$HOME$ ]] && break
|
||||
FILENAME=$(
|
||||
rg -l --max-depth 1 'documentclass' "$DIRNAME/" \
|
||||
| grep '\.tex$' \
|
||||
| head -n1 \
|
||||
)
|
||||
echo.status "here is '$FILENAME'"
|
||||
done
|
||||
|
||||
echo.warning 'unable to find documentclass; pdflatex will probably fail'
|
||||
echo "$1"
|
||||
}
|
||||
|
||||
${scwryptsmodule}.check-is-main-file() {
|
||||
[ ! $FILENAME ] && return 1
|
||||
grep -q 'documentclass' $FILENAME 2>/dev/null && echo $FILENAME || return 3
|
||||
}
|
||||
|
||||
${scwryptsmodule}.get-pdf() {
|
||||
local FILENAME=$(dotwryn.office.latex.get-main-filename "$1" | sed 's/\.[^.]*$/.pdf/')
|
||||
[ $FILENAME ] && [ -f $FILENAME ] || utils.fail 1 "no compiled pdf found for '$1'; have you run 'build-pdf'?"
|
||||
echo.success 'found main pdf'
|
||||
echo $FILENAME
|
||||
}
|
10
scwrypts/dotwryn/office/latex/open-pdf
Executable file
10
scwrypts/dotwryn/office/latex/open-pdf
Executable file
@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env zsh
|
||||
use office/latex
|
||||
#####################################################################
|
||||
|
||||
MAIN() {
|
||||
local PDF=$(dotwryn.office.latex.get-pdf $@)
|
||||
[ ! $PDF ] && return 1
|
||||
|
||||
OPEN "$PDF"
|
||||
}
|
37
scwrypts/dotwryn/office/latex/templates/basic/template.tex
Normal file
37
scwrypts/dotwryn/office/latex/templates/basic/template.tex
Normal file
@ -0,0 +1,37 @@
|
||||
\usepackage[margin=.75in,bottom=0.5in,top=1.0in]{geometry}
|
||||
|
||||
\usepackage{enumitem}
|
||||
\usepackage{fancyhdr}
|
||||
\usepackage{hyperref}
|
||||
\usepackage{lastpage}
|
||||
|
||||
\newcommand{\headerL} {\documentTitle: \documentDate}
|
||||
\newcommand{\headerC} {\documentId}
|
||||
\newcommand{\headerR} {\authorName\ (\authorId)}
|
||||
\newcommand{\pageOfTotal} {\thepage\ of~\pageref{LastPage}}
|
||||
|
||||
\pagestyle{fancy}
|
||||
\fancypagestyle{plain}{%
|
||||
\fancyhf{}
|
||||
\fancyhead[L]{\headerL}\fancyhead[R]{\headerR}\fancyhead[C]{\headerC}
|
||||
\fancyfoot[C]{\pageOfTotal}
|
||||
}
|
||||
|
||||
\renewcommand{\baselinestretch}{1}
|
||||
\setlength{\parskip}{0em}
|
||||
\hyphenpenalty=5000%
|
||||
|
||||
\fancyhf{}
|
||||
\fancyhead[L]{\headerL}\fancyhead[R]{\headerR}\fancyhead[C]{\headerC}
|
||||
\fancyfoot[C]{\pageOfTotal}
|
||||
|
||||
\title{\documentTitle}
|
||||
\author{\authorName\ \\ \authorId}
|
||||
\date{\documentDate}
|
||||
|
||||
\begin{document}
|
||||
\maketitle%
|
||||
% ---------------------------------------------------------------------
|
||||
|
||||
% ---------------------------------------------------------------------
|
||||
\end{document}
|
5
scwrypts/dotwryn/office/latex/templates/gitignore
Normal file
5
scwrypts/dotwryn/office/latex/templates/gitignore
Normal file
@ -0,0 +1,5 @@
|
||||
*.aux
|
||||
*.log
|
||||
*.out
|
||||
*.pdf
|
||||
*.dvi
|
9
scwrypts/dotwryn/office/latex/templates/main.tex
Normal file
9
scwrypts/dotwryn/office/latex/templates/main.tex
Normal file
@ -0,0 +1,9 @@
|
||||
\documentclass[letterpaper]{article}
|
||||
|
||||
\newcommand{\documentTitle} {LATEX-DOC-TITLE}
|
||||
\newcommand{\documentDate} {LATEX-DOC-DATE}
|
||||
\newcommand{\documentId} {LATEX-DOC-ID}
|
||||
|
||||
\newcommand{\authorName} {LATEX-AUTHOR-NAME}
|
||||
\newcommand{\authorId} {LATEX-AUTHOR-ID}
|
||||
|
11
scwrypts/dotwryn/office/latex/templates/math/code.sty
Normal file
11
scwrypts/dotwryn/office/latex/templates/math/code.sty
Normal file
@ -0,0 +1,11 @@
|
||||
\ProvidesPackage{code}
|
||||
% ---------------------------------------------------------------------
|
||||
|
||||
\newcommand{\clispsnippet}[2]{%
|
||||
\lstinputlisting[%
|
||||
caption=#1,
|
||||
language=Lisp,
|
||||
showstringspaces=false,
|
||||
numbers=left,
|
||||
]{#2}
|
||||
}
|
46
scwrypts/dotwryn/office/latex/templates/math/formatting.sty
Normal file
46
scwrypts/dotwryn/office/latex/templates/math/formatting.sty
Normal file
@ -0,0 +1,46 @@
|
||||
\ProvidesPackage{formatting}
|
||||
% ---------------------------------------------------------------------
|
||||
|
||||
\newcommand{\headerLeft} {\documentTitle: \documentDate}
|
||||
\newcommand{\headerCenter} {\documentId}
|
||||
\newcommand{\headerRight} {\authorName\ (\authorId)}
|
||||
\newcommand{\pageOfTotal} {\thepage\ of~\pageref{LastPage}}
|
||||
|
||||
\newtheorem{theorem}{Theorem}[section]
|
||||
\newtheorem{lemma}[theorem]{Lemma}
|
||||
\newtheorem{corollary}{Corollary}[theorem]
|
||||
|
||||
\RequirePackage[margin=1in,bottom=.5in,includefoot]{geometry}
|
||||
\RequirePackage{lastpage}
|
||||
\RequirePackage{fancyhdr}
|
||||
|
||||
% ---------------------------------------------------------------------
|
||||
% Page 1
|
||||
|
||||
\pagestyle{fancy}
|
||||
\fancypagestyle{plain}{%
|
||||
\fancyhf{}
|
||||
\fancyhead[L]{\headerLeft}
|
||||
\fancyhead[R]{\headerRight}
|
||||
\fancyhead[C]{\headerCenter}
|
||||
\fancyfoot[C]{\pageOfTotal}
|
||||
}
|
||||
|
||||
\renewcommand{\baselinestretch}{1}
|
||||
\setlength{\parskip}{0em}
|
||||
\setlength{\parindent}{0em}
|
||||
|
||||
% ---------------------------------------------------------------------
|
||||
% Pages 2+
|
||||
|
||||
\fancyhf{}
|
||||
\fancyhead[L]{\headerLeft}
|
||||
\fancyhead[R]{\headerRight}
|
||||
\fancyhead[C]{\headerCenter}
|
||||
\fancyfoot[C]{\pageOfTotal}
|
||||
|
||||
% ---------------------------------------------------------------------
|
||||
|
||||
\title{\documentTitle}
|
||||
\author{\authorName\ \\ \authorId}
|
||||
\date{\documentDate}
|
16
scwrypts/dotwryn/office/latex/templates/math/imports.sty
Normal file
16
scwrypts/dotwryn/office/latex/templates/math/imports.sty
Normal file
@ -0,0 +1,16 @@
|
||||
\ProvidesPackage{imports}
|
||||
% ---------------------------------------------------------------------
|
||||
|
||||
\RequirePackage{amssymb} % "bold" math letters (e.g. set of integers ℤ)
|
||||
\RequirePackage{amsmath} % advanced math symbols
|
||||
|
||||
\RequirePackage{listings} % code snippet styling block
|
||||
|
||||
\RequirePackage{tikz} % graphic drawing / generation
|
||||
\usetikzlibrary{arrows,automata}
|
||||
\usetikzlibrary{trees}
|
||||
|
||||
\RequirePackage{graphicx} % include images
|
||||
\graphicspath{{./graphics/}}
|
||||
|
||||
\RequirePackage[english]{babel} % -- English compilation rules
|
13
scwrypts/dotwryn/office/latex/templates/math/shorthand.sty
Normal file
13
scwrypts/dotwryn/office/latex/templates/math/shorthand.sty
Normal file
@ -0,0 +1,13 @@
|
||||
\ProvidesPackage{shorthand}
|
||||
% ---------------------------------------------------------------------
|
||||
|
||||
\newcommand{\egfcoefficient}{\ensuremath{\left[\frac{x^n}{n!}\right]}}
|
||||
\newcommand{\ogfcoefficient}{\ensuremath{\left[x^n\right]}}
|
||||
\newcommand{\falling}[1]{^{\underline{#1}}}
|
||||
\newcommand{\divides}{\ensuremath{\;\backslash\;}}
|
||||
|
||||
\newcommand{\sumgz}{\ensuremath{\sum_{n\geq 0}}}
|
||||
\newcommand{\sumdiv}{\ensuremath{\sum_{d\divides n}}}
|
||||
|
||||
\newcommand{\union}{\ensuremath{\cup}}
|
||||
\newcommand{\intersect}{\ensuremath{\cap}}
|
12
scwrypts/dotwryn/office/latex/templates/math/template.tex
Normal file
12
scwrypts/dotwryn/office/latex/templates/math/template.tex
Normal file
@ -0,0 +1,12 @@
|
||||
\usepackage{imports}
|
||||
\usepackage{formatting}
|
||||
\usepackage{shorthand}
|
||||
\usepackage{code}
|
||||
|
||||
\begin{document}
|
||||
\maketitle
|
||||
% ---------------------------------------------------------------------
|
||||
% \input{sections/01.introduction.tex}
|
||||
% \includegraphic{graphics/diagram-a.png}
|
||||
% ---------------------------------------------------------------------
|
||||
\end{document}
|
@ -0,0 +1,7 @@
|
||||
\ProvidesPackage{custom-headers}
|
||||
% ---------------------------------------------------------------------
|
||||
|
||||
\newcommand{\firstH}[1] {\begin{large}\textbf{#1}\end{large}\par}
|
||||
\newcommand{\secondH}[1] {\textbf{#1}\par}
|
||||
\newcommand{\thirdH}[1] {\textbf{#1}. }
|
||||
\newcommand{\fourthH}[1] {\textbf{\textit{#1}}. }
|
@ -0,0 +1,31 @@
|
||||
\ProvidesPackage{formatting}
|
||||
% ---------------------------------------------------------------------
|
||||
|
||||
\newcommand{\horizontalHeader} {%
|
||||
\authorName\hfill
|
||||
\authorId\hfill
|
||||
\documentId\hfill
|
||||
\documentDate%
|
||||
}
|
||||
|
||||
\RequirePackage[margin=1in]{geometry}
|
||||
\RequirePackage{fancyhdr}
|
||||
|
||||
% ---------------------------------------------------------------------
|
||||
|
||||
\pagestyle{fancy}
|
||||
\renewcommand{\headrulewidth}{0pt}
|
||||
\fancyhead[C]{\horizontalHeader}
|
||||
\fancyfoot[C]{\thepage}
|
||||
|
||||
\renewcommand{\baselinestretch}{1}
|
||||
\setlength{\parskip}{1em}
|
||||
\setlength{\parindent}{0em}
|
||||
\raggedright%
|
||||
|
||||
% ---------------------------------------------------------------------
|
||||
|
||||
\newcommand{\insertTitle} {%
|
||||
\centerline{\begin{large}\textbf{\documentTitle}\end{large}}
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
\ProvidesPackage{imports}
|
||||
% ---------------------------------------------------------------------
|
||||
|
||||
\RequirePackage{times} % "Times New Roman" font
|
||||
|
||||
\RequirePackage{kantlipsum} % generate Kantian lorem ipsum
|
||||
|
||||
\RequirePackage{graphicx} % include images
|
||||
\graphicspath{{./graphics/}}
|
||||
|
||||
\RequirePackage[english]{babel} % -- English compilation rules
|
@ -0,0 +1,15 @@
|
||||
\usepackage{imports}
|
||||
\usepackage{formatting}
|
||||
\usepackage{custom-headers}
|
||||
|
||||
\begin{document}
|
||||
\insertTitle%
|
||||
% ---------------------------------------------------------------------
|
||||
|
||||
% \input{sections/abstract.tex}
|
||||
% \includgraphics{graphics/table-a.png}
|
||||
\firstH{First-level Header}
|
||||
\kant%
|
||||
|
||||
% ---------------------------------------------------------------------
|
||||
\end{document}
|
15
scwrypts/dotwryn/office/memo/memo.module.zsh
Normal file
15
scwrypts/dotwryn/office/memo/memo.module.zsh
Normal file
@ -0,0 +1,15 @@
|
||||
#####################################################################
|
||||
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
#####################################################################
|
||||
|
||||
set +o noglob
|
||||
|
||||
MEMO__FILETYPE=md
|
||||
MEMO__DIR="$SCWRYPTS_DATA_PATH/memo"
|
||||
|
||||
[ ! -d $MEMO__DIR ] && mkdir -p $MEMO__DIR
|
||||
|
||||
MEMO__LIST_ALL() { ls $MEMO__DIR | sed "s/\.$MEMO__FILETYPE$//" | sort; }
|
23
scwrypts/dotwryn/office/memo/open
Executable file
23
scwrypts/dotwryn/office/memo/open
Executable file
@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env zsh
|
||||
use office/memo
|
||||
#####################################################################
|
||||
|
||||
MAIN() {
|
||||
local MEMO_NAME=$(MEMO__LIST_ALL | FZF_USER_INPUT 'select/create a memo')
|
||||
[ ! "$MEMO_NAME" ] && user.abort
|
||||
|
||||
MEMO_FILE="$MEMO__DIR/$MEMO_NAME.$MEMO__FILETYPE"
|
||||
|
||||
[ ! -f $MEMO_FILE ] && {
|
||||
echo.status "creating memo '$MEMO_NAME'"
|
||||
echo "# $MEMO_NAME" > "$MEMO_FILE" \
|
||||
&& echo.success "created memo '$MEMO_NAME'" \
|
||||
|| utils.fail 1 "failed to create '$MEMO_FILE'" \
|
||||
;
|
||||
}
|
||||
|
||||
DATESTRING="## $(date '+%A, %B %-d, %Y')"
|
||||
grep -q "$DATESTRING" "$MEMO_FILE" || echo "$DATESTRING" >> "$MEMO_FILE"
|
||||
|
||||
utils.io.edit "$MEMO_FILE"
|
||||
}
|
25
scwrypts/dotwryn/office/memo/remove
Executable file
25
scwrypts/dotwryn/office/memo/remove
Executable file
@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env zsh
|
||||
use office/memo
|
||||
#####################################################################
|
||||
|
||||
MAIN() {
|
||||
local MEMO_NAME=$(MEMO__LIST_ALL | utils.fzf 'select a memo to delete')
|
||||
local MEMO_FILE="$MEMO__DIR/$MEMO_NAME.$MEMO__FILETYPE"
|
||||
[ "$MEMO_NAME" ] && [ -f "$MEMO_FILE" ] || user.abort
|
||||
|
||||
echo.status "--- START OF MEMO ---------------------------------------------------"
|
||||
cat "$MEMO_FILE"
|
||||
echo.status "--- END OF MEMO -----------------------------------------------------"
|
||||
|
||||
echo.warning '
|
||||
memos are not backed up by default; deletion is permanent!
|
||||
'
|
||||
|
||||
yN 'are you sure you want to delete this memo?' || user.abort
|
||||
|
||||
echo.status "deleting memo '$MEMO_FILE'"
|
||||
rm "$MEMO_FILE" \
|
||||
&& echo.success "removed memo '$MEMO_NAME'" \
|
||||
|| utils.fail 1 "failed to remove memo '$MEMO_NAME'" \
|
||||
;
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
#!/bin/zsh
|
||||
use media/audio --group dotwryn
|
||||
#!/usr/bin/env zsh
|
||||
use misc/tally
|
||||
#####################################################################
|
||||
|
||||
MAIN() {
|
||||
MEDIA__PLAY_SFX $@
|
||||
TALLY $@
|
||||
}
|
110
scwrypts/dotwryn/office/tally/tally.module.zsh
Normal file
110
scwrypts/dotwryn/office/tally/tally.module.zsh
Normal file
@ -0,0 +1,110 @@
|
||||
#####################################################################
|
||||
|
||||
DEPENDENCIES+=()
|
||||
REQUIRED_ENV+=()
|
||||
|
||||
#####################################################################
|
||||
|
||||
TALLY_USE_REDIS=false # maybe someday
|
||||
TALLY_PATH="${SCWRYPTS_DATA_PATH}/tally"
|
||||
|
||||
#####################################################################
|
||||
|
||||
${scwryptsmodule}() {
|
||||
local USAGE="
|
||||
usage: [...options...]
|
||||
|
||||
options:
|
||||
-c, --increment-count increment the tally by this much (default 1)
|
||||
-n, --tally-name name of tally system (default 'default')
|
||||
|
||||
-g, --get only output the current value
|
||||
-s, --set set the tally to a specific value
|
||||
-r, --reset set the tally back to zero
|
||||
|
||||
--raw only output the tally value
|
||||
|
||||
-h, --help print this dialogue and exit
|
||||
|
||||
Simple tally mark system; keep track of a count.
|
||||
"
|
||||
|
||||
local INCREMENT_COUNT=1
|
||||
local TALLY_NAME=default
|
||||
local RAW=false
|
||||
|
||||
local SET_VALUE=
|
||||
|
||||
while [[ $# -gt 0 ]]
|
||||
do
|
||||
case $1 in
|
||||
-c | --increment-count ) INCREMENT_COUNT=$2; shift 1 ;;
|
||||
-n | --tally-name ) TALLY_NAME=$2; shift 1 ;;
|
||||
|
||||
-g | --get ) INCREMENT_COUNT=0 ;;
|
||||
|
||||
-s | --set ) SET_VALUE=$2; shift 1 ;;
|
||||
-r | --reset ) SET_VALUE=0 ;;
|
||||
|
||||
--raw ) RAW=true ;;
|
||||
|
||||
* ) echo.error "unknown argument '$1'" ;;
|
||||
esac
|
||||
shift 1
|
||||
done
|
||||
|
||||
[ $TALLY_NAME ] && echo "$TALLY_NAME" | grep -qv '/' \
|
||||
|| echo.error "invalid tally name '$TALLY_NAME'"
|
||||
|
||||
local TALLY_FILENAME="$TALLY_PATH/$TALLY_NAME.txt"
|
||||
|
||||
utils.check-errors || return 1
|
||||
|
||||
##########################################
|
||||
|
||||
local NEW_VALUE CURRENT_VALUE=0
|
||||
[ $SET_VALUE ] && NEW_VALUE=$SET_VALUE || {
|
||||
[ -f "$TALLY_FILENAME" ] && {
|
||||
CURRENT_VALUE=$(cat "$TALLY_FILENAME" | tail -n1 | grep '^[0-9]\+')
|
||||
}
|
||||
|
||||
[ $CURRENT_VALUE ] || {
|
||||
echo.error "malformed tally file '$TALLY_FILENAME'; aborting"
|
||||
return 1
|
||||
}
|
||||
|
||||
NEW_VALUE=$(($CURRENT_VALUE + $INCREMENT_COUNT))
|
||||
}
|
||||
|
||||
##########################################
|
||||
|
||||
local TALLY_DIR="$(dirname "$TALLY_FILENAME")"
|
||||
|
||||
[ -d "$TALLY_DIR" ] || mkdir -p "$TALLY_DIR"
|
||||
[ -d "$TALLY_DIR" ] || {
|
||||
echo.error "unable to write to '$TALLY_DIR'; aborting"
|
||||
return 1
|
||||
}
|
||||
|
||||
echo "# autogenerated tally file; avoid direct modification\n$NEW_VALUE" > "$TALLY_FILENAME" || {
|
||||
echo.error "failed to write to '$TALLY_FILENAME': aborting"
|
||||
return 1
|
||||
}
|
||||
|
||||
##########################################
|
||||
|
||||
case $RAW in
|
||||
true ) printf "$NEW_VALUE" ;;
|
||||
false )
|
||||
case $TALLY_NAME in
|
||||
default ) echo.success "current tally : $NEW_VALUE" ;;
|
||||
* ) echo.success "$TALLY_NAME : $NEW_VALUE" ;;
|
||||
esac
|
||||
esac
|
||||
}
|
||||
|
||||
|
||||
#####################################################################
|
||||
|
||||
${scwryptsmodule}.parse() {
|
||||
}
|
31
scwrypts/dotwryn/office/vim/config.module.zsh
Normal file
31
scwrypts/dotwryn/office/vim/config.module.zsh
Normal file
@ -0,0 +1,31 @@
|
||||
#####################################################################
|
||||
|
||||
utils.vim() {
|
||||
utils.dependencies.check vim \
|
||||
|| return 1
|
||||
|
||||
vim $@ </dev/tty >/dev/tty;
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
|
||||
config.vim.get-config-dir() {
|
||||
local VIM_CONFIG_DIR
|
||||
|
||||
[ -d "${HOME}/.vim" ] \
|
||||
&& VIM_CONFIG_DIR="${HOME}/.vim" \
|
||||
|| VIM_CONFIG_DIR="${XDG_CONFIG_HOME:-${HOME}/.config}/vim" \
|
||||
;
|
||||
|
||||
mkdir -p -- "${VIM_CONFIG_DIR}" \
|
||||
&& echo "${VIM_CONFIG_DIR}" \
|
||||
|| echo.error "unable to determine vim config dir" \
|
||||
;
|
||||
}
|
||||
|
||||
config.vim.get-plugin-dir() {
|
||||
local VIM_CONFIG_DIR="$(config.vim.get-config-dir)"
|
||||
[ "${VIM_CONFIG_DIR}" ] || return 1
|
||||
|
||||
echo "${VIM_CONFIG_DIR}/bundle"
|
||||
}
|
7
scwrypts/dotwryn/office/vim/vim.module.zsh
Normal file
7
scwrypts/dotwryn/office/vim/vim.module.zsh
Normal file
@ -0,0 +1,7 @@
|
||||
#
|
||||
# interface with vim and vim plugins
|
||||
#
|
||||
|
||||
|
||||
# basic configuration options and utils.vim definition
|
||||
use office/vim/config --group dotwryn
|
59
scwrypts/dotwryn/office/vim/vundle/build/build.module.zsh
Normal file
59
scwrypts/dotwryn/office/vim/vundle/build/build.module.zsh
Normal file
@ -0,0 +1,59 @@
|
||||
#####################################################################
|
||||
|
||||
use office/vim/config --group dotwryn
|
||||
use office/vim/vundle/get-all --group dotwryn
|
||||
|
||||
#DEPENDENCIES+=()
|
||||
#REQUIRED_ENV+=()
|
||||
|
||||
#####################################################################
|
||||
|
||||
${scwryptsmodule}() {
|
||||
eval "$(utils.parse.autosetup)"
|
||||
##########################################
|
||||
local ORIGINAL_DIR="$(pwd)"
|
||||
local VIM_PLUGIN_DIR="$(config.vim.get-plugin-dir)"
|
||||
|
||||
local PLUGIN
|
||||
for PLUGIN in $(dotwryn.office.vim.vundle.get-all)
|
||||
do
|
||||
unset -f utils.vundle.build &>/dev/null
|
||||
|
||||
case ${PLUGIN} in
|
||||
( vim-hexokinase )
|
||||
utils.vundle.build() {
|
||||
make hexokinase
|
||||
}
|
||||
;;
|
||||
|
||||
( [yY]ou[cC]omplete[Mm]e )
|
||||
utils.vundle.build() {
|
||||
git submodule update --remote
|
||||
./install.py --all
|
||||
}
|
||||
;;
|
||||
|
||||
( * )
|
||||
continue # most plugins do not require build steps
|
||||
;;
|
||||
esac
|
||||
|
||||
cd -- "${VIM_PLUGIN_DIR}/${PLUGIN}"
|
||||
|
||||
echo.status "building '$PLUGIN'"
|
||||
utils.vundle.build \
|
||||
&& echo.success "finished building '$PLUGIN'" \
|
||||
|| echo.error "failed to build '$PLUGIN' (see above)" \
|
||||
;
|
||||
done
|
||||
|
||||
[ "${ORIGINAL_DIR}" ] && cd -- "${ORIGINAL_DIR}"
|
||||
return $ERRORS
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
|
||||
${scwryptsmodule}.parse() { return 0; }
|
||||
${scwryptsmodule}.parse.usage() {
|
||||
USAGE__description='(re)build plugins based on defined steps'
|
||||
}
|
8
scwrypts/dotwryn/office/vim/vundle/build/configure
vendored
Executable file
8
scwrypts/dotwryn/office/vim/vundle/build/configure
vendored
Executable file
@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env zsh
|
||||
#####################################################################
|
||||
|
||||
USAGE__description='adjust build steps for Vundle.vim plugins'
|
||||
|
||||
#####################################################################
|
||||
|
||||
MAIN() { utils.io.edit "$(scwrypts.config.group dotwryn root)/office/vim/vundle/build/build.module.zsh"; }
|
11
scwrypts/dotwryn/office/vim/vundle/get-all.module.zsh
Normal file
11
scwrypts/dotwryn/office/vim/vundle/get-all.module.zsh
Normal file
@ -0,0 +1,11 @@
|
||||
#####################################################################
|
||||
|
||||
use office/vim/config --group dotwryn
|
||||
|
||||
#####################################################################
|
||||
|
||||
${scwryptsmodule}() {
|
||||
find "$(config.vim.get-plugin-dir)" -mindepth 1 -maxdepth 1 -type d -exec basename {} \; \
|
||||
| grep -v '^[Vv]undle\.vim$' \
|
||||
;
|
||||
}
|
7
scwrypts/dotwryn/office/vim/vundle/update
Executable file
7
scwrypts/dotwryn/office/vim/vundle/update
Executable file
@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env zsh
|
||||
use office/vim/vundle --group dotwryn
|
||||
#####################################################################
|
||||
|
||||
dotwryn.office.vim.vundle.parse.usage
|
||||
|
||||
MAIN() { dotwryn.office.vim.vundle.update $@; }
|
40
scwrypts/dotwryn/office/vim/vundle/update.module.zsh
Normal file
40
scwrypts/dotwryn/office/vim/vundle/update.module.zsh
Normal file
@ -0,0 +1,40 @@
|
||||
#####################################################################
|
||||
|
||||
use office/vim/config --group dotwryn
|
||||
use office/vim/vundle/build --group dotwryn
|
||||
|
||||
DEPENDENCIES+=(git)
|
||||
|
||||
#####################################################################
|
||||
|
||||
${scwryptsmodule}() {
|
||||
eval "$(utils.parse.autosetup)"
|
||||
##########################################
|
||||
|
||||
local VIM_PLUGIN_DIR="$(config.vim.get-plugin-dir)"
|
||||
[ "${VIM_PLUGIN_DIR}" ] \
|
||||
|| echo.error "cannot determine vim plugin dir (see above)" \
|
||||
|| return 1
|
||||
|
||||
local VUNDLE_DIR="${VIM_PLUGIN_DIR}/Vundle.vim"
|
||||
[ -d "${VUNDLE_DIR}" ] || {
|
||||
git clone https://github.com/VundleVim/Vundle.vim.git "${VUNDLE_DIR}" \
|
||||
|| echo.error "unable to install Vundle.vim" \
|
||||
|| return 2
|
||||
}
|
||||
|
||||
utils.vim +PluginInstall +qall \
|
||||
&& echo.success 'successfully installed Vundle.vim plugins' \
|
||||
|| echo.error 'failed to install Vundle.vim plugins' \
|
||||
|| return 3
|
||||
|
||||
dotwryn.office.vim.vundle.build \
|
||||
|| return 4
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
|
||||
${scwryptsmodule}.parse() { return 0; }
|
||||
${scwryptsmodule}.parse.usage() {
|
||||
USAGE__description='update / install Vundle.vim and vim plugins'
|
||||
}
|
11
scwrypts/dotwryn/office/vim/vundle/vundle.module.zsh
Normal file
11
scwrypts/dotwryn/office/vim/vundle/vundle.module.zsh
Normal file
@ -0,0 +1,11 @@
|
||||
#
|
||||
# Vundle.vim plugin manager interface
|
||||
#
|
||||
|
||||
|
||||
# invoke :PluginInstall and vundle/rebuild (see below) from scwrypts
|
||||
use office/vim/vundle/update --group dotwryn
|
||||
|
||||
|
||||
# run custom build steps
|
||||
use office/vim/vundle/build --group dotwryn
|
@ -6,12 +6,42 @@ use system --group dotwryn
|
||||
#####################################################################
|
||||
|
||||
USAGE__description='
|
||||
sets up links to things like /etc/*.d/ configurations
|
||||
or systemd services; requires root access
|
||||
Set up symlinks to source-controlled config files, configure terminfo,
|
||||
and complete other computer setup/maintenance tasks.
|
||||
'
|
||||
|
||||
dotwryn.system.zshparse.dry-run.usage
|
||||
|
||||
#####################################################################
|
||||
|
||||
MAIN() {
|
||||
dotwryn.system.setup
|
||||
local FORWARD_ARGS=()
|
||||
local PARSERS=(dotwryn.system.zshparse.dry-run)
|
||||
eval "$(utils.parse.autosetup)"
|
||||
##########################################
|
||||
|
||||
dotwryn.system.symlinks.setup ${FORWARD_ARGS[@]} \
|
||||
|| ((ERRORS+=1))
|
||||
|
||||
dotwryn.system.terminfo.setup ${FORWARD_ARGS[@]} \
|
||||
|| ((ERRORS+=1))
|
||||
|
||||
##########################################
|
||||
|
||||
case ${DRY_RUN} in
|
||||
( true ) ;;
|
||||
( false )
|
||||
[[ ${ERRORS} -eq 0 ]] \
|
||||
&& echo.success "successfully completed system setup" \
|
||||
|| echo.error "one or more errors encountered during setup (see above)" \
|
||||
;
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
|
||||
MAIN.parse() { return 0; }
|
||||
MAIN.parse.validate() {
|
||||
[[ DRY_RUN =~ true ]] && FORWARD_ARGS+=(--dry-run)
|
||||
}
|
||||
|
6
scwrypts/dotwryn/system/symlinks/configure
vendored
Executable file
6
scwrypts/dotwryn/system/symlinks/configure
vendored
Executable file
@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env zsh
|
||||
#####################################################################
|
||||
|
||||
MAIN() {
|
||||
utils.io.edit "$(scwrypts.config.group dotwryn root)/system/symlinks/get-all.module.zsh"
|
||||
}
|
59
scwrypts/dotwryn/system/symlinks/get-all.module.zsh
Normal file
59
scwrypts/dotwryn/system/symlinks/get-all.module.zsh
Normal file
@ -0,0 +1,59 @@
|
||||
${scwryptsmodule}() {
|
||||
() { # DYNAMIC_CONFIGS
|
||||
##########################################
|
||||
|
||||
local ETC_CONFIGS
|
||||
for ETC_CONFIGS in \
|
||||
"${DOTWRYN}/config/etc" \
|
||||
"${DOTWRYN}/config/local/${DOTWRYN_HOSTNAME}/etc" \
|
||||
; # $HOST/etc will overwrite etc
|
||||
do
|
||||
find "${ETC_CONFIGS}" -mindepth 1 -type f 2>/dev/null \
|
||||
| sed "s|\(${ETC_CONFIGS}/\(.*\)\)|\\1^/etc/\\2|"
|
||||
done
|
||||
|
||||
##########################################
|
||||
|
||||
local USER_CONFIGS
|
||||
for USER_CONFIGS in \
|
||||
"${DOTWRYN}/config/user" \
|
||||
"${DOTWRYN}/config/local/${DOTWRYN_HOSTNAME}/user" \
|
||||
; # $HOST/user will overwrite user
|
||||
do
|
||||
echo.debug "$(find "${USER_CONFIGS}" -mindepth 1 -type f 2>/dev/null \
|
||||
| sed "s|\(${USER_CONFIGS}/\(.*\)\)|\\1^${XDG_CONFIG_HOME}/\\2|"
|
||||
)"
|
||||
find "${USER_CONFIGS}" -mindepth 1 -type f 2>/dev/null \
|
||||
| sed "s|\(${USER_CONFIGS}/\(.*\)\)|\\1^${XDG_CONFIG_HOME}/\\2|"
|
||||
;
|
||||
done
|
||||
|
||||
##########################################
|
||||
|
||||
local SCWRYPTS_GROUP_ENVS=(
|
||||
scwrypts
|
||||
$(find "$(scwrypts.config.group scwrypts root)/plugins" -mindepth 1 -maxdepth 1 -type d -exec basename {} \;)
|
||||
$(find "${DOTWRYN}/scwrypts" -mindepth 1 -maxdepth 1 -type d -exec basename {} \;)
|
||||
)
|
||||
|
||||
local GROUP_MATCH_REGEX="\\($(printf '\|%s' ${SCWRYPTS_GROUP_ENVS[@]} | sed 's/^\\|//')\\)"
|
||||
local LOCAL_MATCH_REGEX='\(\.'${DOTWRYN_HOSTNAME}'\(\..*\+\)*\)\?'
|
||||
|
||||
local LOCAL_DIR="${SCWRYPTS_CONFIG_PATH}/environments"
|
||||
local SOURCE_DIR="${DOTWRYN}/config/scwrypts/environments"
|
||||
|
||||
find "${DOTWRYN}/config/scwrypts/environments" -mindepth 1 -maxdepth 1 -name \*.env.yaml \
|
||||
| sed -n "s^.*/\(local${LOCAL_MATCH_REGEX}\.${GROUP_MATCH_REGEX}.env.yaml\)$${SOURCE_DIR}/\1^${LOCAL_DIR}/\1^p" \
|
||||
| grep -v '\.secret\.' \
|
||||
;
|
||||
} | column -ts '^'
|
||||
|
||||
# STATIC CONFIGS
|
||||
# ---------------------------------------------- | -------------------------------------------------
|
||||
# fully qualified source path | fully qualified target path
|
||||
# ---------------------------------------------- | -------------------------------------------------
|
||||
echo "
|
||||
${DOTWRYN}/config/scwrypts/config.zsh ${XDG_CONFIG_HOME}/scwrypts/config.zsh
|
||||
"
|
||||
|
||||
}
|
113
scwrypts/dotwryn/system/symlinks/setup.module.zsh
Normal file
113
scwrypts/dotwryn/system/symlinks/setup.module.zsh
Normal file
@ -0,0 +1,113 @@
|
||||
#####################################################################
|
||||
|
||||
use scwrypts/get-realpath
|
||||
|
||||
use system/symlinks/get-all --group dotwryn
|
||||
use system/zshparse --group dotwryn
|
||||
|
||||
#####################################################################
|
||||
|
||||
${scwryptsmodule}() {
|
||||
local PARSERS=(dotwryn.system.zshparse.dry-run)
|
||||
eval "$(utils.parse.autosetup)"
|
||||
##########################################
|
||||
local SYMLINK SOURCE_CONFIG TARGET_CONFIG SYMLINK_COUNT DRY_RUN_OUTPUT
|
||||
local SUDO_PREFIX SUDO=not-checked
|
||||
while read SYMLINK
|
||||
do
|
||||
((SYMLINK_COUNT+=1))
|
||||
SOURCE_CONFIG="$(scwrypts.get-realpath "$(echo ${SYMLINK} | awk '{print $1;}')")"
|
||||
TARGET_CONFIG="$(scwrypts.get-realpath "$(echo ${SYMLINK} | awk '{print $2;}')")"
|
||||
|
||||
[ "${SOURCE_CONFIG}" ] && [ "${TARGET_CONFIG}" ] \
|
||||
|| echo.error "bad symlink entry : ${SYMLINK}" \
|
||||
|| continue
|
||||
|
||||
case "${TARGET_CONFIG}" in
|
||||
( /etc/* )
|
||||
case ${SUDO} in
|
||||
( not-checked )
|
||||
echo.status "detected link(s) which require root access"
|
||||
utils.io.getsudo && {
|
||||
SUDO=checked
|
||||
} || {
|
||||
echo.status "skipping all links which require root access"
|
||||
SUDO=denied
|
||||
((SYMLINK_COUNT+=-1))
|
||||
continue
|
||||
}
|
||||
;;
|
||||
( denied )
|
||||
((SYMLINK_COUNT+=-1))
|
||||
continue
|
||||
;;
|
||||
( checked ) ;;
|
||||
esac
|
||||
SUDO_PREFIX="sudo "
|
||||
;;
|
||||
( * )
|
||||
SUDO_PREFIX=""
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
[[ ${DRY_RUN} =~ true ]] \
|
||||
&& DRY_RUN_OUTPUT+="\n${SUDO_PREFIX}^ln -sf --^\"${SOURCE_CONFIG}\"^\"${TARGET_CONFIG}\"^" \
|
||||
&& continue \
|
||||
;
|
||||
|
||||
: \
|
||||
&& [ ! -f "${SOURCE_CONFIG}" ] && [ ! -d "${SOURCE_CONFIG}" ] \
|
||||
&& [ ! -f "${TARGET_CONFIG}" ] && [ ! -d "${TARGET_CONFIG}" ] \
|
||||
&& echo.status "${SOURCE_CONFIG} is a new file" \
|
||||
&& mkdir -p -- "$(basename -- "${SOURCE_CONFIG}")" \
|
||||
&& touch "${SOURCE_CONFIG}" \
|
||||
;
|
||||
|
||||
: \
|
||||
&& [ ! -f "${SOURCE_CONFIG}" ] && [ ! -d "${SOURCE_CONFIG}" ] \
|
||||
&& [ -f "${TARGET_CONFIG}" ] \
|
||||
&& echo.status "${SOURCE_CONFIG} is not tracked yet; copying from ${TARGET_CONFIG}" \
|
||||
&& mkdir -p -- "$(basename -- "${SOURCE_CONFIG}")" \
|
||||
&& cp -- "${TARGET_CONFIG}" "${SOURCE_CONFIG}" \
|
||||
;
|
||||
|
||||
[ ! -f "${SOURCE_CONFIG}" ] && [ ! -d "${SOURCE_CONFIG}" ] && {
|
||||
echo.error "symlink entry is either misconfigured or requires manual intervention\n${SYMLINK}"
|
||||
continue
|
||||
}
|
||||
|
||||
: \
|
||||
&& eval "${SUDO_PREFIX}mkdir -p -- $(dirname -- "${TARGET_CONFIG}")" \
|
||||
&& eval "${SUDO_PREFIX}ln -sf -- ${SOURCE_CONFIG} ${TARGET_CONFIG}" \
|
||||
&& echo.success "successfully linked '$(echo "${TARGET_CONFIG}" | sed "s|${HOME}/||")'" \
|
||||
|| echo.error "error creating symlink\n${SYMLINK}" \
|
||||
;
|
||||
done < <(dotwryn.system.symlinks.get-all | grep '[^ ]')
|
||||
|
||||
case ${DRY_RUN} in
|
||||
( true )
|
||||
echo "${DRY_RUN_OUTPUT}" | column -ts '^'
|
||||
[[ ${ERRORS} -eq 0 ]] \
|
||||
&& echo.success "detected ${SYMLINK_COUNT} symlink(s)" \
|
||||
|| echo.error "encountered ${ERRORS} / ${SYMLINK_COUNT} symlink processing error(s)"
|
||||
;;
|
||||
|
||||
( false )
|
||||
[[ ${ERRORS} -eq 0 ]] \
|
||||
&& echo.success "successfully linked ${SYMLINK_COUNT} / ${SYMLINK_COUNT} symlink(s)" \
|
||||
|| echo.error "failed to link ${ERRORS} / ${SYMLINK_COUNT} symlink(s)" \
|
||||
;
|
||||
;;
|
||||
esac
|
||||
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
|
||||
${scwryptsmodule}.parse() { return 0; }
|
||||
${scwryptsmodule}.parse.usage() {
|
||||
USAGE__description='
|
||||
establishes all symlinks defined in dotwryn/system/user/get-all-symlinks
|
||||
'
|
||||
}
|
11
scwrypts/dotwryn/system/symlinks/symlinks.module.zsh
Normal file
11
scwrypts/dotwryn/system/symlinks/symlinks.module.zsh
Normal file
@ -0,0 +1,11 @@
|
||||
#
|
||||
# configures user-space symlinks and settings
|
||||
#
|
||||
|
||||
|
||||
# get a two-column output of all source-controlled symlinks
|
||||
use system/symlinks/get-all --group dotwryn
|
||||
|
||||
|
||||
# actually configure the target symlinks listed from the above function
|
||||
use system/symlinks/setup --group dotwryn
|
15
scwrypts/dotwryn/system/system.module.zsh
Normal file
15
scwrypts/dotwryn/system/system.module.zsh
Normal file
@ -0,0 +1,15 @@
|
||||
#
|
||||
# provides system setup utilities
|
||||
#
|
||||
|
||||
|
||||
# symlinks to source-controlled configurations
|
||||
use system/symlinks --group dotwryn
|
||||
|
||||
|
||||
# compile source-controlled terminfo files
|
||||
use system/terminfo --group dotwryn
|
||||
|
||||
|
||||
# common argument parsing
|
||||
use system/zshparse --group dotwryn
|
60
scwrypts/dotwryn/system/terminfo/setup.module.zsh
Normal file
60
scwrypts/dotwryn/system/terminfo/setup.module.zsh
Normal file
@ -0,0 +1,60 @@
|
||||
#####################################################################
|
||||
|
||||
use system/zshparse --group dotwryn
|
||||
|
||||
DEPENDENCIES+=(tic)
|
||||
|
||||
#####################################################################
|
||||
|
||||
${scwryptsmodule}() {
|
||||
local PARSERS=(dotwryn.system.zshparse.dry-run)
|
||||
eval "$(utils.parse.autosetup)"
|
||||
##########################################
|
||||
local TERMINFO_FILE TERMINFO_FILE_COUNT
|
||||
for TERMINFO_FILE in $(find "${TERMINFO_PATH}" -type f)
|
||||
do
|
||||
((TERMINFO_FILE_COUNT+=1))
|
||||
case ${DRY_RUN} in
|
||||
( true )
|
||||
echo "tic -x \"${TERMINFO_FILE}\""
|
||||
;;
|
||||
( false )
|
||||
tic -x $TERMINFO_FILE >/dev/null 2>&1 \
|
||||
&& echo.success "added '$(basename $TERMINFO_FILE)'" \
|
||||
|| echo.error "failed to add '$(basename $TERMINFO_FILE)'" \
|
||||
;
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
case ${DRY_RUN} in
|
||||
( true )
|
||||
echo.success "detected ${TERMINFO_FILE_COUNT} terminal description(s)"
|
||||
;;
|
||||
( false )
|
||||
[[ ${ERRORS} -eq 0 ]] \
|
||||
&& echo.success "successfully compiled ${TERMINFO_FILE_COUNT} / ${TERMINFO_FILE_COUNT} terminal description(s)" \
|
||||
|| echo.error "failed to compile ${ERRORS} / ${TERMINFO_FILE_COUNT} terminal description(s)" \
|
||||
;
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
#####################################################################
|
||||
|
||||
${scwryptsmodule}.parse() { return 0; }
|
||||
|
||||
${scwryptsmodule}.parse.locals() {
|
||||
local TERMINFO_PATH="${DOTWRYN}/config/terminfo"
|
||||
}
|
||||
|
||||
${scwryptsmodule}.parse.usage() {
|
||||
USAGE__description='
|
||||
compiles source-controlled terminal descriptions
|
||||
'
|
||||
}
|
||||
|
||||
${scwryptsmodule}.parse.validate() {
|
||||
[ -d "$TERMINFO_PATH" ] \
|
||||
|| echo.error "TERMINFO_PATH='$TERMINFO_PATH' does not exist"
|
||||
}
|
7
scwrypts/dotwryn/system/terminfo/terminfo.module.zsh
Normal file
7
scwrypts/dotwryn/system/terminfo/terminfo.module.zsh
Normal file
@ -0,0 +1,7 @@
|
||||
#
|
||||
# work with source-controlled, *.terminfo terminal definitions
|
||||
#
|
||||
|
||||
|
||||
# compile all source-controlled terminal definitions
|
||||
use system/terminfo/setup --group dotwryn
|
25
scwrypts/dotwryn/system/zshparse.module.zsh
Normal file
25
scwrypts/dotwryn/system/zshparse.module.zsh
Normal file
@ -0,0 +1,25 @@
|
||||
#####################################################################
|
||||
|
||||
${scwryptsmodule}.dry-run() {
|
||||
local PARSED=0
|
||||
|
||||
case $1 in
|
||||
( --dry-run ) PARSED=1; DRY_RUN=true ;;
|
||||
esac
|
||||
|
||||
return ${PARSED}
|
||||
}
|
||||
|
||||
${scwryptsmodule}.dry-run.locals() {
|
||||
local DRY_RUN=false
|
||||
}
|
||||
|
||||
|
||||
${scwryptsmodule}.dry-run.usage() {
|
||||
USAGE__options+="
|
||||
--dry-run output the commands that will be run, but don't perform any
|
||||
actions on the filesystem
|
||||
"
|
||||
}
|
||||
|
||||
#####################################################################
|
Loading…
x
Reference in New Issue
Block a user