From 6d3b5639365280d89ff672a9f4e0f30eeae0fb00 Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Wed, 16 Nov 2011 14:33:05 -0600 Subject: [PATCH] * usr/bin/byobu-modrian: - add a new, fun script --- debian/changelog | 3 +- usr/bin/byobu-modrian | 69 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100755 usr/bin/byobu-modrian diff --git a/debian/changelog b/debian/changelog index 8ed89aae..334ddd65 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,7 @@ byobu (4.49) unreleased; urgency=low - * UNRELEASED + * usr/bin/byobu-modrian: + - add a new, fun script -- Dustin Kirkland Mon, 14 Nov 2011 17:43:02 -0600 diff --git a/usr/bin/byobu-modrian b/usr/bin/byobu-modrian new file mode 100755 index 00000000..da478b6b --- /dev/null +++ b/usr/bin/byobu-modrian @@ -0,0 +1,69 @@ +#!/bin/bash +# +# byobu-modrian: randomly generate some Modrian art in tmux +# +# Copyright (C) 2011 Dustin Kirkland +# +# Authors: Dustin Kirkland +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, version 3 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +get_random_pane() { + local panes=$(tmux list-panes | wc -l) + r=$((RANDOM % 4)) + while [ $r = "$LAST_PANE" ]; do + r=$((RANDOM % 4)) + done + LAST_PANE="$r" + echo "$r" +} + +red_color=196 +yellow_color=226 +blue_color=57 +white_color=231 + +# Get number of splits +[ -n "$1" ] && TOTAL_SPLITS=$1 || TOTAL_SPLITS=10 +# Choose 1 red, 1 yellow, 1 blue +nums=$(rand -N 3 -M $TOTAL_SPLITS -u) +red=$(echo "$nums" | awk '{print $1}') +yellow=$(echo "$nums" | awk '{print $2}') +blue=$(echo "$nums" | awk '{print $3}') +directions=$(rand -N TOTAL_SPLITS -M 2) + +# Create some splits +tmux new-window -n modrian "solid_color $white_color" +tmux set-option -g pane-active-border-bg default +tmux set-option -g pane-active-border-fg default +for i in $(seq 0 $((TOTAL_SPLITS-1))); do + case $i in + $red) color=$red_color ;; + $yellow) color=$yellow_color ;; + $blue) color=$blue_color ;; + *) color=$white_color ;; + esac + CMD="solid_color $color" + case "$(head -c 10 /dev/urandom | md5sum | head -c1)" in + 0|1|2|3|4|5|6|7) SPLIT="-v" ;; + 8|9|a|b|c|d|e|f) SPLIT="-h" ;; + esac + if ! tmux split-window $SPLIT -t $(get_random_pane) "$CMD" ; then + case "$i" in + $red) red=$((red+1)) ;; + $yellow) yellow=$((yellow+1)) ;; + $blue) blue=$((blue+1)) ;; + esac + fi + #sleep 0.1 +done