path: root/static
diff options
authorAustin Adams <git@austinjadams.com>2017-08-27 20:47:17 -0400
committerAustin Adams <git@austinjadams.com>2017-08-27 20:47:17 -0400
commita9a406250c0786d7a2e4374387abc847daef9368 (patch)
treec09c46aec4c5b3cf3824f72ad73dcbaff7f7f1db /static
parent1a2b191f6d7e57a23d73d8a8e4c4c7aaf734d55d (diff)
open-circ-in-brandonsim: Add script
The page is just a bunch of commands to run anyway, so might as well add a script that runs them all in one fell swoop.
Diffstat (limited to 'static')
1 files changed, 73 insertions, 0 deletions
diff --git a/static/img/blog/open-circ-in-brandonsim/brandonsim-setup.sh b/static/img/blog/open-circ-in-brandonsim/brandonsim-setup.sh
new file mode 100755
index 0000000..8686950
--- /dev/null
+++ b/static/img/blog/open-circ-in-brandonsim/brandonsim-setup.sh
@@ -0,0 +1,73 @@
+# Give Brandonsim and .circ files a nice Brandonsim icon, and associate .circ
+# files with Brandonsim.
+# Send complaints to Austin Adams (aja@gatech.edu), not Brandon
+# More fun: https://austinjadams.com/blog/open-circ-in-brandonsim/
+set -e
+set -o pipefail
+# If first argument is provided, use it as the path to the Brandonsim jar,
+# otherwise prompt for it
+if [[ -n $1 ]]; then
+ brandonsim_jar_path=$1
+ read -r -p "Enter absolute path to Brandonsim-X.Y.Z.jar: " brandonsim_jar_path </dev/tty
+# .desktop files require an absolute path
+brandonsim_jar_path=$(readlink -f "${brandonsim_jar_path/#~/$HOME}") && \
+[[ -f $brandonsim_jar_path ]] || {
+ printf 'error: the file `%s` does not exist. Please try again.\n' "$brandonsim_jar_path" >&2
+ exit 1
+# Create directories used later
+mkdir -p ~/.local/share/applications/ ~/.local/share/mime/packages/
+# Install Brandonsim icons
+tmpfile=$(mktemp --suffix=.png)
+for size in 16 20 24 48 64 128; do
+ curl -sL https://austinjadams.com/img/blog/open-circ-in-brandonsim/brandonsim-icon-$size.png -o "$tmpfile"
+ xdg-icon-resource install --size $size "$tmpfile" brandonsim-icon
+rm "$tmpfile"
+# Register the .circ mimetype
+cat >~/.local/share/mime/packages/brandonsim.xml << EOF
+<?xml version="1.0" encoding="UTF-8"?>
+<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
+ <mime-type type="application/brandonsim">
+ <comment>Brandonsim circuit</comment>
+ <glob pattern="*.circ"/>
+ <icon name="brandonsim-icon"/>
+ </mime-type>
+update-mime-database ~/.local/share/mime
+# Install the .desktop file for Brandonsim
+cat >~/.local/share/applications/brandonsim.desktop <<EOF
+[Desktop Entry]
+GenericName=Logic circuit simulator
+Comment=Digital logic circuit simulator
+Exec=java -jar $brandonsim_jar_path %U
+# Associate the .circ mimetype with Brandonsim
+xdg-mime default brandonsim.desktop application/brandonsim
+# Remind people to log out and log back in. You might not need to do this, but
+# might as well tell people to. I think I had to restart gnome-shell at least.
+printf 'Done! Now log out and log back in\n'