dtfscript: Implement log coloring for tasks and employ it
This commit is contained in:
parent
819e5534ca
commit
2b6ee96bbc
@ -9,6 +9,16 @@
|
|||||||
# Basic logging service. Do not override unless necessary
|
# Basic logging service. Do not override unless necessary
|
||||||
function tsk_log() {
|
function tsk_log() {
|
||||||
if [ -z ${1+x} ]; then return 1; fi
|
if [ -z ${1+x} ]; then return 1; fi
|
||||||
dtf_log "$task: $1"
|
out=1
|
||||||
|
if ! [ -z ${2+x} ]; then out="$2"; fi
|
||||||
|
col_reset="\e[0m"
|
||||||
|
col_tskname="\e[96m"
|
||||||
|
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_tskname}${task}${col_reset}: ${col_message}${1}${col_reset}" >&${out}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
if ! pgrep bspwm > /dev/null 2>&1; then
|
if ! pgrep bspwm > /dev/null 2>&1; then
|
||||||
tsk_log "Not under bspwm"
|
tsk_log "Not under bspwm" 1
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -20,34 +20,34 @@ desktops_secondary=$(($desktops_total - $desktops_primary))
|
|||||||
|
|
||||||
# Sanity checks
|
# Sanity checks
|
||||||
if ! [[ "$desktops_total" -ge 1 ]]; then
|
if ! [[ "$desktops_total" -ge 1 ]]; then
|
||||||
tsk_log "desktops_total cannot be $desktops_total, defaulting to 8"
|
tsk_log "desktops_total cannot be $desktops_total, defaulting to 8" 0
|
||||||
desktops_total=8
|
desktops_total=8
|
||||||
fi
|
fi
|
||||||
if ! [[ "$desktops_primary" -ge 1 ]]; then
|
if ! [[ "$desktops_primary" -ge 1 ]]; then
|
||||||
tsk_log "desktops_primary cannot be $desktops_primary, defaulting to 6"
|
tsk_log "desktops_primary cannot be $desktops_primary, defaulting to 6" 0
|
||||||
desktops_primary=6
|
desktops_primary=6
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Do we have enough desktops for all monitors?
|
# Do we have enough desktops for all monitors?
|
||||||
# We can correct this without defaulting, so don't error
|
# We can correct this without defaulting, so don't error
|
||||||
if [[ $desktops_secondary -lt ${#monitors_secondary[@]} ]]; then
|
if [[ $desktops_secondary -lt ${#monitors_secondary[@]} ]]; then
|
||||||
tsk_log "Configuration would leave some monitors without desktops; adding more"
|
tsk_log "Configuration would leave some monitors without desktops; adding more" 0
|
||||||
desktops_secondary=${#monitors_secondary[@]}
|
desktops_secondary=${#monitors_secondary[@]}
|
||||||
desktops_total=$(($desktops_secondary + $desktops_primary))
|
desktops_total=$(($desktops_secondary + $desktops_primary))
|
||||||
deskpermon=1
|
deskpermon=1
|
||||||
tsk_log "Remaining desktops set to $desktops_secondary, highest desktop is now $desktops_total"
|
tsk_log "Remaining desktops set to $desktops_secondary, highest desktop is now $desktops_total" 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Can we actually reach all of these desktops via keybinds?
|
# Can we actually reach all of these desktops via keybinds?
|
||||||
if [[ $desktops_total -gt 10 ]]; then
|
if [[ $desktops_total -gt 10 ]]; then
|
||||||
tsk_log "More than ten desktops were allocated! Not all of these can be reached via keybinds!"
|
tsk_log "More than ten desktops were allocated! Not all of these can be reached via keybinds!" 0
|
||||||
if [[ $(($desktops_total - $desktops_secondary)) -gt 0 ]]; then
|
if [[ $(($desktops_total - $desktops_secondary)) -gt 0 ]]; then
|
||||||
tsk_log "Adjusting primary desktop reservation"
|
tsk_log "Adjusting primary desktop reservation" 0
|
||||||
desktops_primary=$(($desktops_total - $desktops_secondary))
|
desktops_primary=$(($desktops_total - $desktops_secondary))
|
||||||
tsk_log "Set reserved desktops to $desktops_primary"
|
tsk_log "Set reserved desktops to $desktops_primary" 0
|
||||||
else
|
else
|
||||||
tsk_log "Cannot resolve this situation without starving the primary monitor of desktops!"
|
tsk_log "Cannot resolve this situation without starving the primary monitor of desktops!" 1
|
||||||
tsk_log "This may result in desktops being allocated that cannot be easily accessed!"
|
tsk_log "This may result in desktops being allocated that cannot be easily accessed!" 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ else
|
|||||||
tsk_log "Giving primary monitor $monitor_primary layout \"$layout\""
|
tsk_log "Giving primary monitor $monitor_primary layout \"$layout\""
|
||||||
bspc monitor $monitor_primary -d $layout
|
bspc monitor $monitor_primary -d $layout
|
||||||
unset layout
|
unset layout
|
||||||
tsk_log "Attempting to put $desktops_secondary desktops across ${#monitors_secondary[@]} monitors, $deskpermon each"
|
tsk_log "Attempting to put $desktops_secondary desktops across ${#monitors_secondary[@]} monitors, $deskpermon each" 0
|
||||||
for m in $(seq 0 $((${#monitors_secondary[@]} - 1))); do
|
for m in $(seq 0 $((${#monitors_secondary[@]} - 1))); do
|
||||||
layout=$(seq --separator=" " $((1 + $m + $desktops_primary)) ${#monitors_secondary[@]} "$desktops_total")
|
layout=$(seq --separator=" " $((1 + $m + $desktops_primary)) ${#monitors_secondary[@]} "$desktops_total")
|
||||||
tsk_log "Giving monitor $m (${monitors_secondary[$m]}) layout \"$layout\""
|
tsk_log "Giving monitor $m (${monitors_secondary[$m]}) layout \"$layout\""
|
||||||
|
@ -11,7 +11,7 @@ for i in {1..100}; do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if pgrep krunner > /dev/null 2>&1; then
|
if pgrep krunner > /dev/null 2>&1; then
|
||||||
tsk_log "Failed to kill krunner"
|
tsk_log "Failed to kill krunner" 1
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
tsk_log "Killed krunner"
|
tsk_log "Killed krunner"
|
||||||
|
@ -5,7 +5,7 @@ if [ -r ~/.Xresources ]; then
|
|||||||
fi
|
fi
|
||||||
for file in $XDG_CONFIG_HOME/xrdb/*.xresources; do
|
for file in $XDG_CONFIG_HOME/xrdb/*.xresources; do
|
||||||
if ! [ -r "$file" ]; then
|
if ! [ -r "$file" ]; then
|
||||||
tsk_log "Could not read file \"$file\""
|
tsk_log "Could not read file \"$file\"" 1
|
||||||
else
|
else
|
||||||
tsk_log "Merging in file \"$file\""
|
tsk_log "Merging in file \"$file\""
|
||||||
xrdb -merge "$file"
|
xrdb -merge "$file"
|
||||||
|
Loading…
Reference in New Issue
Block a user