2018-07-31 14:47:17 -05:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# Copyright (c) 2018 rehashedsalt/vintagesalt
|
|
|
|
#
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
# of this software and associated documentation files (the "Software"), to deal
|
|
|
|
# in the Software without restriction, including without limitation the rights
|
|
|
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
# copies of the Software, and to permit persons to whom the Software is
|
|
|
|
# furnished to do so, subject to the following conditions:
|
|
|
|
#
|
|
|
|
# The above copyright notice and this permission notice shall be included in all
|
|
|
|
# copies or substantial portions of the Software.
|
|
|
|
#
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
# SOFTWARE.
|
|
|
|
|
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-25 00:35:50 -05:00
|
|
|
# Specific to this script
|
|
|
|
unset DTF_KILL_EXTRA
|
2018-08-26 16:11:25 -05:00
|
|
|
unset DTF_SERVICES
|
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-26 16:11:25 -05:00
|
|
|
# First parameter is the indentation level
|
|
|
|
# Second is the message
|
|
|
|
function dtf_log() {
|
|
|
|
name="$(basename $0 .sh)"
|
|
|
|
if [ -z ${1+x} ]; then return 1; fi
|
|
|
|
printf "$name: $1\n"
|
|
|
|
}
|
|
|
|
|
|
|
|
## Patch some directories
|
|
|
|
if [[ "$PATH" != *"$HOME/.local/bin"* ]]; then
|
|
|
|
dtf_log "Patching path for $HOME/.local/bin"
|
2018-07-31 14:47:17 -05:00
|
|
|
export PATH="$HOME/.local/bin:$PATH"
|
|
|
|
fi
|
2018-08-26 16:11:25 -05:00
|
|
|
if [[ "$XDG_CONFIG_HOME" == "" ]]; then
|
|
|
|
dtf_log "Correcting configuration directory"
|
|
|
|
export XDG_CONFIG_HOME="$HOME/.config"
|
|
|
|
fi
|
2018-08-24 15:28:52 -05:00
|
|
|
if [[ "$XDG_RUNTIME_DIR" == "" ]]; then
|
2018-08-26 16:11:25 -05:00
|
|
|
dtf_log "Correcting runtime directory"
|
2018-08-24 15:28:52 -05:00
|
|
|
export XDG_RUNTIME_DIR="/run/user/$UID"
|
|
|
|
fi
|
|
|
|
|
2018-08-26 16:11:25 -05:00
|
|
|
## Set some more variables
|
|
|
|
export DTF_SERVICES_DIR="$XDG_CONFIG_HOME/dtfscripts/services"
|
2018-07-31 15:59:17 -05:00
|
|
|
|
2018-08-26 16:11:25 -05:00
|
|
|
## Load device-specific scripts
|
|
|
|
if [[ -x "$XDG_CONFIG_HOME/dtfscripts/devices/$(hostname).rc" ]]; then
|
|
|
|
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-26 16:11:25 -05:00
|
|
|
## Run startup scripts
|
|
|
|
for service in $DTF_SERVICES_DIR/*.dtf; do
|
|
|
|
(
|
|
|
|
source $service
|
|
|
|
if isup; then
|
|
|
|
stop
|
2018-08-21 22:27:38 -05:00
|
|
|
fi
|
2018-08-26 16:11:25 -05:00
|
|
|
start
|
|
|
|
)
|
|
|
|
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
|
|
|
|