Skip to content
Closed
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
4 changes: 3 additions & 1 deletion install/user/xcompose.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Set default XCompose that is triggered with CapsLock
tee ~/.XCompose >/dev/null <<EOF
if [[ ! -f $HOME/.XCompose ]]; then
cat >"$HOME/.XCompose" <<EOF
# Run omarchy-restart-xcompose to apply changes

# Include fast emoji access
Expand All @@ -9,3 +10,4 @@ include "/usr/share/omarchy/default/xcompose"
<Multi_key> <space> <n> : "$OMARCHY_USER_NAME"
<Multi_key> <space> <e> : "$OMARCHY_USER_EMAIL"
EOF
fi
33 changes: 33 additions & 0 deletions test/shell.d/xcompose-install-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

set -euo pipefail

source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/base-test.sh"

xcompose_install="$ROOT/install/user/xcompose.sh"
test_dir=$(mktemp -d)
trap 'rm -rf "$test_dir"' EXIT

home="$test_dir/home"
mkdir -p "$home"

OMARCHY_USER_NAME="Example User" \
OMARCHY_USER_EMAIL="user@example.com" \
HOME="$home" \
bash -eE "$xcompose_install"

grep -qFx '<Multi_key> <space> <n> : "Example User"' "$home/.XCompose" ||
fail "XCompose install writes the user's name"
grep -qFx '<Multi_key> <space> <e> : "user@example.com"' "$home/.XCompose" ||
fail "XCompose install writes the user's email"
pass "XCompose install creates the default file with the user's identity"

printf '\n<Multi_key> <space> <x> : "custom"\n' >>"$home/.XCompose"
before=$(sha256sum "$home/.XCompose")

env -u OMARCHY_USER_NAME -u OMARCHY_USER_EMAIL HOME="$home" \
bash -eE "$xcompose_install"

[[ $(sha256sum "$home/.XCompose") == "$before" ]] ||
fail "XCompose install preserves an existing user file" "$(cat "$home/.XCompose")"
pass "XCompose install preserves user customizations on rerun"