1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
#!/bin/bash
# Tests global shortcuts on X11.
set -xeuo pipefail
export COPYQ_SESSION_NAME=__COPYQ_SHORTCUT
source "$(dirname "$0")/test-start-server.sh"
trap "kill $copyq_pid || true" QUIT TERM INT HUP EXIT
./copyq removeTab TEST || true
# register Ctrl+Alt+T to exit CopyQ
./copyq - <<EOF
setCommands(
[
{
name: "Test Command",
cmd: "copyq tab TEST add TEST",
globalShortcuts: ["ctrl+alt+t"],
isGlobalShortcut: true,
}
]
)
EOF
sleep 2
trigger_shortcut() {
xdotool \
keydown Control_L \
keydown Alt_L \
key t \
keyup Alt_L \
keyup Control_L
}
trigger_shortcut
if [[ $(./copyq tab TEST count) == 1 ]]; then
echo "✅ PASSED: Global shortcut registered: Command executed"
else
echo "❌ FAILED: Global shortcut registered: Command not executed"
exit 1
fi
# Unregister the shortcut
./copyq 'setCommands([])'
trigger_shortcut
if [[ $(./copyq tab TEST count) == 1 ]]; then
echo "✅ PASSED: Global shortcut unregistered: Command not executed"
else
echo "❌ FAILED: Global shortcut unregistered: Command executed"
exit 1
fi
|