dtfscript: Implement service logging coloration
This commit is contained in:
parent
e6b9abd2cf
commit
b15d1e61cf
@ -14,17 +14,27 @@ service_flags=""
|
|||||||
# Basic logging service. Do not override unless necessary
|
# Basic logging service. Do not override unless necessary
|
||||||
function svc_log() {
|
function svc_log() {
|
||||||
if [ -z ${1+x} ]; then return 1; fi
|
if [ -z ${1+x} ]; then return 1; fi
|
||||||
dtf_log "$service_name: $1"
|
out=1
|
||||||
|
if ! [ -z ${2+x} ]; then out="$2"; fi
|
||||||
|
col_reset="\e[0m"
|
||||||
|
col_svcname="\e[94m"
|
||||||
|
col_message="\e[39m"
|
||||||
|
if ! [ "$out" -eq "1" ]; then col_message="\e[31m"; fi
|
||||||
|
if [ "$out" -eq "0" ]; then
|
||||||
|
out=1
|
||||||
|
col_message="\e[37m"
|
||||||
|
fi
|
||||||
|
dtf_log "${col_svcname}${service_name}${col_reset}: ${col_message}${1}${col_reset}" >&${out}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Basic pre-start checks. Stick extra checks in prestart-extra
|
# Basic pre-start checks. Stick extra checks in prestart-extra
|
||||||
function prestart() {
|
function prestart() {
|
||||||
if pgrep $service_process > /dev/null 2>&1; then
|
if pgrep $service_process > /dev/null 2>&1; then
|
||||||
svc_log "Already running"
|
svc_log "Already running" 0
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
if ! which $service_process > /dev/null 2>&1; then
|
if ! which $service_process > /dev/null 2>&1; then
|
||||||
svc_log "Could not find associated binary: \"${service_process}\""
|
svc_log "Could not find associated binary: \"${service_process}\"" 2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
|
@ -11,7 +11,7 @@ service_process="sxhkd"
|
|||||||
|
|
||||||
function prestart-extra() {
|
function prestart-extra() {
|
||||||
if ! pgrep bspwm > /dev/null 2>&1; then
|
if ! pgrep bspwm > /dev/null 2>&1; then
|
||||||
svc_log "Not under bspwm"
|
svc_log "Not under bspwm" 2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
|
@ -11,7 +11,7 @@ service_process="compton"
|
|||||||
|
|
||||||
function prestart-extra() {
|
function prestart-extra() {
|
||||||
if [[ "$HOST" == "vm-*" ]]; then
|
if [[ "$HOST" == "vm-*" ]]; then
|
||||||
svc_log "Will not start: in a VM"
|
svc_log "Will not start: in a VM" 2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
|
@ -22,7 +22,7 @@ function start-extra() {
|
|||||||
if xprop -name "Conky" > /dev/null 2>&1; then break; fi
|
if xprop -name "Conky" > /dev/null 2>&1; then break; fi
|
||||||
sleep 0.01
|
sleep 0.01
|
||||||
if (( $i > 99 )); then
|
if (( $i > 99 )); then
|
||||||
svc_log "Conky may spawn behind the current desktop"
|
svc_log "Conky may spawn behind the current desktop" 2
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
Loading…
Reference in New Issue
Block a user