<commit_before>#!/bin/bash

set -eufo pipefail

die() {
    echo "$0: $*" >&2
    exit 1
}

# https://apple.stackexchange.com/a/103346
val=$(ioreg -n IODisplayWrangler \
    | grep -i IOPowerManagement \
    | perl -pe 's/^.*DevicePowerState\"=([0-9]+).*$/\1/')
if [[ "$val" == "0" ]]; then
    die "screen is off"
fi

session=$(tmux list-clients | head -n1 | cut -d' ' -f2)
if [[ -z "$session" ]]; then
    die "no tmux session"
fi

tmux split-window -t "$session" rainbowterm set -as \; resize-pane -y 2
echo "changed color preset on $session"<commit_msg>Log session and preset in autorainbow.sh<commit_after>#!/bin/bash

set -eufo pipefail

die() {
    echo "$0: $*" >&2
    exit 1
}

echo "$(date): running autorainbow"

# https://apple.stackexchange.com/a/103346
val=$(ioreg -n IODisplayWrangler \
    | grep -i IOPowerManagement \
    | perl -pe 's/^.*DevicePowerState\"=([0-9]+).*$/\1/')
if [[ "$val" == "0" ]]; then
    die "screen is off"
fi

session=$(tmux list-clients | head -n1 | cut -d' ' -f2)
if [[ -z "$session" ]]; then
    die "no tmux session"
fi

tmux split-window -t "$session" rainbowterm set -as \; resize-pane -y 2
sleep 10 # wait for animation
preset=$(rainbowterm list -c)
echo "$(date): tmux session $session: changed preset to $preset"
{'fraction_non_alphanumeric': 0.1892319873317498, 'fraction_numerical': 0.026920031670625493, 'mean_word_length': 3.1716171617161715, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '453019', 'n_tokens_mistral': 521, 'n_tokens_neox': 497, 'n_words': 141}