2022-04-07 19:41:00 -05:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2022-04-22 14:15:14 -05:00
|
|
|
if [ -z "$DISPLAY" ] && [ -x "$(command -v startx)" ] && ! pgrep herbstluftwm >/dev/null; then
|
2022-04-09 08:13:45 -05:00
|
|
|
# start x if it's available and we're not already in it
|
|
|
|
startx
|
|
|
|
else
|
|
|
|
if command -v tmux &> /dev/null && [ -n "$PS1" ] && [[ ! "$TERM" =~ screen ]] && [[ ! "$TERM" =~ linux ]] && [ -z "$TMUX" ]; then
|
|
|
|
# otherwise start tmux if it's available and we're not already in it
|
|
|
|
exec tmux
|
|
|
|
else
|
|
|
|
# otherwise robot quote
|
|
|
|
if [ -x "$(command -v botsay)" ]; then
|
|
|
|
len=1642 #$(jq '. | length' ~/skynet/quotes.json)
|
|
|
|
idx=$(( RANDOM % len))
|
|
|
|
quote=()
|
|
|
|
while read -r value; do
|
|
|
|
quote+=("$value")
|
|
|
|
done < <(jq -r ".[$idx] | .quoteText, .quoteAuthor" ~/skynet/shell/quotes.json)
|
|
|
|
quoteText="${quote[0]}"
|
|
|
|
if [ -n "${quote[1]}" ]; then
|
|
|
|
quoteText="$quoteText --${quote[1]}"
|
|
|
|
fi
|
|
|
|
echo "$quoteText" | botsay -c -
|
|
|
|
fi
|
2022-04-07 19:41:00 -05:00
|
|
|
fi
|
|
|
|
fi
|