Skip to content

Commit

Permalink
Configurable application window shadow, more examples
Browse files Browse the repository at this point in the history
  • Loading branch information
joelpurra committed Jan 22, 2015
1 parent d156a57 commit a9348c5
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 14 deletions.
47 changes: 35 additions & 12 deletions README.md
@@ -1,35 +1,58 @@
# [shell-keystroke-animator](https://github.com/joelpurra/shell-keystroke-animator)

Simulate stroking keys, based on characters from `stdin`, while taking screenshots of the application window to create a `.gif` animation.

Create repeatable, editable, automatable example usage of:

- Terminal/shell programs.
- Code snippets.
- Proof-of-concept for hacks.
- Other text input.



<p align="center">
<a href="https://github.com/joelpurra/shell-keystroke-animator"><img src="https://cloud.githubusercontent.com/assets/1398544/5838453/e57ac372-a187-11e4-90f6-b2b498c457b0.gif" alt="shell-keystroke-animator Terminal demo" border="0" /></a>
<a href="https://cloud.githubusercontent.com/assets/1398544/5851864/9f8eb82e-a20d-11e4-9c05-a33de1558be3.gif">
<img src="https://cloud.githubusercontent.com/assets/1398544/5851864/9f8eb82e-a20d-11e4-9c05-a33de1558be3.gif" alt="shell-keystroke-animator Google search demo" width="50%" border="0" />
</a>
</p>

<p align="center">
<a href="https://github.com/joelpurra/shell-keystroke-animator"><img src="https://cloud.githubusercontent.com/assets/1398544/5838460/f034cda8-a187-11e4-8836-489c4ba94751.gif" alt="shell-keystroke-animator TextEdit demo" border="0" /></a>
<a href="https://github.com/joelpurra/shell-keystroke-animator">
<img src="https://cloud.githubusercontent.com/assets/1398544/5851982/9e88415a-a20f-11e4-8976-9a3fedeb54a0.gif" alt="shell-keystroke-animator Terminal demo" border="0" />
</a>
</p>

<p align="center">
<a href="https://github.com/joelpurra/npshell/"><img src="https://cloud.githubusercontent.com/assets/1398544/5836151/b8d8e31e-a171-11e4-8412-d23765b54a25.gif" alt="npshell in action" border="0" /></a>
<a href="https://github.com/joelpurra/shell-keystroke-animator">
<img src="https://cloud.githubusercontent.com/assets/1398544/5851871/cc05ff3e-a20d-11e4-9a60-cdea5c6cf346.gif" alt="shell-keystroke-animator TextEdit demo, with a shadow" border="0" />
</a>
</p>

Simulate stroking keys, based on characters from `stdin`, while taking screenshots to create a `.gif` animation.

Create repeatable, editable, automatable example usage of:
<p align="center">
<a href="https://github.com/joelpurra/shell-keystroke-animator">
<img src="https://cloud.githubusercontent.com/assets/1398544/5851868/c1023710-a20d-11e4-9a0e-fd4bd54d3b9b.gif" alt="shell-keystroke-animator TextEdit demo, without a shadow" border="0" />
</a>
</p>

- Terminal/shell programs.
- Code snippets.
- Proof-of-concept for hacks.
- Other text input.
<p align="center">
<a href="https://github.com/joelpurra/npshell/">
<img src="https://cloud.githubusercontent.com/assets/1398544/5836151/b8d8e31e-a171-11e4-8412-d23765b54a25.gif" alt="npshell in action" border="0" />
</a>
</p>



## Usage

Running the software creates a series of `.png` images, and an `output.gif`.

```bash
cat "my-keys.txt" | keystroke-animator [countdown [keysleep [linesleep]]]
cat "my-keys.txt" | keystroke-animator [--no-shadow] [countdown [keysleep [linesleep]]]
```
- `my-keys.txt` Sequence of keys/characters to "type", one by one.
- `my-keys.txt` Sequence of keys/characters to read from `stdin` and then "type", one by one.
- `--no-shadow` Turn off application window shadows (optional). Useful if the background of the window isn't white.
- `countdown` Pre-script countdown, in integer seconds (optional).
- `keysleep` Time to sleep between keys, in seconds (optional).
- `linesleep` Time to sleep between lines, in seconds (optional).
Expand Down
20 changes: 18 additions & 2 deletions src/keystroke-animator
Expand Up @@ -58,9 +58,11 @@ function animator {
filesAndSettings+=("-delay")
filesAndSettings+=("${delay}x100")
filesAndSettings+=("${file}")
filesAndSettings+=("-alpha")
filesAndSettings+=("remove")
done

convert -background "white" -flatten "${filesAndSettings[@]}" -layers "optimize" -loop 0 "$animationOutputFilename"
convert -background "white" -alpha remove "${filesAndSettings[@]}" -layers "optimize" -loop 0 "$animationOutputFilename"
}

read -d '' getActiveWindowIdOnMacScript <<-'EOF' || true
Expand All @@ -84,7 +86,13 @@ function screenshotOnMac {
shift

local activeWindowId=$(getActiveWindowId)
screencapture -o "-l${activeWindowId}" "$filename"

if [[ "$config_withShadow" == "false" ]];
then
screencapture -o "-l${activeWindowId}" "$filename"
else
screencapture "-l${activeWindowId}" "$filename"
fi
}

function screenshot {
Expand Down Expand Up @@ -146,6 +154,12 @@ function typeKeysFromStdin {
}

function keystroker {
if [[ "$1" == "--no-shadow" ]];
then
config_withShadow="false"
shift
fi

local -ri countdown="${1:-5}"
shift || true
local -r keySleep="${1:-0.05}"
Expand Down Expand Up @@ -175,4 +189,6 @@ function main {
fi
}

declare config_withShadow="true"

main "$@"

0 comments on commit a9348c5

Please sign in to comment.