-
Notifications
You must be signed in to change notification settings - Fork 15
/
synclient
executable file
·68 lines (62 loc) · 1.67 KB
/
synclient
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env bash
# This is a shell script to start and stop the Synergy client
# Written and tested on Fedora 28
# Set some default values to be used later
# Set this IP address to the IP address of the system running Synergy server
SERVER="172.16.1.30"
# Set some help text to be displayed if needed
HELP="synclient [ start | stop | status ]"
# Check for correct parameters (exactly one sub-command expected)
if [ "$#" -ne 1 ]; then
echo "Incorrect number of parameters; please provide exactly one valid subcommand"
echo $HELP
exit 1
fi
# Set the name of the subcommand supplied by the user
CMD=$1
# Check for existence of synergy-core and get path if present
if hash synergy-core 2>/dev/null; then
SYNCMD=$(command -v synergy-core)
else
echo "synergy-core is required but not found, aborting"
exit 1
fi
# Match against the supplied subcommand
case $CMD in
start)
if pgrep -x "synergy-core" > /dev/null 2>&1; then
echo "Synergy is already running"
exit 1
else
echo "Starting Synergy..."
$SYNCMD --client $SERVER > /dev/null 2>&1
exit 0
fi
;;
stop)
echo "Stopping Synergy..."
pkill -x "synergy-core" > /dev/null 2>&1
exit 0
;;
status)
if pgrep -x "synergy-core" > /dev/null 2>&1; then
echo "Synergy is running"
exit 0
else
echo "Synergy is not running"
exit 0
fi
;;
help)
echo $HELP
exit 0
;;
--help)
echo $HELP
exit 0
;;
*)
echo "Unrecognized subcommand"
echo $HELP
exit 1
esac