Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Imagery and shortcut keys #5

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
Tested on Fedora Core 26 at 1600x900 resolution:

Install prerequisites:

$ dnf install lua htop mplayer sox youtube-dl

Configure gnome-terminal

Set the color scheme to (built-in) Green on Black
Set the color palette to xterm

$ perl 256color.pl

You're looking for an image like this:
![256colors](docs/example_256_color.png)

If all of the colors are visible, continue. Otherwise, you may need to
find a suitable 256-color terminal.

Install tmux from source. This may not be neccessary, but it is tested

$ git clone https://github.com/tmux/tmux
$ cd tmux
$ ./configure && make
$ make install

Install cli-visualizer

$ dnf install fftw-devel ncurses-devel pulseaudio-libs-devel
$ git clone https://github.com/dpayne/cli-visualizer
$ cd cli-visualizer
$ ./install.sh
$ cd ~
$ vis
(Verify the bars are moving while playing audio, q to exit)

Install and verify cmatrix:

$ git clone https://github.com/abishekvashok/cmatrix
$ cd cmatrix
$ autoreconf -i
$ ./configure
$ sudo make install
$ cd ~
$ cmatrix
(ctrl-c to exit)


Verify spooky:

$ lua 3spooky.lua
(Press ctrl-Z to stop, then pkill lua to terminate)

Verify hack.exe

$ ./hack.exe
(Type 'exit' to stop, then ctrl-c to terminate)

Verify hack.exe

$ ./hack.exe yahoo.com
(Type 'exit' to stop, then ctrl-c to terminate)

Verify pipes.sh

$ ./pipes.sh
(Control-C to exit)
# If you want pipes precisely like shown in the original gif, you'll
# need to install pipes from: https://github.com/pipeseroni/pipes.sh

Configure htop:

$ htop
(Press F2, In Left column, delete CPUs (1/1) [Bar]
Add CPU average from available meters to left column, it will change
it's name to just CPU [Bar])
(Press q to quit htop)

Start a new gnome-terminal window

These settings are for a 1600x900 screen resolution:

Create a new profile called "hackermode", make the following settings:
Font: monospace regular 9 point
Color scheme: green on black
Color palette: xterm
Turn off scroll bar
Turn off menu bar


12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,15 @@ An upgraded version of hack.exe
- 100% stupid

Written in C, compile with -lpthread.

**INSTALL.md**

Prerequisites and installation instructions for Fedora Core 26.

**Tmux-preload**

Example scripts for configuring starting live interactions with a single
shell file.

![Hacking is needed](docs/rice_megaman.gif)
![Daily usage Example](docs/rice_tmux_screenshot.png)
Binary file added docs/example_256_color.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/rice_megaman.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/rice_megaman_screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/rice_tmux_screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 20 additions & 10 deletions pipes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,44 @@
# On ^C, bash may give an malloc/free error
# I don't think this is an error that can be fixed easily
# in this script, but if you managed to do so, help
# would be nice.
# would be nice.

trap 'tput cnorm;clear;exit' INT HUP QUIT ABRT TERM CHLD ALRM

declare -i f=75 s=12 r=3000 t=0 c=1 n=0 l=0
declare -ir w=$(tput cols) h=$(tput lines)
declare -i x=$((w/2)) y=$((h/2))
declare -ar v=( [00]="\x83" [01]="\x8f" [03]="\x93"
[10]="\x9b" [11]="\x81" [12]="\x93"
[21]="\x97" [22]="\x83" [23]="\x9b"
[30]="\x97" [32]="\x8f" [33]="\x81" )

declare -i f=75 s=12 r=3000 t=0 c=1 n=0 l=0 d=0
OPTIND=1
while getopts "f:s:r:h" arg; do
while getopts "f:s:r:d:h" arg; do
case $arg in
f) ((f=($OPTARG>19 && $OPTARG<101)?$OPTARG:$f));;
s) ((s=($OPTARG>4 && $OPTARG<16 )?$OPTARG:$s));;
r) ((r=($OPTARG>0)?$OPTARG:$r));;
d) ((d=($OPTARG>0)?$OPTARG:$d));;
h) echo -e "Usage: pipes [OPTION]..."
echo -e "Creates an animation similar to the old \"pipes\" screensaver.\n"
echo -e " -f [20-100]\tframerate (Default 75)."
echo -e " -s [5-15]\tprobability of a straight fitting (Default 12)."
echo -e " -r LIMIT\treset after x characters (Default 3000)."
echo -e " -d 0|1 \tForce draw within an 80x25 box. "
echo -e " -h\t\thelp (This screen).\n"
exit 0;;
esac
done


# Brutal hack to force the size of the terminal for tmux panes that
# won't seem to pass the new size
if [ $d == 1 ]
then
declare -ir w=80 h=25
else
declare -ir w=$(tput cols) h=$(tput lines)
fi

declare -i x=$((w/2)) y=$((h/2))
declare -ar v=( [00]="\x83" [01]="\x8f" [03]="\x93"
[10]="\x9b" [11]="\x81" [12]="\x93"
[21]="\x97" [22]="\x83" [23]="\x9b"
[30]="\x97" [32]="\x8f" [33]="\x81" )
tput smcup
tput reset
tput civis
Expand Down
11 changes: 11 additions & 0 deletions rice-fullscreen
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
#
# Update your full path below to point to the appropriate file
#
# Then create a system wide shortcut to map to ctrl-alt-shift-h for
# hacker mode. hackermode profile is xterm palette, green on black,
# monospace regular 9 point font size, which looks good on 1600x900
# systems
cd /home/nharrington/projects/rice
exec gnome-terminal --window-with-profile=hackermode \
--full-screen -- "./rice-megaman"
63 changes: 63 additions & 0 deletions rice-megaman
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/sh
#
# This is designed to be run on a 1600x900 screen in gnome-terminal with
# Monospace Regular font at size 9 in full screen. No menubars, no
# titlebars.
#
# For maximum effect, create a shortcut key combo on your linux desktop that
# starts a new gnome-terminal in full screen mode and then executes this
# script like that shown in rice-fullscreen.
#
# Built with tmux from source commit: 968296bb

tmux new-session -d -s 'rice_hack_megaman'

tmux split-window -h 'bash' # top middle spooky

tmux split-window -h './pipes.sh -d 1 ' # top right pipes

# Those are the three main columns, now split them horizontally

tmux select-pane -t 0
tmux split-window -v 'sleep 1; ./hack.exe www.facebook.com'
tmux split-window -v 'htop'

tmux select-pane -t 3
tmux split-window -v 'cmatrix'

tmux select-pane -t 5
tmux split-window -v 'vis'
tmux split-window -v './youtube-mplayer.sh "https://www.youtube.com/watch?v=m1i00Eb4wUE"'
tmux resize-pane -U 10

# This split sleeps forever so we don't have to set the global exit on wait
tmux split-window -v 'cat ./top_half_megaman.txt; sleep 8000000000'

# At this point all panes are created with the following indexes:
# 0 top left sox noise synthesis
# 1 middle left hack.exe
# 2 bottom left htop
# 3 top middle spooky
# 4 top bottom cmatrix
# 5 top right pipes
# 6 middle right vis
# 7 bottom right cmus

# Resize the hack pane
tmux select-pane -t 1
tmux resize-pane -D 50
tmux resize-pane -L 12

# Resize the spooky center pane
tmux select-pane -t 3
tmux resize-pane -R 1

# Respawn the top left pane to play the synth command
# For that 'riding the waves of cyberspace' feeling.
tmux respawn-pane -t 0 -k 'play -n -n --combine merge synth brownnoise band -n 750 750 tremolo .1 40'

# Respawn the pane to ensure it has the right dimensions
tmux respawn-pane -t 3 -k 'echo STARTING SPOOKY; sleep 1; lua ./3spooky.lua'

# -2 forces 256 colors
tmux -2 attach-session -d -t 'rice_hack_megaman'
71 changes: 71 additions & 0 deletions rice-tmux
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/bin/sh
#
# This is designed to be run on a 1600x900 screen in gnome-terminal with
# Monospace Regular font at size 9 in full screen. No menubars, no
# titlebars.
#
# Built with tmux from source commit: 968296bb

SESSIONNAME=rice_hack

CHECK=$( tmux has-session -t $SESSIONNAME )

if [[ $? -eq 0 ]] ; then
tmux -2 attach-session -d -t "$SESSIONNAME"
exit
fi

tmux new-session -d -s $SESSIONNAME

tmux split-window -h 'bash' # top middle spooky

tmux split-window -h '~/projects/pulsemixer/pulsemixer' # top right pipes

# Those are the three main columns, now split them horizontally

tmux select-pane -t 0
tmux split-window -v 'sleep 5; ./hack.exe www.facebook.com'
tmux split-window -v 'htop'

tmux select-pane -t 3
tmux split-window -v 'cmatrix'

tmux select-pane -t 5
tmux split-window -v 'vis'
tmux split-window -v 'bash'

# At this point all panes are created with the following indexes:
# 0 top left sox noise synthesis
# 1 middle left hack.exe
# 2 bottom left htop
# 3 top middle spooky
# 4 top bottom cmatrix
# 5 top right pipes
# 6 middle right vis
# 7 bottom right cmus

# Resize the hack pane
tmux select-pane -t 1
tmux resize-pane -D 50
tmux resize-pane -L 12

# Resize the spooky center pane
tmux select-pane -t 3
tmux resize-pane -R 1

# Respawn the top left pane to play the synth command
# Solid wall of noise to block out the environment
tmux respawn-pane -t 0 -k 'play -c 2 -n synth brownnoise'

# Respawn the pane to ensure it has the right dimensions
tmux respawn-pane -t 3 -k 'echo STARTING SPOOKY; sleep 5; lua ./3spooky.lua'

# Toggle the 'full screen' size to trigger cmus to draw correctly, then
# respawn the cmus pane to get it to draw correctly:
tmux resize-pane -Z -t 7
sleep 3
tmux respawn-pane -t 7 -k 'echo "STARTING CMUS"; sleep 3; cmus'
tmux resize-pane -Z -t 7

# -2 forces 256 colors
tmux -2 attach-session -d -t $SESSIONNAME
16 changes: 16 additions & 0 deletions top_half_megaman.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

                               
                               
                               
                               
                               
                               
                               
                               
                               
                               
                               
                               
                               
                               
(B
7 changes: 7 additions & 0 deletions youtube-mplayer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
youtube-dl -q -o- "$*" | mplayer -loop 0 -vo null -af scaletempo -softvol -softvol-max 400 -cache 8192 -

# Usage:
# youtube-mplayer.sh https://www.youtube.com/watch?v=v-OS-DgxuFo
#
# From: https://gist.github.com/elFua/48f804f0994bb968c3952f3fea69bc23