Skip to content

Instantly share code, notes, and snippets.

@jarkkojs
Created July 4, 2024 14:08
Show Gist options
  • Save jarkkojs/e6808cab565045513cc5cd6fc7054b0e to your computer and use it in GitHub Desktop.
Save jarkkojs/e6808cab565045513cc5cd6fc7054b0e to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Copyright (c) Jarkko Sakkinen 2024
set -e
usage() {
>&2 cat << EOF
usage: `basename $0` [-bhp]
-b <wayland|x11> select the rendering backend
-h usage information
-p <prefix> select the installation prefix (defaults to '/usr/local')
EOF
}
opt_failed=false
opt_wayland=false
opt_x11=false
opt_prefix="$HOME/.local"
while getopts 'b:hp:' opt_name; do
case ${opt_name} in
h)
usage
exit 0
;;
b)
if [[ "wayland" == $OPTARG ]]; then
opt_wayland=true
elif [[ "x11" == $OPTARG ]]; then
opt_x11=true
else
opt_failed=true
fi
;;
p)
if [[ -d $OPTARG ]]; then
opt_prefix=$OPTARG
else
opt_failed=true
fi
;;
?)
opt_failed=true
;;
esac
if $opt_failed; then
usage
exit 1
fi
done
BUILD_DIR=`mktemp -d -t alacritty-build-XXXX`
echo $BUILD_DIR
function finish {
rm -rf $BUILD_DIR
}
trap finish EXIT
git clone https://github.com/alacritty/alacritty $BUILD_DIR
pushd $BUILD_DIR
CARGO_FLAGS="--release"
if $opt_wayland; then
cargo b $CARGO_FLAGS --no-default-features --features=wayland
elif $opt_x11; then
cargo b $CARGO_FLAGS --no-default-features --features=x11
else
cargo b $CARGO_FLAGS
fi
mkdir -p "${opt_prefix}/share/pixmaps"
cp target/release/alacritty "${opt_prefix}/bin"
cp extra/logo/alacritty-term.svg "${opt_prefix}/share/pixmaps/Alacritty.svg"
cp extra/linux/Alacritty.desktop "${opt_prefix}/share/applications/Alacritty.desktop"
update-desktop-database
popd # BUILD_DIR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment