From 496240dfe151a9c681da81e42ca6caca87e1abf3 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Mon, 27 Apr 2020 01:11:28 -0500 Subject: [PATCH] - Resolved inotify support for browsers --- system-config/caret_status_xkey.sh | 10 +++++----- xkeysnail-config/prexk.sh | 4 ++-- xkeysnail-config/xkeysnail.service | 4 ++-- xkeysnail-config/xkeystart.sh | 2 +- xkeysnail_service.sh | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/system-config/caret_status_xkey.sh b/system-config/caret_status_xkey.sh index 999bcb4..a405c86 100755 --- a/system-config/caret_status_xkey.sh +++ b/system-config/caret_status_xkey.sh @@ -7,7 +7,7 @@ for pid in $(pidof -x caret_status_xkey.sh); do fi done -mkdir -p /tmp/kinto +mkdir -p /tmp/kinto/xkeysnail echo "0" > /tmp/kinto/caret millitime=`date +%s%3N` @@ -58,20 +58,20 @@ while (true);do if [ "${check}" == "ff nw" ] && [ "${lastcheck}" != 1 ]; then echo "firefox no wordwise" # Sets new config - perl -pi -e "s/[^\n]\s{3}(K.*)(# Chrome-nw)/ # \$1\$2/g;s/[^\n]\s{3}#\s(K.*)(# Firefox-nw)/ \$1\$2/g;s/[^\n]\s{3}(K.*)(# Beginning of Line)/ # \$1\$2/g;s/[^\n]\s{3}(K.*)(# End of Line)/ # \$1\$2/g" /tmp/kinto/kinto.py 2>/dev/null + perl -pi -e "s/[^\n]\s{3}(K.*)(# Chrome-nw)/ # \$1\$2/g;s/[^\n]\s{3}#\s(K.*)(# Firefox-nw)/ \$1\$2/g;s/[^\n]\s{3}(K.*)(# Beginning of Line)/ # \$1\$2/g;s/[^\n]\s{3}(K.*)(# End of Line)/ # \$1\$2/g" /tmp/kinto/xkeysnail/kinto.py 2>/dev/null lastcheck=1 ww=0 elif [ "${check}" == "chrome nw" ] && [ "${lastcheck}" != 2 ]; then echo "chrome no wordwise" # Sets new config - perl -pi -e "s/[^\n]\s{3}(K.*)(# Firefox-nw)/ # \$1\$2/g;s/[^\n]\s{3}(K.*)(# Beginning of Line)/ # \$1\$2/g;s/[^\n]\s{3}(K.*)(# End of Line)/ # \$1\$2/g;s/[^\n]\s{3}#\s(K.*)(# Chrome-nw)/ \$1\$2/g" /tmp/kinto/kinto.py 2>/dev/null + perl -pi -e "s/[^\n]\s{3}(K.*)(# Firefox-nw)/ # \$1\$2/g;s/[^\n]\s{3}(K.*)(# Beginning of Line)/ # \$1\$2/g;s/[^\n]\s{3}(K.*)(# End of Line)/ # \$1\$2/g;s/[^\n]\s{3}#\s(K.*)(# Chrome-nw)/ \$1\$2/g" /tmp/kinto/xkeysnail/kinto.py 2>/dev/null lastcheck=2 ww=0 elif ([ "${check}" != "chrome nw" ] && [ "${check}" != "ff nw" ] && [ "${lastcheck}" != 3 ]) || ([ "${appname2}" != "Firefox" ] && [ "${appname2}" != "Chromium" ] && [ "${appname2}" != "Chromium-browser" ] && [ "${appname2}" != "Google-chrome" ] && [ "${appname2}" != "Epiphany" ] && [ "${check}" == "reset" ] && [ "${lastcheck}" != 3 ]); then echo "wordwise" # Sets original config - perl -pi -e "s/[^\n]\s{3}(K.*)(# Firefox-nw)/ # \$1\$2/g;s/[^\n]\s{3}#\s(K.*)(# Beginning of Line)/ \$1\$2/g;s/[^\n]\s{3}#\s(K.*)(# End of Line)/ \$1\$2/g;s/[^\n]\s{3}(K.*)(# Chrome-nw)/ # \$1\$2/g" /tmp/kinto/kinto.py 2>/dev/null - # cp /home/ryan/.config/kinto/kinto.py /tmp/kinto/kinto.py + perl -pi -e "s/[^\n]\s{3}(K.*)(# Firefox-nw)/ # \$1\$2/g;s/[^\n]\s{3}#\s(K.*)(# Beginning of Line)/ \$1\$2/g;s/[^\n]\s{3}#\s(K.*)(# End of Line)/ \$1\$2/g;s/[^\n]\s{3}(K.*)(# Chrome-nw)/ # \$1\$2/g" /tmp/kinto/xkeysnail/kinto.py 2>/dev/null + # cp /home/ryan/.config/kinto/kinto.py /tmp/kinto/xkeysnail/kinto.py lastcheck=3 fi fi diff --git a/xkeysnail-config/prexk.sh b/xkeysnail-config/prexk.sh index 484df4e..e7f00a0 100755 --- a/xkeysnail-config/prexk.sh +++ b/xkeysnail-config/prexk.sh @@ -12,5 +12,5 @@ if systemctl -q --user is-enabled keyswap; then fi # export DISPLAY={displayid};/usr/bin/xhost +SI:localuser:root -mkdir -p /tmp/kinto -cp /home/{username}/.config/kinto/kinto.py /tmp/kinto/kinto.py \ No newline at end of file +mkdir -p /tmp/kinto/xkeysnail +cp /home/{username}/.config/kinto/kinto.py /tmp/kinto/xkeysnail/kinto.py \ No newline at end of file diff --git a/xkeysnail-config/xkeysnail.service b/xkeysnail-config/xkeysnail.service index aeb9a23..0a07509 100644 --- a/xkeysnail-config/xkeysnail.service +++ b/xkeysnail-config/xkeysnail.service @@ -5,8 +5,8 @@ Description=xkeysnail Type=simple KillMode=process ExecStartPre=/bin/bash -c "{xhost} +SI:localuser:root && /sbin/runuser -l {username} -c /home/{username}/.config/kinto/prexk.sh" -ExecStart=/usr/bin/sudo /bin/bash -c '{experimental-caret}/home/{username}/.config/kinto/xkeystart.sh /tmp/kinto/kinto.py' -ExecStop=/bin/bash -c 'me=$$;ps -ef | grep \'[t]mp/kinto/kinto.py\' | awk -v me=$me \'$2 != me {print $2}\' | xargs kill;/usr/bin/killall xkeysnail;{kill-caret}' +ExecStart=/usr/bin/sudo /bin/bash -c '{experimental-caret}/home/{username}/.config/kinto/xkeystart.sh /tmp/kinto/xkeysnail/kinto.py' +ExecStop=/bin/bash -c 'me=$$;ps -ef | grep \'[t]mp/kinto/kinto.py\' | awk -v me=$me \'$2 != me {print $2}\' | xargs kill;/usr/bin/killall dbus-monitor;/usr/bin/killall xkeysnail;{kill-caret}' Restart=on-failure RestartSec=3 Environment=DISPLAY={displayid} diff --git a/xkeysnail-config/xkeystart.sh b/xkeysnail-config/xkeystart.sh index 0c25068..e590e39 100755 --- a/xkeysnail-config/xkeystart.sh +++ b/xkeysnail-config/xkeystart.sh @@ -2,7 +2,7 @@ # >/dev/null 2>&1 /usr/local/bin/xkeysnail --quiet --watch "$1" & -inotifywait -m -e close_write,moved_to,create -q "$1" | +inotifywait -m -e close_write,moved_to,create,modify /tmp/kinto/xkeysnail | while read -r path; do /usr/bin/killall xkeysnail /usr/local/bin/xkeysnail --quiet --watch "$1" & diff --git a/xkeysnail_service.sh b/xkeysnail_service.sh index 13edb37..949a4df 100755 --- a/xkeysnail_service.sh +++ b/xkeysnail_service.sh @@ -17,7 +17,7 @@ fi if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1 == "chromebook" ]]; then while true; do - read -rep $'\nExperimental Support for Firefox/Chrome Back/Forward buttons (Cmd+Left/Right)? (y/n)\n' yn + read -rep $'\nExperimental Support for Firefox/Chrome Back/Forward hotkeys (Cmd+Left/Right)?\n(Keys could get stuck, switch windows or press ctrl &/or super to release) (y/n)\n' yn case $yn in [Yy]* ) exp='/sbin/runuser -l {username} -c "export DISPLAY={displayid};/home/{username}/.config/kinto/caret_status_xkey.sh\&";'; expsh='"/home/{username}/.config/kinto/caret_status_xkey.sh"'; break;; [Nn]* ) exp=" "; expsh=" " break;; @@ -48,7 +48,7 @@ if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1 yes | cp -rf ./xkeysnail-config/xkeystart.sh ~/.config/kinto/xkeystart.sh yes | cp -rf ./xkeysnail-config/kinto.py ./xkeysnail-config/kinto.py.new yes | cp -rf ./xkeysnail-config/limitedadmins ./xkeysnail-config/limitedadmins.new - yes | cp -rf ./xkeysnail-config/prexk.sh ~/.config/kinto/prexk.sh + yes | cp -rf ./xkeysnail-config/fprexk.sh ~/.config/kinto/prexk.sh yes | cp -rf ./system-config/caret_status_xkey.sh ~/.config/kinto/caret_status_xkey.sh yes | cp -rf ./xkeysnail-config/xkeysnail.service ./xkeysnail-config/xkeysnail.service.new # yes | cp -rf ./xkeysnail-config/xkeysnail.timer ~/.config/systemd/user/xkeysnail.timer