wmstartup: Add custom service definition, leverage subshells better
This commit is contained in:
parent
c0b14dba2d
commit
c4c2cfdcc9
@ -17,7 +17,7 @@ function svc_log() {
|
||||
}
|
||||
|
||||
function prestart() {
|
||||
if pgrep $service_proccess > /dev/null 2>&1; then
|
||||
if pgrep $service_process > /dev/null 2>&1; then
|
||||
svc_log "Already running"
|
||||
return 1
|
||||
fi
|
||||
|
@ -23,6 +23,8 @@
|
||||
## Clean up some variables
|
||||
# General
|
||||
unset TERMINAL
|
||||
# Specific to these dtfscripts
|
||||
unset DTF_SERVICES
|
||||
# Polybar
|
||||
unset PB_MONITOR
|
||||
unset PB_WM_RESTACK
|
||||
@ -68,18 +70,38 @@ if [[ -x "$XDG_CONFIG_HOME/dtfscripts/devices/$(hostname).rc" ]]; then
|
||||
source $HOME/.config/dtfscripts/devices/$(hostname).rc
|
||||
fi
|
||||
|
||||
## Determine which services to run
|
||||
# If DTF_SERVICES is set, use that
|
||||
# Otherwise, populate it with every service
|
||||
if [[ "$DTF_SERVICES" == "" ]]; then
|
||||
dtf_log "Starting all available services"
|
||||
for service in $DTF_SEVICES_DIR/*.dtf; do
|
||||
export DTF_SERVICES="$DTF_SERVICES $(basename $service)"
|
||||
done
|
||||
else
|
||||
dtf_log "Starting a subset of available services"
|
||||
fi
|
||||
|
||||
## Run startup scripts
|
||||
for service in $DTF_SERVICES_DIR/*.dtf; do
|
||||
service_full="$DTF_SERVICES_DIR/$service"
|
||||
(
|
||||
source $service
|
||||
if ! prestart; then
|
||||
svc_log "Failed pre-start checks"
|
||||
else
|
||||
if isup && [[ "$service_kill_on_reload" == "true" ]] ; then
|
||||
stop
|
||||
fi
|
||||
start
|
||||
if ! [ -r $service ]; then
|
||||
dtf_log "Service is unreadable or missing: $service"
|
||||
exit 1
|
||||
fi
|
||||
if ! [ -x $service ]; then
|
||||
dtf_log "Service is unexecutable: $service"
|
||||
exit 1
|
||||
fi
|
||||
source $service
|
||||
if isup && [[ "$service_kill_on_reload" == "true" ]] ; then
|
||||
stop
|
||||
fi
|
||||
if ! prestart; then
|
||||
exit 1
|
||||
fi
|
||||
start
|
||||
)
|
||||
done
|
||||
|
||||
|
Reference in New Issue
Block a user