Prevent make_me_synergy from making multiple synergyc instances for the same ip. Move synergy functions into their own file.
This commit is contained in:
parent
a1942d9761
commit
633e38e08e
@ -214,37 +214,3 @@ function set_modifier_keys_on_all_keyboards() {
|
|||||||
function get_keyboard_vendor_id_product_id_pairs() {
|
function get_keyboard_vendor_id_product_id_pairs() {
|
||||||
ioreg -n IOHIDKeyboard -r | grep -e 'class IOHIDKeyboard' -e VendorID\" -e Product | gawk 'BEGIN { RS = "class IOHIDKeyboard" } match($0, /VendorID. = ([0-9]*)/, arr) { printf arr[1]} match($0, /ProductID. = ([0-9]*)/, arr) { printf " %s\n", arr[1]} '
|
ioreg -n IOHIDKeyboard -r | grep -e 'class IOHIDKeyboard' -e VendorID\" -e Product | gawk 'BEGIN { RS = "class IOHIDKeyboard" } match($0, /VendorID. = ([0-9]*)/, arr) { printf arr[1]} match($0, /ProductID. = ([0-9]*)/, arr) { printf " %s\n", arr[1]} '
|
||||||
}
|
}
|
||||||
|
|
||||||
function make_me_synergy() {
|
|
||||||
local new_host_name="$(echo $SSH_CONNECTION | get_cols 1)"
|
|
||||||
while getopts "h:" OPTCHAR; do
|
|
||||||
case $OPTCHAR in
|
|
||||||
h)
|
|
||||||
new_host_name="$OPTARG";
|
|
||||||
return
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
synergyc $new_host_name
|
|
||||||
}
|
|
||||||
|
|
||||||
function stop_synergy_at() {
|
|
||||||
pgrep synergys | xargs kill
|
|
||||||
ssh $1 "source ~/.zshrc && clear_my_synergy"
|
|
||||||
}
|
|
||||||
|
|
||||||
function clear_all_synergy() {
|
|
||||||
pgrep synergy | xargs kill
|
|
||||||
}
|
|
||||||
|
|
||||||
function clear_my_synergy() {
|
|
||||||
clear_synergy_for_ip "$(echo $SSH_CONNECTION | get_cols 1)"
|
|
||||||
}
|
|
||||||
|
|
||||||
function clear_synergy_for_ip() {
|
|
||||||
ps aux | grep -e synergyc | grep $1 | get_cols 2 | xargs kill
|
|
||||||
}
|
|
||||||
|
|
||||||
function activate_synergy_for() {
|
|
||||||
synergys --config ~/synergy.conf && ssh $1 "source ~/.zshrc && make_me_synergy"
|
|
||||||
}
|
|
||||||
|
37
dotfiles/lib/shellrc/synergy.sh
Normal file
37
dotfiles/lib/shellrc/synergy.sh
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
function make_me_synergy() {
|
||||||
|
local new_host_name="$(echo $SSH_CONNECTION | get_cols 1)"
|
||||||
|
while getopts "h:" OPTCHAR; do
|
||||||
|
case $OPTCHAR in
|
||||||
|
h)
|
||||||
|
new_host_name="$OPTARG";
|
||||||
|
return
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
test -z $(get_synergy_pids_for_ip) && synergyc $new_host_name
|
||||||
|
}
|
||||||
|
|
||||||
|
function stop_synergy_at() {
|
||||||
|
pgrep synergys | xargs kill
|
||||||
|
ssh $1 "source ~/.zshrc && clear_my_synergy"
|
||||||
|
}
|
||||||
|
|
||||||
|
function clear_all_synergy() {
|
||||||
|
pgrep synergy | xargs kill
|
||||||
|
}
|
||||||
|
|
||||||
|
function clear_my_synergy() {
|
||||||
|
clear_synergy_for_ip "$(echo $SSH_CONNECTION | get_cols 1)"
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_synergy_pids_for_ip() {
|
||||||
|
ps aux | grep synergyc | grep $1 | get_cols 2
|
||||||
|
}
|
||||||
|
|
||||||
|
function clear_synergy_for_ip() {
|
||||||
|
get_synergy_pids_for_ip $1 | xargs kill
|
||||||
|
}
|
||||||
|
|
||||||
|
function activate_synergy_for() {
|
||||||
|
synergys --config ~/synergy.conf && ssh $1 "source ~/.zshrc && make_me_synergy"
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user