2018-07-31 14:47:17 -05:00
|
|
|
#!/usr/bin/env bash
|
2018-08-27 21:35:28 -05:00
|
|
|
# Copyright 2018 rehashedsalt
|
|
|
|
# Licensed to all under the terms of the MIT License
|
2018-07-31 14:47:17 -05:00
|
|
|
|
2018-08-26 16:11:25 -05:00
|
|
|
## Clean up some variables
|
2018-08-11 17:18:15 -05:00
|
|
|
# General
|
|
|
|
unset TERMINAL
|
2018-08-27 12:02:14 -05:00
|
|
|
# Specific to these dtfscripts
|
|
|
|
unset DTF_SERVICES
|
2018-08-27 20:28:58 -05:00
|
|
|
unset DTF_TASKS
|
2018-08-01 21:21:35 -05:00
|
|
|
# Polybar
|
2018-07-31 14:47:17 -05:00
|
|
|
unset PB_MONITOR
|
2018-08-01 20:20:06 -05:00
|
|
|
unset PB_WM_RESTACK
|
|
|
|
unset PB_BAR_PRIMARY_MODULES_LEFT PB_BAR_PRIMARY_MODULES_CENTER PB_BAR_PRIMARY_MODULES_RIGHT
|
|
|
|
unset PB_BAR_PRIMARY_2_MODULES_LEFT PB_BAR_PRIMARY_2_MODULES_CENTER PB_BAR_PRIMARY_2_MODULES_RIGHT
|
|
|
|
unset PB_BAR_SECONDARY_MODULES_LEFT PB_BAR_SECONDARY_MODULES_CENTER PB_BAR_SECONDARY_MODULES_RIGHT
|
|
|
|
unset PB_BAR_SECONDARY_2_MODULES_LEFT PB_BAR_SECONDARY_2_MODULES_CENTER PB_BAR_SECONDARY_2_MODULES_RIGHT
|
|
|
|
unset PB_MODULE_BAR_WIDTH
|
2018-08-01 22:38:48 -05:00
|
|
|
unset PB_MODULE_ETH_INTERFACE
|
2018-08-01 20:20:06 -05:00
|
|
|
unset PB_MODULE_WLAN_INTERFACE
|
2018-08-01 21:21:35 -05:00
|
|
|
# bspwm monitorset.sh
|
|
|
|
unset BSPWM_DESKTOPS_TOTAL
|
|
|
|
unset BSPWM_DESKTOPS_PRIMARY
|
2018-07-31 14:47:17 -05:00
|
|
|
|
2018-08-27 21:35:28 -05:00
|
|
|
## Simple patches to get to the common environment script
|
2018-08-26 16:11:25 -05:00
|
|
|
if [[ "$XDG_CONFIG_HOME" == "" ]]; then
|
|
|
|
export XDG_CONFIG_HOME="$HOME/.config"
|
|
|
|
fi
|
2018-08-27 12:35:25 -05:00
|
|
|
export DTF_CONFIG_HOME="$XDG_CONFIG_HOME/dtfscripts"
|
2018-08-27 21:35:28 -05:00
|
|
|
source "$DTF_CONFIG_HOME/common.sh"
|
2018-07-31 15:59:17 -05:00
|
|
|
|
2018-08-26 16:11:25 -05:00
|
|
|
## Load device-specific scripts
|
2018-08-27 12:35:25 -05:00
|
|
|
if [[ -x "$DTF_CONFIG_HOME/devices/$(hostname).rc" ]]; then
|
2018-08-26 16:11:25 -05:00
|
|
|
dtf_log "Sourcing devices/$(hostname).rc"
|
|
|
|
source $HOME/.config/dtfscripts/devices/$(hostname).rc
|
2018-07-31 15:59:17 -05:00
|
|
|
fi
|
2018-08-21 22:27:38 -05:00
|
|
|
|
2018-08-27 20:28:58 -05:00
|
|
|
## Determine which tasks to run
|
|
|
|
# If DTF_TASKS is set, use that
|
|
|
|
# Otherwise, run everything
|
|
|
|
if [[ "$DTF_TASKS" == "" ]]; then
|
|
|
|
dtf_log "Performing all tasks"
|
|
|
|
for task in $DTF_TASKS_DIR/*; do
|
|
|
|
export DTF_TASKS="$DTF_TASKS $(basename "$task")"
|
|
|
|
done
|
|
|
|
else
|
|
|
|
dtf_log "Performing a subset of all tasks"
|
|
|
|
fi
|
|
|
|
|
|
|
|
## Run tasks
|
|
|
|
for task in $DTF_TASKS; do
|
|
|
|
task_full="$DTF_TASKS_DIR/$task"
|
|
|
|
(
|
|
|
|
if ! [ -r "$task_full" ]; then
|
|
|
|
dtf_log "Task is unreadable or missing: $task"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if ! [ -x "$task_full" ]; then
|
|
|
|
dtf_log "Task is unexecutable: $task"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
source "$DTF_CONFIG_HOME/common_task.sh"
|
|
|
|
source "$task_full"
|
|
|
|
)
|
|
|
|
done
|
|
|
|
|
2018-08-27 20:50:23 -05:00
|
|
|
## Determine which services to run
|
|
|
|
# Same as above
|
|
|
|
if [[ "$DTF_SERVICES" == "" ]]; then
|
|
|
|
dtf_log "Starting all available services"
|
|
|
|
for service in $DTF_SERVICES_DIR/*.dtf; do
|
|
|
|
export DTF_SERVICES="$DTF_SERVICES $(basename "$service")"
|
|
|
|
done
|
|
|
|
else
|
|
|
|
dtf_log "Starting a subset of available services"
|
|
|
|
fi
|
|
|
|
|
2018-08-26 16:11:25 -05:00
|
|
|
## Run startup scripts
|
2018-08-27 12:09:03 -05:00
|
|
|
for service in $DTF_SERVICES; do
|
2018-08-27 12:02:14 -05:00
|
|
|
service_full="$DTF_SERVICES_DIR/$service"
|
2018-08-26 16:11:25 -05:00
|
|
|
(
|
2018-08-27 12:09:03 -05:00
|
|
|
if ! [ -r "$service_full" ]; then
|
2018-08-27 12:02:14 -05:00
|
|
|
dtf_log "Service is unreadable or missing: $service"
|
|
|
|
exit 1
|
|
|
|
fi
|
2018-08-27 12:09:03 -05:00
|
|
|
if ! [ -x "$service_full" ]; then
|
2018-08-27 12:02:14 -05:00
|
|
|
dtf_log "Service is unexecutable: $service"
|
|
|
|
exit 1
|
|
|
|
fi
|
2018-08-27 12:35:25 -05:00
|
|
|
source "$DTF_CONFIG_HOME/common_service.sh"
|
|
|
|
source "$service_full"
|
2018-08-27 12:02:14 -05:00
|
|
|
if isup && [[ "$service_kill_on_reload" == "true" ]] ; then
|
|
|
|
stop
|
|
|
|
fi
|
2018-08-27 13:09:40 -05:00
|
|
|
if ! prestart; then exit 1; fi
|
|
|
|
if ! prestart-extra; then exit 1; fi
|
2018-08-27 12:02:14 -05:00
|
|
|
start
|
2018-08-27 13:09:40 -05:00
|
|
|
start-extra
|
2018-08-26 16:11:25 -05:00
|
|
|
)
|
|
|
|
done
|
2018-08-21 22:27:38 -05:00
|
|
|
|
2018-08-26 16:11:25 -05:00
|
|
|
dtf_log "Finished initialization"
|
2018-07-31 14:47:17 -05:00
|
|
|
|