-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgsconnect
executable file
·51 lines (40 loc) · 958 Bytes
/
gsconnect
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
#!/bin/bash
#!/bin/bash
set -o errexit
set -o pipefail
set -o nounset
set -o noclobber
export RED=$(tput setaf 1)
export GREEN=$(tput setaf 2)
export YELLOW=$(tput setaf 3)
export BLUE=$(tput setaf 4)
export RESET=$(tput sgr0)
debug() {
echo "${BLUE}DEBUG:${RESET} $*"
}
info() {
echo "${GREEN}INFO:${RESET} $*"
}
error() {
echo "${RED}ERROR:${RESET} $*" >&2
}
gsconnect() {
~/.local/share/gnome-shell/extensions/[email protected]/service/daemon.js "$@"
}
connected_device() {
local -r num_devs="$(gsconnect --list-devices | wc -l)"
if [[ "$num_devs" -ne 1 ]]; then
error "Found $num_devs available devices"
gsconnect --list-all
echo "Available:"
gsconnect --list-devices
exit 1
fi
gsconnect --list-devices
}
gsconnect_connected_device() {
local device
device="$(connected_device)"
gsconnect --device "$device" "$@"
}
gsconnect_connected_device "$@"