mirror of
https://github.com/m-housh/dotfiles.git
synced 2026-02-14 14:12:41 +00:00
feat: Integrates logging into scripts that need it.
This commit is contained in:
22
env/.local/scripts/hypr/utils-launcher
vendored
22
env/.local/scripts/hypr/utils-launcher
vendored
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
THIS=$(basename ${BASH_SOURCE[0]})
|
||||
THIS_FILE=${BASH_SOURCE[0]}
|
||||
THIS=$(basename $THIS_FILE)
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
@@ -27,7 +28,6 @@ launch_flag="0"
|
||||
|
||||
rows=()
|
||||
invocation_id=${RANDOM}
|
||||
LOG_FILE=${LOG_FILE:-/tmp/$THIS.log}
|
||||
XDG_CONFIG_HOME=${XDG_CONFIG_HOME}
|
||||
SCRIPTS=${SCRIPTS}
|
||||
|
||||
@@ -42,15 +42,9 @@ while [[ $# -gt 0 ]]; do
|
||||
done
|
||||
|
||||
log() {
|
||||
echo "[$invocation_id]:[$($SCRIPTS/isosec)]:[$THIS]: $1" >>$LOG_FILE
|
||||
logging log --source "$THIS_FILE" "$@"
|
||||
}
|
||||
|
||||
if [[ -z $XDG_CONFIG_HOME ]]; then
|
||||
log "XDG_CONFIG_HOME not set"
|
||||
log "using ~/.config"
|
||||
XDG_CONFIG_HOME=$HOME/.config
|
||||
fi
|
||||
|
||||
launch() {
|
||||
ghostty --class=$window_class --window-padding-x=$window_padding_x \
|
||||
--keybind="ctrl+c=quit" \
|
||||
@@ -81,6 +75,16 @@ generate_rows() {
|
||||
# MAIN
|
||||
################################################################################
|
||||
|
||||
# Setup logging file and label.
|
||||
source "$SCRIPTS/hypr/logging"
|
||||
setup-logging "/tmp/$THIS.log" "$THIS"
|
||||
|
||||
if [[ -z $XDG_CONFIG_HOME ]]; then
|
||||
log "XDG_CONFIG_HOME not set"
|
||||
log "using ~/.config"
|
||||
XDG_CONFIG_HOME=$HOME/.config
|
||||
fi
|
||||
|
||||
if [[ -z $config_file ]]; then
|
||||
log "No config file set."
|
||||
log "Using ~/.config/utils-launcher/config.json"
|
||||
|
||||
Reference in New Issue
Block a user