File: test-linux-global-shortcuts.sh

package info (click to toggle)
copyq 13.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 12,964 kB
  • sloc: cpp: 63,306; sh: 992; xml: 452; python: 293; ruby: 152; makefile: 27; javascript: 25
file content (54 lines) | stat: -rwxr-xr-x 1,168 bytes parent folder | download
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