From 81ecd3f03157bfd4db5cd64303df043564849c13 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Mon, 20 Apr 2020 23:50:57 -0500 Subject: [PATCH 01/48] - Added xkeysnail implementation --- .gitignore | 1 + {xkeysnail => xkeysnail-config}/kinto.py | 44 +++++++------- xkeysnail-config/prexk.sh | 12 ++++ xkeysnail-config/xkeysnail.service | 15 +++++ xkeysnail_service.sh | 77 ++++++++++++++++++++++++ 5 files changed, 127 insertions(+), 22 deletions(-) rename {xkeysnail => xkeysnail-config}/kinto.py (89%) create mode 100755 xkeysnail-config/prexk.sh create mode 100644 xkeysnail-config/xkeysnail.service create mode 100755 xkeysnail_service.sh diff --git a/.gitignore b/.gitignore index cf2069f..19075ff 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .env/ .DS_Store __pycache__/ +xkeysnail/ diff --git a/xkeysnail/kinto.py b/xkeysnail-config/kinto.py similarity index 89% rename from xkeysnail/kinto.py rename to xkeysnail-config/kinto.py index 6be9b14..944f539 100644 --- a/xkeysnail/kinto.py +++ b/xkeysnail-config/kinto.py @@ -11,15 +11,15 @@ define_conditional_modmap(lambda wm_class: wm_class not in ("Gnome-terminal","ko # Key.RIGHT_ALT: Key.RIGHT_CTRL, # Chromebook # Key.RIGHT_CTRL: Key.RIGHT_ALT, # Chromebook - # Default Mac/Win - Key.LEFT_ALT: Key.RIGHT_CTRL, # WinMac - Key.LEFT_META: Key.LEFT_ALT, # WinMac - Key.LEFT_CTRL: Key.LEFT_META, # WinMac - Key.RIGHT_ALT: Key.RIGHT_CTRL, # WinMac - Key.RIGHT_META: Key.RIGHT_ALT, # WinMac - Key.RIGHT_CTRL: Key.RIGHT_META, # WinMac + # # Default Mac/Win + # Key.LEFT_ALT: Key.RIGHT_CTRL, # WinMac + # Key.LEFT_META: Key.LEFT_ALT, # WinMac + # Key.LEFT_CTRL: Key.LEFT_META, # WinMac + # Key.RIGHT_ALT: Key.RIGHT_CTRL, # WinMac + # Key.RIGHT_META: Key.RIGHT_ALT, # WinMac + # Key.RIGHT_CTRL: Key.RIGHT_META, # WinMac - # # Mac Only + # Mac Only # Key.LEFT_META: Key.RIGHT_CTRL, # Mac # Key.LEFT_CTRL: Key.LEFT_META, # Mac # Key.RIGHT_META: Key.RIGHT_CTRL, # Mac @@ -29,20 +29,20 @@ define_conditional_modmap(lambda wm_class: wm_class not in ("Gnome-terminal","ko # [Conditional modmap] Change modifier keys in certain applications define_conditional_modmap(re.compile("Gnome-terminal|konsole|io.elementary.terminal|terminator|sakura|guake|tilda|xterm|eterm|kitty"), { # # Chromebook - # Key.LEFT_ALT: Key.RIGHT_CTRL, + # Key.LEFT_ALT: Key.RIGHT_CTRL, # Chromebook # # Left Ctrl Stays Left Ctrl - # Key.LEFT_META: Key.LEFT_ALT, - # Key.RIGHT_ALT: Key.RIGHT_CTRL, - # Key.RIGHT_CTRL: Key.RIGHT_ALT, + # Key.LEFT_META: Key.LEFT_ALT, # Chromebook + # Key.RIGHT_ALT: Key.RIGHT_CTRL, # Chromebook + # Key.RIGHT_CTRL: Key.RIGHT_ALT, # Chromebook # # Right Meta does not exist on chromebooks - # Default Mac/Win - Key.LEFT_ALT: Key.RIGHT_CTRL, # WinMac - Key.LEFT_META: Key.LEFT_ALT, # WinMac - Key.LEFT_CTRL: Key.LEFT_CTRL, # WinMac - Key.RIGHT_ALT: Key.RIGHT_CTRL, # WinMac - Key.RIGHT_META: Key.RIGHT_ALT, # WinMac - Key.RIGHT_CTRL: Key.LEFT_CTRL, # WinMac + # # Default Mac/Win + # Key.LEFT_ALT: Key.RIGHT_CTRL, # WinMac + # Key.LEFT_META: Key.LEFT_ALT, # WinMac + # Key.LEFT_CTRL: Key.LEFT_CTRL, # WinMac + # Key.RIGHT_ALT: Key.RIGHT_CTRL, # WinMac + # Key.RIGHT_META: Key.RIGHT_ALT, # WinMac + # Key.RIGHT_CTRL: Key.LEFT_CTRL, # WinMac # # Mac Only # Key.LEFT_META: Key.RIGHT_CTRL, # Mac @@ -120,11 +120,11 @@ define_keymap(None,{ K("RC-Shift-Tab"): K("RC-Shift-F13"), K("RC-Grave"): K("RC-Shift-F13"), # In-App Tab switching - # K("M-Tab"): K("C-Tab"), # Chromebook - # K("M-Shift-Tab"): K("C-Shift-Tab"), # Chromebook + # K("M-Tab"): K("C-Tab"), # Chromebook - In-App Tab switching + # K("M-Shift-Tab"): K("C-Shift-Tab"), # Chromebook - In-App Tab switching K("Super-Tab"): K("LC-Tab"), # Default K("Super-Shift-Tab"): K("LC-Shift-Tab"), # Default - K("LC-Grave") : K("LC-Shift-Tab"), # Default + K("LC-Grave") : K("LC-Shift-Tab"), # Wordwise K("RC-Left"): K("Home"), # Beginning of Line diff --git a/xkeysnail-config/prexk.sh b/xkeysnail-config/prexk.sh new file mode 100755 index 0000000..ba15330 --- /dev/null +++ b/xkeysnail-config/prexk.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +if systemctl -q --user is-enabled keyswap.timer; then + systemctl --user stop keyswap.timer + systemctl --user disable keyswap.timer +fi +if systemctl -q --user is-active keyswap; then + systemctl --user stop keyswap +fi +if systemctl -q --user is-enabled keyswap; then + systemctl --user disable keyswap +fi \ No newline at end of file diff --git a/xkeysnail-config/xkeysnail.service b/xkeysnail-config/xkeysnail.service new file mode 100644 index 0000000..b152d81 --- /dev/null +++ b/xkeysnail-config/xkeysnail.service @@ -0,0 +1,15 @@ +[Unit] +Description=xkeysnail + +[Service] +Type=simple +KillMode=process +ExecStartPre=/sbin/runuser -l {username} -c /home/{username}/.config/kinto/prexk.sh +ExecStart=/usr/bin/sudo /usr/local/bin/xkeysnail --quiet --watch /home/{username}/.config/kinto/kinto.py +ExecStop=/usr/bin/sudo /usr/bin/killall xkeysnail +Restart=on-failure +RestartSec=3 +Environment=DISPLAY={displayid} + +[Install] +WantedBy=graphical.target \ No newline at end of file diff --git a/xkeysnail_service.sh b/xkeysnail_service.sh new file mode 100755 index 0000000..548fca4 --- /dev/null +++ b/xkeysnail_service.sh @@ -0,0 +1,77 @@ +#!/bin/bash + + +if [ $# -eq 0 ]; then + echo "Install Kinto - xkeysnail (udev)" + echo " 1) Windows & Mac (HID driver)" + echo " 2) Mac Only & VMs on Macbooks" + echo " 3) Chromebook" + + read n + + set "$n" +fi + +if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1 == "chromebook" ]]; then + # echo "Transferring files..." + mkdir -p ~/.config/kinto + + # KDE xhost fix + mkdir -p ~/.kde/Autostart + echo -e '#!/bin/sh\rxhost +SI:localuser:root' > ~/.kde/Autostart/kintohost.sh + chmod +x ~/.kde/Autostart/kintohost.sh + + cp ./xkeysnail-config/kinto.py ./xkeysnail-config/kinto.py.new + cp ./xkeysnail-config/prexk.sh ~/.config/kinto/prexk.sh + cp ./xkeysnail-config/xkeysnail.service ./xkeysnail-config/xkeysnail.service.new + sed -i "s/{username}/`whoami`/g" ./xkeysnail-config/xkeysnail.service.new + sed -i "s/{displayid}/`echo "$DISPLAY"`/g" ./xkeysnail-config/xkeysnail.service.new +else + echo "Expected argument was not provided" +fi + +if [[ $1 == "1" || $1 == "winmac" ]]; then + echo '1' | sudo tee -a /sys/module/hid_apple/parameters/swap_opt_cmd;echo 'options hid_apple swap_opt_cmd=1' | sudo tee -a /etc/modprobe.d/hid_apple.conf;sudo update-initramfs -u -k all + perl -pi -e "s/(# )(.*)(# WinMac)/\$2\$3/g" ./xkeysnail-config/kinto.py.new +elif [[ $1 == "2" || $1 == "mac" ]]; then + perl -pi -e "s/(# )(.*)(# Mac)/\$2\$3/g" ./xkeysnail-config/kinto.py.new +elif [[ $1 == "3" || $1 == "chromebook" ]]; then + perl -pi -e "s/(# )(.*)(# Chromebook)/\$2\$3/g" ./xkeysnail-config/kinto.py.new + perl -pi -e "s/(\w.*)(# Default)/# \$1\$2/g" ./xkeysnail-config/kinto.py.new +fi + +if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1 == "chromebook" ]]; then + mv ./xkeysnail-config/kinto.py.new ~/.config/kinto/kinto.py + sudo mv ./xkeysnail-config/xkeysnail.service.new /etc/systemd/system/xkeysnail.service + git clone --depth 1 https://github.com/rbreaves/xkeysnail.git + cd xkeysnail + sudo pip3 install --upgrade . + sudo systemctl enable xkeysnail + sudo systemctl daemon-reload + sudo systemctl start xkeysnail + + echo "Adding xhost fix..." + + # KDE startup - xhost fix + cp ./xkeysnail-config/xkeysnail.desktop ~/.config/autostart/xkeysnail.desktop + + LINE='xhost +SI:localuser:root' + + if [ ! -e "~/.xprofile" ]; then + # Ubuntu xhost fix + echo "$LINE" > ~/.xprofile + # echo "$LINE" > ~/.xinitrc + fi + # Ubuntu xhost fix + grep -qF -- "$LINE" ~/.xprofile || echo "$LINE" >> ~/.xprofile + # KDE xhost fix + # grep -qF -- "$LINE" ~/.bashrc || echo "$LINE" >> ~/.bashrc + # grep -qF -- "$LINE" ~/.xinitrc || echo "$LINE" >> ~/.xinitrc + + # remove kintox11 login startup + rm ~/.config/autostart/kinto.desktop +else + echo "Expected argument was not provided" +fi + + From 3b802d1d492e84e68ffd2be78498f225d5b36434 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Tue, 21 Apr 2020 16:17:32 -0500 Subject: [PATCH 02/48] - Added xhost fix to the xkey service setup file --- xkeysnail_service.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xkeysnail_service.sh b/xkeysnail_service.sh index 548fca4..3f7f9ae 100755 --- a/xkeysnail_service.sh +++ b/xkeysnail_service.sh @@ -1,5 +1,7 @@ #!/bin/bash +# set about:config?filter=ui.key.menuAccessKeyFocuses +# to false for wordwise to work in Firefox if [ $# -eq 0 ]; then echo "Install Kinto - xkeysnail (udev)" @@ -43,6 +45,7 @@ fi if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1 == "chromebook" ]]; then mv ./xkeysnail-config/kinto.py.new ~/.config/kinto/kinto.py sudo mv ./xkeysnail-config/xkeysnail.service.new /etc/systemd/system/xkeysnail.service + xhost +SI:localuser:root git clone --depth 1 https://github.com/rbreaves/xkeysnail.git cd xkeysnail sudo pip3 install --upgrade . From c1e2db9a2e76b91288e4cd638b3f114c136380e0 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Tue, 21 Apr 2020 17:39:20 -0500 Subject: [PATCH 03/48] - Updated xkeysnail installer to properly copy desktop autostart and to restart service on config file changes --- system-config/unipkg.sh | 21 +++++++++++++++++++++ xkeysnail-config/xkeysnail.desktop | 8 ++++++++ xkeysnail-config/xkeysnail.service | 2 +- xkeysnail-config/xkeystart.sh | 8 ++++++++ xkeysnail_service.sh | 17 +++++++++++------ 5 files changed, 49 insertions(+), 7 deletions(-) create mode 100755 system-config/unipkg.sh create mode 100644 xkeysnail-config/xkeysnail.desktop create mode 100755 xkeysnail-config/xkeystart.sh diff --git a/system-config/unipkg.sh b/system-config/unipkg.sh new file mode 100755 index 0000000..fe69aa8 --- /dev/null +++ b/system-config/unipkg.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +if pkgmgr="$( which apt-get )" 2> /dev/null; then + echo "Debian" + $pkgmgr update + $pkgmgr install "$1" +elif pkgmgr="$( which dnf )" 2> /dev/null; then + echo "dnf" + $pkgmgr check-update; $pkgmgr install -y "$1" +elif pkgmgr="$( which pacman )" 2> /dev/null; then + echo "Arch-based" + $pkgmgr -Syy; $pkgmr -S "$1" +else + echo "Package manager not found, please install $1" >&2 + exit 1 +fi +if [[ 1 -ne $# ]]; then + echo "Syntax: $0 PACKAGE" + exit 1 +fi +exit $? \ No newline at end of file diff --git a/xkeysnail-config/xkeysnail.desktop b/xkeysnail-config/xkeysnail.desktop new file mode 100644 index 0000000..46a6b31 --- /dev/null +++ b/xkeysnail-config/xkeysnail.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Name=Kinto_xkey +GenericName=Kinto_xkey +Comment=Make Linux Type Like it's a Mac +Exec=/usr/bin/xhost +SI:localuser:root +Terminal=false +Type=Application +X-GNOME-Autostart-enabled=true \ No newline at end of file diff --git a/xkeysnail-config/xkeysnail.service b/xkeysnail-config/xkeysnail.service index b152d81..53fbbea 100644 --- a/xkeysnail-config/xkeysnail.service +++ b/xkeysnail-config/xkeysnail.service @@ -5,7 +5,7 @@ Description=xkeysnail Type=simple KillMode=process ExecStartPre=/sbin/runuser -l {username} -c /home/{username}/.config/kinto/prexk.sh -ExecStart=/usr/bin/sudo /usr/local/bin/xkeysnail --quiet --watch /home/{username}/.config/kinto/kinto.py +ExecStart=/usr/bin/sudo /bin/bash -c '/home/{username}/.config/kinto/xkeystart.sh "/home/{username}/.config/kinto/kinto.py"' ExecStop=/usr/bin/sudo /usr/bin/killall xkeysnail Restart=on-failure RestartSec=3 diff --git a/xkeysnail-config/xkeystart.sh b/xkeysnail-config/xkeystart.sh new file mode 100755 index 0000000..7a64e39 --- /dev/null +++ b/xkeysnail-config/xkeystart.sh @@ -0,0 +1,8 @@ +#!/bin/bash +# >/dev/null 2>&1 +/usr/local/bin/xkeysnail --quiet --watch "$1" & +while true + do inotifywait -e close_write,moved_to,create -q "$1" + /usr/bin/killall xkeysnail + /usr/local/bin/xkeysnail --quiet --watch "$1" & +done \ No newline at end of file diff --git a/xkeysnail_service.sh b/xkeysnail_service.sh index 3f7f9ae..58704c5 100755 --- a/xkeysnail_service.sh +++ b/xkeysnail_service.sh @@ -15,6 +15,10 @@ if [ $# -eq 0 ]; then fi if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1 == "chromebook" ]]; then + if ! [ -x "$(command -v inotifywait)" ]; then + echo "Will need to install inotify-tools to restart key remapper live for config file changes..." + sudo ./system-config/unipkg.sh inotify-tools + fi # echo "Transferring files..." mkdir -p ~/.config/kinto @@ -23,9 +27,13 @@ if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1 echo -e '#!/bin/sh\rxhost +SI:localuser:root' > ~/.kde/Autostart/kintohost.sh chmod +x ~/.kde/Autostart/kintohost.sh - cp ./xkeysnail-config/kinto.py ./xkeysnail-config/kinto.py.new - cp ./xkeysnail-config/prexk.sh ~/.config/kinto/prexk.sh - cp ./xkeysnail-config/xkeysnail.service ./xkeysnail-config/xkeysnail.service.new + # KDE startup - xhost fix + yes | cp -rf ./xkeysnail-config/xkeysnail.desktop ~/.config/autostart/xkeysnail.desktop + + 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/prexk.sh ~/.config/kinto/prexk.sh + yes | cp -rf ./xkeysnail-config/xkeysnail.service ./xkeysnail-config/xkeysnail.service.new sed -i "s/{username}/`whoami`/g" ./xkeysnail-config/xkeysnail.service.new sed -i "s/{displayid}/`echo "$DISPLAY"`/g" ./xkeysnail-config/xkeysnail.service.new else @@ -55,9 +63,6 @@ if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1 echo "Adding xhost fix..." - # KDE startup - xhost fix - cp ./xkeysnail-config/xkeysnail.desktop ~/.config/autostart/xkeysnail.desktop - LINE='xhost +SI:localuser:root' if [ ! -e "~/.xprofile" ]; then From 162aa3e5d08d55ef79f1247972983bb0cfc3415d Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Tue, 21 Apr 2020 18:26:30 -0500 Subject: [PATCH 04/48] - Added uninstaller for xkeysnail edition --- xkeysnail_service.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/xkeysnail_service.sh b/xkeysnail_service.sh index 58704c5..b0e2fd7 100755 --- a/xkeysnail_service.sh +++ b/xkeysnail_service.sh @@ -8,6 +8,7 @@ if [ $# -eq 0 ]; then echo " 1) Windows & Mac (HID driver)" echo " 2) Mac Only & VMs on Macbooks" echo " 3) Chromebook" + echo " 4) Uninstall" read n @@ -36,7 +37,7 @@ if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1 yes | cp -rf ./xkeysnail-config/xkeysnail.service ./xkeysnail-config/xkeysnail.service.new sed -i "s/{username}/`whoami`/g" ./xkeysnail-config/xkeysnail.service.new sed -i "s/{displayid}/`echo "$DISPLAY"`/g" ./xkeysnail-config/xkeysnail.service.new -else +elif ! [[ $1 == "4" || $1 == "uninstall" ]]; then echo "Expected argument was not provided" fi @@ -78,8 +79,14 @@ if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1 # remove kintox11 login startup rm ~/.config/autostart/kinto.desktop -else +elif ! [[ $1 == "4" || $1 == "uninstall" ]]; then echo "Expected argument was not provided" +else + echo "Uninstalling Kinto - xkeysnail (udev)" + echo '0' | sudo tee -a /sys/module/hid_apple/parameters/swap_opt_cmd;echo 'options hid_apple swap_opt_cmd=0' | sudo tee -a /etc/modprobe.d/hid_apple.conf;sudo update-initramfs -u -k all + sudo systemctl stop xkeysnail + sudo systemctl disable xkeysnail + rm -rf ~/.config/kinto fi From 6eedd8b4f7dee66a19232854257d27aa620b2e66 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Tue, 21 Apr 2020 19:09:36 -0500 Subject: [PATCH 05/48] - Updated sublimetext hotkeys for xkey and added firefox back/forward hotkeys --- xkeysnail-config/kinto.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/xkeysnail-config/kinto.py b/xkeysnail-config/kinto.py index 944f539..64c1fa8 100644 --- a/xkeysnail-config/kinto.py +++ b/xkeysnail-config/kinto.py @@ -60,6 +60,8 @@ define_keymap(re.compile("Sublime_text"),{ K("Super-M-up"): K("C-up"), # scroll_lines up K("C-down"): pass_through_key, # cancel scroll_lines down K("Super-M-down"): K("C-down"), # scroll_lines down + K("Super-Shift-up"): K("M-Shift-up"), # multi-cursor up + K("Super-Shift-down"): K("M-Shift-down"), # multi-cursor down K("C-PAGE_DOWN"): pass_through_key, # cancel next_view K("C-PAGE_UP"): pass_through_key, # cancel prev_view K("C-Shift-left_brace"): K("C-PAGE_DOWN"), # next_view @@ -127,15 +129,17 @@ define_keymap(None,{ K("LC-Grave") : K("LC-Shift-Tab"), # Wordwise - K("RC-Left"): K("Home"), # Beginning of Line - K("RC-Right"): K("End"), # End of Line - K("M-Left"): K("C-Left"), # Left of Word - K("M-Right"): K("C-Right"), # Right of Word - K("RC-Up"): K("C-Home"), # Beginning of File - K("RC-Down"): K("C-End"), # End of File - K("M-Backspace"): K("Delete"), # Delete - # K(""): pass_through_key, # cancel - # K(""): K(""), # + K("RC-Left"): K("Home"), # Beginning of Line + K("RC-Right"): K("End"), # End of Line + # K("RC-Left"): K("C-LEFT_BRACE"), # Firefox-nw - Back + # K("RC-Right"): K("C-RIGHT_BRACE"), # Firefox-nw - Forward + K("M-Left"): K("C-Left"), # Left of Word + K("M-Right"): K("C-Right"), # Right of Word + K("RC-Up"): K("C-Home"), # Beginning of File + K("RC-Down"): K("C-End"), # End of File + K("M-Backspace"): K("Delete"), # Delete + # K(""): pass_through_key, # cancel + # K(""): K(""), # }) # define_keymap(re.compile("Gnome-terminal|io.elementary.terminal|terminator|sakura|guake|tilda|xterm|eterm|kitty"),{ From f134e9d13b698eb34ecc58b1a4fb9a80f0d6c45f Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Wed, 22 Apr 2020 15:21:56 -0500 Subject: [PATCH 06/48] - Updated xkey service to use tmp location for config, added wordwise script --- system-config/caret_status_xkey.sh | 97 ++++++++++++++++++++++++++++++ xkeysnail-config/prexk.sh | 5 +- xkeysnail-config/xkeysnail.service | 2 +- xkeysnail_service.sh | 2 + 4 files changed, 104 insertions(+), 2 deletions(-) create mode 100755 system-config/caret_status_xkey.sh diff --git a/system-config/caret_status_xkey.sh b/system-config/caret_status_xkey.sh new file mode 100755 index 0000000..cfaad8a --- /dev/null +++ b/system-config/caret_status_xkey.sh @@ -0,0 +1,97 @@ +#!/bin/bash + +# silent_background() { +# { 2>&3 "$@"& } 3>&2 2>/dev/null +# disown &>/dev/null +# } + +mkdir -p /tmp/kinto +echo "0" > /tmp/kinto/caret +# background process that will check +# caret status and apply keymap +lastcheck=0 +ww=0 +while (true);do + sleep 0.2 + check=$(cat /tmp/kinto/caret) + if [ "${check}" == "ff ww 1" ] && [ "${lastcheck}" != 1 ]; then + echo "firefox wordwise" + # echo "$check" + # Sets original config + perl -pi -e "s/(# )(.*)(# Beginning of Line)/\$2\$3/g" /tmp/kinto/kinto.py + perl -pi -e "s/(# )(.*)(# End of Line)/\$2\$3/g" /tmp/kinto/kinto.py + perl -pi -e "s/(\w.*)(# Firefox-nw)/# \$1\$2/g" /tmp/kinto/kinto.py + lastcheck=1 + ww=1 + elif [ "${check}" == "ff nw" ] && [ "${lastcheck}" != 2 ]; then + echo "firefox no wordwise" + # echo "$check" + # Sets new config + perl -pi -e "s/(# )(.*)(# Firefox-nw)/\$2\$3/g" /tmp/kinto/kinto.py + perl -pi -e "s/(\w.*)(# Beginning of Line)/# \$1\$2/g" /tmp/kinto/kinto.py + perl -pi -e "s/(\w.*)(# End of Line)/# \$1\$2/g" /tmp/kinto/kinto.py + lastcheck=2 + ww=0 + elif [ "${check}" == "chrome ww 1" ] && [ "${lastcheck}" != 3 ]; then + echo "chrome wordwise" + # echo "$check" + # Sets original config + perl -pi -e "s/(\w.*)(# Beginning of Line)/\$1\$2/g" /tmp/kinto/kinto.py + perl -pi -e "s/(\w.*)(# End of Line)/\$1\$2/g" /tmp/kinto/kinto.py + lastcheck=3 + ww=1 + elif [ "${check}" == "chrome nw" ] && [ "${lastcheck}" != 4 ]; then + echo "chrome no wordwise" + # echo "$check" + # Sets new config + perl -pi -e "s/(# )(.*)(# Beginning of Line)/\$2\$3/g" /tmp/kinto/kinto.py + perl -pi -e "s/(# )(.*)(# End of Line)/\$2\$3/g" /tmp/kinto/kinto.py + lastcheck=4 + ww=0 + elif [ "${check}" == "reset" ] && [ "${lastcheck}" != 5 ]; then + echo "reset" + # cp /home/{username}/.config/kinto/kinto.py /tmp/kinto/kinto.py + lastcheck=5 + fi + # echo "outside loop $check" +done & + +lastapp="None" +reset=false +IBUSADD=$(cat ~/.config/ibus/bus/`ls ~/.config/ibus/bus -1rt | tail -n1` | awk -F'IBUS_ADDRESS=' '{print $2}' | xargs) +dbus-monitor --address $IBUSADD "path='/org/freedesktop/IBus/Panel',interface='org.freedesktop.IBus.Panel',member='FocusOut'" 2> /dev/null | grep --line-buffered -o -P '(?<=object path \"/org/freedesktop/IBus/InputContext_).*(?=[\"])' | +while read ln +do + appname=$(xprop -id `xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)" | awk '{print $5}'` | grep "WM_CLASS(STRING)" | awk '{print substr($4,2,length($4)-2)}') + # Enable wordwise + if (( $ln == 1 )); then + if [ "${appname}" == "Firefox" ] && [ "${laststatus}" != "1" ]; then + printf 'ff ww %s\n' "$ln" > /tmp/kinto/caret + reset=false + elif [ "${appname}" == "Chromium" ] || [ "${appname}" == "Chromium-browser" ] || [ "${appname}" == "Google-chrome" ] || [ "${appname}" == "Epiphany" ] && [ "${laststatus}" != "1" ]; then + printf 'chrome ww %s\n' "$ln" > /tmp/kinto/caret + reset=false + elif ! [ "${appname}" == "Firefox" ] || [ "${appname}" == "Chromium" ] || [ "${appname}" == "Chromium-browser" ] || [ "${appname}" == "Google-chrome" ] || [ "${appname}" == "Epiphany" ] && [ "${reset}" == false ]; then + echo "reset" > /tmp/kinto/caret + reset=true + fi + + lastapp="$appname" + laststatus="$ln" + #printf '%s\n' "$ln" > /tmp/kinto/caret + # disable wordwise + else + if [ "${appname}" == "Firefox" ] && [ "${laststatus}" == "1" ]; then + printf 'ff nw\n' > /tmp/kinto/caret + reset=false + elif [ "${appname}" == "Chromium" ] || [ "${appname}" == "Chromium-browser" ] || [ "${appname}" == "Google-chrome" ] || [ "${appname}" == "Epiphany" ] && [ "${laststatus}" == "1" ]; then + printf 'chrome nw\n' > /tmp/kinto/caret + reset=false + elif ! [ "${appname}" == "Firefox" ] || [ "${appname}" == "Chromium" ] || [ "${appname}" == "Chromium-browser" ] || [ "${appname}" == "Google-chrome" ] || [ "${appname}" == "Epiphany" ] && [ "${reset}" == false ]; then + echo "reset" > /tmp/kinto/caret + reset=true + fi + lastapp="$appname" + laststatus="$ln" + fi +done diff --git a/xkeysnail-config/prexk.sh b/xkeysnail-config/prexk.sh index ba15330..d1d381d 100755 --- a/xkeysnail-config/prexk.sh +++ b/xkeysnail-config/prexk.sh @@ -9,4 +9,7 @@ if systemctl -q --user is-active keyswap; then fi if systemctl -q --user is-enabled keyswap; then systemctl --user disable keyswap -fi \ No newline at end of file +fi + +mkdir -p /tmp/kinto +cp /home/{username}/.config/kinto/kinto.py /tmp/kinto/kinto.py \ No newline at end of file diff --git a/xkeysnail-config/xkeysnail.service b/xkeysnail-config/xkeysnail.service index 53fbbea..2559a71 100644 --- a/xkeysnail-config/xkeysnail.service +++ b/xkeysnail-config/xkeysnail.service @@ -5,7 +5,7 @@ Description=xkeysnail Type=simple KillMode=process ExecStartPre=/sbin/runuser -l {username} -c /home/{username}/.config/kinto/prexk.sh -ExecStart=/usr/bin/sudo /bin/bash -c '/home/{username}/.config/kinto/xkeystart.sh "/home/{username}/.config/kinto/kinto.py"' +ExecStart=/usr/bin/sudo /bin/bash -c '/home/{username}/.config/kinto/xkeystart.sh "/tmp/kinto/kinto.py"' ExecStop=/usr/bin/sudo /usr/bin/killall xkeysnail Restart=on-failure RestartSec=3 diff --git a/xkeysnail_service.sh b/xkeysnail_service.sh index b0e2fd7..1b36fcb 100755 --- a/xkeysnail_service.sh +++ b/xkeysnail_service.sh @@ -16,6 +16,7 @@ if [ $# -eq 0 ]; then fi if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1 == "chromebook" ]]; then + sudo systemctl enable xkeysnail >/dev/null 2>&1 if ! [ -x "$(command -v inotifywait)" ]; then echo "Will need to install inotify-tools to restart key remapper live for config file changes..." sudo ./system-config/unipkg.sh inotify-tools @@ -36,6 +37,7 @@ if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1 yes | cp -rf ./xkeysnail-config/prexk.sh ~/.config/kinto/prexk.sh yes | cp -rf ./xkeysnail-config/xkeysnail.service ./xkeysnail-config/xkeysnail.service.new sed -i "s/{username}/`whoami`/g" ./xkeysnail-config/xkeysnail.service.new + sed -i "s/{username}/`whoami`/g" ~/.config/kinto/prexk.sh sed -i "s/{displayid}/`echo "$DISPLAY"`/g" ./xkeysnail-config/xkeysnail.service.new elif ! [[ $1 == "4" || $1 == "uninstall" ]]; then echo "Expected argument was not provided" From a66c82d84c66e554c8825ce9034d80b5ca18d1fd Mon Sep 17 00:00:00 2001 From: Ryan Reaves Date: Thu, 23 Apr 2020 13:57:02 -0500 Subject: [PATCH 07/48] - Tweaked caret checking regex to be more specific --- system-config/caret_status_xkey.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/system-config/caret_status_xkey.sh b/system-config/caret_status_xkey.sh index cfaad8a..b2bd466 100755 --- a/system-config/caret_status_xkey.sh +++ b/system-config/caret_status_xkey.sh @@ -18,34 +18,34 @@ while (true);do echo "firefox wordwise" # echo "$check" # Sets original config - perl -pi -e "s/(# )(.*)(# Beginning of Line)/\$2\$3/g" /tmp/kinto/kinto.py - perl -pi -e "s/(# )(.*)(# End of Line)/\$2\$3/g" /tmp/kinto/kinto.py - perl -pi -e "s/(\w.*)(# Firefox-nw)/# \$1\$2/g" /tmp/kinto/kinto.py + perl -pi -e "s/[^\n]\s{3}#\s(K.*)(# Beginning of Line)/\$2\$3/g" /tmp/kinto/kinto.py + perl -pi -e "s/[^\n]\s{3}#\s(K.*)(# End of Line)/\$2\$3/g" /tmp/kinto/kinto.py + perl -pi -e "s/[^\n]\s{3}(K.*)(# Firefox-nw)/# \$1\$2/g" /tmp/kinto/kinto.py lastcheck=1 ww=1 elif [ "${check}" == "ff nw" ] && [ "${lastcheck}" != 2 ]; then echo "firefox no wordwise" # echo "$check" # Sets new config - perl -pi -e "s/(# )(.*)(# Firefox-nw)/\$2\$3/g" /tmp/kinto/kinto.py - perl -pi -e "s/(\w.*)(# Beginning of Line)/# \$1\$2/g" /tmp/kinto/kinto.py - perl -pi -e "s/(\w.*)(# End of Line)/# \$1\$2/g" /tmp/kinto/kinto.py + perl -pi -e "s/[^\n]\s{3}#\s(K.*)(# Firefox-nw)/\$2\$3/g" /tmp/kinto/kinto.py + perl -pi -e "s/[^\n]\s{3}(K.*)(# Beginning of Line)/# \$1\$2/g" /tmp/kinto/kinto.py + perl -pi -e "s/[^\n]\s{3}(K.*)(# End of Line)/# \$1\$2/g" /tmp/kinto/kinto.py lastcheck=2 ww=0 elif [ "${check}" == "chrome ww 1" ] && [ "${lastcheck}" != 3 ]; then echo "chrome wordwise" # echo "$check" # Sets original config - perl -pi -e "s/(\w.*)(# Beginning of Line)/\$1\$2/g" /tmp/kinto/kinto.py - perl -pi -e "s/(\w.*)(# End of Line)/\$1\$2/g" /tmp/kinto/kinto.py + perl -pi -e "s/[^\n]\s{3}(K.*)(# Beginning of Line)/\$1\$2/g" /tmp/kinto/kinto.py + perl -pi -e "s/[^\n]\s{3}(K.*)(# End of Line)/\$1\$2/g" /tmp/kinto/kinto.py lastcheck=3 ww=1 elif [ "${check}" == "chrome nw" ] && [ "${lastcheck}" != 4 ]; then echo "chrome no wordwise" # echo "$check" # Sets new config - perl -pi -e "s/(# )(.*)(# Beginning of Line)/\$2\$3/g" /tmp/kinto/kinto.py - perl -pi -e "s/(# )(.*)(# End of Line)/\$2\$3/g" /tmp/kinto/kinto.py + perl -pi -e "s/[^\n]\s{3}#\s(K.*)(# Beginning of Line)/\$2\$3/g" /tmp/kinto/kinto.py + perl -pi -e "s/[^\n]\s{3}#\s(K.*)(# End of Line)/\$2\$3/g" /tmp/kinto/kinto.py lastcheck=4 ww=0 elif [ "${check}" == "reset" ] && [ "${lastcheck}" != 5 ]; then From 696fb6ad7f018d405d192c3c0bbe43668a08833c Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Fri, 24 Apr 2020 20:04:35 -0500 Subject: [PATCH 08/48] - Added VS Code wordwise fix for xkeysnail --- xkeysnail-config/kinto.py | 18 ++++++++++++++++++ xkeysnail-config/vscode_keybindings.json | 21 +++++++++++++++++++++ xkeysnail_service.sh | 2 +- 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 xkeysnail-config/vscode_keybindings.json diff --git a/xkeysnail-config/kinto.py b/xkeysnail-config/kinto.py index 64c1fa8..0bd720d 100644 --- a/xkeysnail-config/kinto.py +++ b/xkeysnail-config/kinto.py @@ -51,6 +51,24 @@ define_conditional_modmap(re.compile("Gnome-terminal|konsole|io.elementary.termi # Key.RIGHT_CTRL: Key.LEFT_CTRL, # Mac }) +# Keybindings for VS Code +define_keymap(re.compile("Code"),{ + K("C-g"): pass_through_key, # cancel Go to Line... + K("Super-g"): K("C-g"), # Go to Line... + K("F3"): pass_through_key, # cancel Find next + K("C-h"): pass_through_key, # cancel replace + K("C-M-f"): K("C-h"), # replace + K("C-Shift-h"): pass_through_key, # cancel replace_next + K("C-M-e"): K("C-Shift-h"), # replace_next + K("f3"): pass_through_key, # cancel find_next + K("C-g"): K("f3"), # find_next + K("Shift-f3"): pass_through_key, # cancel find_prev + K("C-Shift-g"): K("Shift-f3"), # find_prev + K("Super-C-g"): K("C-f2"), # Sublime - find_all_under + K("Super-Shift-up"): K("M-Shift-up"), # multi-cursor up + K("Super-Shift-down"): K("M-Shift-down"), # multi-cursor down +}, "Code") + # Keybindings for Sublime Text define_keymap(re.compile("Sublime_text"),{ K("C-Super-up"): K("M-o"), # Switch file diff --git a/xkeysnail-config/vscode_keybindings.json b/xkeysnail-config/vscode_keybindings.json new file mode 100644 index 0000000..30d4657 --- /dev/null +++ b/xkeysnail-config/vscode_keybindings.json @@ -0,0 +1,21 @@ +// Place your key bindings in this file to override the defaultsauto[] +[ + { + "key": "alt+left", + "command": "-workbench.action.terminal.focusPreviousPane", + "when": "terminalFocus" + }, + { + "key": "alt+right", + "command": "-workbench.action.terminal.focusNextPane", + "when": "terminalFocus" + }, + { + "key": "alt+right", + "command": "cursorWordRight" + }, + { + "key": "alt+left", + "command": "cursorWordLeft" + } +] \ No newline at end of file diff --git a/xkeysnail_service.sh b/xkeysnail_service.sh index 1b36fcb..239789d 100755 --- a/xkeysnail_service.sh +++ b/xkeysnail_service.sh @@ -62,7 +62,7 @@ if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1 sudo pip3 install --upgrade . sudo systemctl enable xkeysnail sudo systemctl daemon-reload - sudo systemctl start xkeysnail + sudo systemctl restart xkeysnail echo "Adding xhost fix..." From f0f152e21f607edce53469d8c8969d910c443464 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Fri, 24 Apr 2020 20:22:37 -0500 Subject: [PATCH 09/48] - More notes about VS Code and Firefox in regards to wordwise --- xkeysnail-config/kinto.py | 87 +++++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 40 deletions(-) diff --git a/xkeysnail-config/kinto.py b/xkeysnail-config/kinto.py index 0bd720d..5cce379 100644 --- a/xkeysnail-config/kinto.py +++ b/xkeysnail-config/kinto.py @@ -19,7 +19,7 @@ define_conditional_modmap(lambda wm_class: wm_class not in ("Gnome-terminal","ko # Key.RIGHT_META: Key.RIGHT_ALT, # WinMac # Key.RIGHT_CTRL: Key.RIGHT_META, # WinMac - # Mac Only + # # Mac Only # Key.LEFT_META: Key.RIGHT_CTRL, # Mac # Key.LEFT_CTRL: Key.LEFT_META, # Mac # Key.RIGHT_META: Key.RIGHT_CTRL, # Mac @@ -51,6 +51,50 @@ define_conditional_modmap(re.compile("Gnome-terminal|konsole|io.elementary.termi # Key.RIGHT_CTRL: Key.LEFT_CTRL, # Mac }) +define_keymap(None,{ + # Cmd Tab - App Switching Default + K("RC-Tab"): K("RC-F13"), + K("RC-Shift-Tab"): K("RC-Shift-F13"), + K("RC-Grave"): K("RC-Shift-F13"), + # In-App Tab switching + # K("M-Tab"): K("C-Tab"), # Chromebook - In-App Tab switching + # K("M-Shift-Tab"): K("C-Shift-Tab"), # Chromebook - In-App Tab switching + K("Super-Tab"): K("LC-Tab"), # Default + K("Super-Shift-Tab"): K("LC-Shift-Tab"), # Default + K("LC-Grave") : K("LC-Shift-Tab"), + + # Wordwise + K("RC-Left"): K("Home"), # Beginning of Line + K("RC-Right"): K("End"), # End of Line + # K("RC-Left"): K("C-LEFT_BRACE"), # Firefox-nw - Back + # K("RC-Right"): K("C-RIGHT_BRACE"), # Firefox-nw - Forward + K("RC-Up"): K("C-Home"), # Beginning of File + K("RC-Down"): K("C-End"), # End of File + K("M-Backspace"): K("Delete"), # Delete + # K(""): pass_through_key, # cancel + # K(""): K(""), # +}) + +define_keymap(lambda wm_class: wm_class not in ("Code"),{ + # Wordwise remaining - for Everything but VS Code + K("M-Left"): K("C-Left"), # Left of Word + K("M-Right"): K("C-Right"), # Right of Word + # ** VS Code fix ** + # Electron issue precludes normal keybinding fix. + # Alt menu auto-focus/toggle gets in the way. + # + # refer to ./xkeysnail-config/vscode_keybindings.json + # ** + # + # ** Firefox fix ** + # User will need to set "ui.key.menuAccessKeyFocuses" + # under about:config to false. + # + # https://superuser.com/questions/770301/pentadactyl-how-to-disable-menu-bar-toggle-by-alt + # ** + # +}) + # Keybindings for VS Code define_keymap(re.compile("Code"),{ K("C-g"): pass_through_key, # cancel Go to Line... @@ -67,6 +111,8 @@ define_keymap(re.compile("Code"),{ K("Super-C-g"): K("C-f2"), # Sublime - find_all_under K("Super-Shift-up"): K("M-Shift-up"), # multi-cursor up K("Super-Shift-down"): K("M-Shift-down"), # multi-cursor down + # K(""): pass_through_key, # cancel + # K(""): K(""), # }, "Code") # Keybindings for Sublime Text @@ -134,38 +180,6 @@ define_keymap(re.compile("Sublime_text"),{ # K(""): K(""), # }, "Sublime Text") -define_keymap(None,{ - # Cmd Tab - App Switching Default - K("RC-Tab"): K("RC-F13"), - K("RC-Shift-Tab"): K("RC-Shift-F13"), - K("RC-Grave"): K("RC-Shift-F13"), - # In-App Tab switching - # K("M-Tab"): K("C-Tab"), # Chromebook - In-App Tab switching - # K("M-Shift-Tab"): K("C-Shift-Tab"), # Chromebook - In-App Tab switching - K("Super-Tab"): K("LC-Tab"), # Default - K("Super-Shift-Tab"): K("LC-Shift-Tab"), # Default - K("LC-Grave") : K("LC-Shift-Tab"), - - # Wordwise - K("RC-Left"): K("Home"), # Beginning of Line - K("RC-Right"): K("End"), # End of Line - # K("RC-Left"): K("C-LEFT_BRACE"), # Firefox-nw - Back - # K("RC-Right"): K("C-RIGHT_BRACE"), # Firefox-nw - Forward - K("M-Left"): K("C-Left"), # Left of Word - K("M-Right"): K("C-Right"), # Right of Word - K("RC-Up"): K("C-Home"), # Beginning of File - K("RC-Down"): K("C-End"), # End of File - K("M-Backspace"): K("Delete"), # Delete - # K(""): pass_through_key, # cancel - # K(""): K(""), # -}) - -# define_keymap(re.compile("Gnome-terminal|io.elementary.terminal|terminator|sakura|guake|tilda|xterm|eterm|kitty"),{ -# # Ctrl Tab - In App Tab Switching -# # LC is already set -# K("LC-Grave") : K("LC-Shift-Tab"), -# }, "Terminals tab switching") - define_keymap(re.compile("konsole"),{ # Ctrl Tab - In App Tab Switching K("LC-Tab") : K("Shift-Right"), @@ -174,8 +188,6 @@ define_keymap(re.compile("konsole"),{ }, "Konsole tab switching") - - define_keymap(re.compile("Gnome-terminal|konsole|io.elementary.terminal|terminator|sakura|guake|tilda|xterm|eterm|kitty"),{ # Ctrl Tab - In App Tab Switching K("LC-Tab") : K("LC-PAGE_DOWN"), @@ -225,8 +237,3 @@ define_keymap(re.compile("Gnome-terminal|konsole|io.elementary.terminal|terminat K("RC-SLASH"): K("C-Shift-SLASH"), K("RC-KPASTERISK"): K("C-Shift-KPASTERISK"), }, "terminals") - -# define_keymap(re.compile("Chromium-browser"),{ -# # K("RC-Tab"): K("C-F13"), -# # K("RC-Shift-Tab"): K("C-f1"), -# }, "Chromium-browser") From 2eb5a33b9375c63529b662e57b05d5db12382824 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Sat, 25 Apr 2020 03:26:46 -0500 Subject: [PATCH 10/48] - Corrected some caret check logic, updated autostart for xkeysnail --- system-config/caret_status_xkey.sh | 18 +++++++++--------- xkeysnail-config/limitedadmins | 5 +++++ xkeysnail-config/prexk.sh | 1 + xkeysnail-config/xkeysnail.desktop | 2 +- xkeysnail-config/xkeysnail.service | 2 +- xkeysnail_service.sh | 12 +++++++++--- 6 files changed, 26 insertions(+), 14 deletions(-) create mode 100644 xkeysnail-config/limitedadmins diff --git a/system-config/caret_status_xkey.sh b/system-config/caret_status_xkey.sh index b2bd466..d6172fe 100755 --- a/system-config/caret_status_xkey.sh +++ b/system-config/caret_status_xkey.sh @@ -20,37 +20,37 @@ while (true);do # Sets original config perl -pi -e "s/[^\n]\s{3}#\s(K.*)(# Beginning of Line)/\$2\$3/g" /tmp/kinto/kinto.py perl -pi -e "s/[^\n]\s{3}#\s(K.*)(# End of Line)/\$2\$3/g" /tmp/kinto/kinto.py - perl -pi -e "s/[^\n]\s{3}(K.*)(# Firefox-nw)/# \$1\$2/g" /tmp/kinto/kinto.py + perl -pi -e "s/[^\n]\s{3}(K.*)(# Firefox-nw)/ # \$1\$2/g" /tmp/kinto/kinto.py lastcheck=1 ww=1 elif [ "${check}" == "ff nw" ] && [ "${lastcheck}" != 2 ]; then echo "firefox no wordwise" # echo "$check" # Sets new config - perl -pi -e "s/[^\n]\s{3}#\s(K.*)(# Firefox-nw)/\$2\$3/g" /tmp/kinto/kinto.py - perl -pi -e "s/[^\n]\s{3}(K.*)(# Beginning of Line)/# \$1\$2/g" /tmp/kinto/kinto.py - perl -pi -e "s/[^\n]\s{3}(K.*)(# End of Line)/# \$1\$2/g" /tmp/kinto/kinto.py + perl -pi -e "s/[^\n]\s{3}#\s(K.*)(# Firefox-nw)/ \$1\$2/g" /tmp/kinto/kinto.py + perl -pi -e "s/[^\n]\s{3}(K.*)(# Beginning of Line)/ # \$1\$2/g" /tmp/kinto/kinto.py + perl -pi -e "s/[^\n]\s{3}(K.*)(# End of Line)/ # \$1\$2/g" /tmp/kinto/kinto.py lastcheck=2 ww=0 elif [ "${check}" == "chrome ww 1" ] && [ "${lastcheck}" != 3 ]; then echo "chrome wordwise" # echo "$check" # Sets original config - perl -pi -e "s/[^\n]\s{3}(K.*)(# Beginning of Line)/\$1\$2/g" /tmp/kinto/kinto.py - perl -pi -e "s/[^\n]\s{3}(K.*)(# End of Line)/\$1\$2/g" /tmp/kinto/kinto.py + perl -pi -e "s/[^\n]\s{3}#\s(K.*)(# Beginning of Line)/ \$1\$2/g" /tmp/kinto/kinto.py + perl -pi -e "s/[^\n]\s{3}#\s(K.*)(# End of Line)/ \$1\$2/g" /tmp/kinto/kinto.py lastcheck=3 ww=1 elif [ "${check}" == "chrome nw" ] && [ "${lastcheck}" != 4 ]; then echo "chrome no wordwise" # echo "$check" # Sets new config - perl -pi -e "s/[^\n]\s{3}#\s(K.*)(# Beginning of Line)/\$2\$3/g" /tmp/kinto/kinto.py - perl -pi -e "s/[^\n]\s{3}#\s(K.*)(# End of Line)/\$2\$3/g" /tmp/kinto/kinto.py + perl -pi -e "s/[^\n]\s{3}(K.*)(# Beginning of Line)/ # \$1\$2g" /tmp/kinto/kinto.py + perl -pi -e "s/[^\n]\s{3}(K.*)(# End of Line)/ # \$1\$2/g" /tmp/kinto/kinto.py lastcheck=4 ww=0 elif [ "${check}" == "reset" ] && [ "${lastcheck}" != 5 ]; then echo "reset" - # cp /home/{username}/.config/kinto/kinto.py /tmp/kinto/kinto.py + cp /home/{username}/.config/kinto/kinto.py /tmp/kinto/kinto.py lastcheck=5 fi # echo "outside loop $check" diff --git a/xkeysnail-config/limitedadmins b/xkeysnail-config/limitedadmins new file mode 100644 index 0000000..3b196a8 --- /dev/null +++ b/xkeysnail-config/limitedadmins @@ -0,0 +1,5 @@ +# /etc/sudoers.d/limitedadmins +%{username} ALL=NOPASSWD: /bin/systemctl restart xkeysnail +%{username} ALL=NOPASSWD: /bin/systemctl start xkeysnail +%{username} ALL=NOPASSWD: /bin/systemctl stop xkeysnail +%{username} ALL=NOPASSWD: /bin/systemctl status xkeysnail diff --git a/xkeysnail-config/prexk.sh b/xkeysnail-config/prexk.sh index d1d381d..484df4e 100755 --- a/xkeysnail-config/prexk.sh +++ b/xkeysnail-config/prexk.sh @@ -11,5 +11,6 @@ if systemctl -q --user is-enabled keyswap; then systemctl --user disable keyswap 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 diff --git a/xkeysnail-config/xkeysnail.desktop b/xkeysnail-config/xkeysnail.desktop index 46a6b31..a875673 100644 --- a/xkeysnail-config/xkeysnail.desktop +++ b/xkeysnail-config/xkeysnail.desktop @@ -2,7 +2,7 @@ Name=Kinto_xkey GenericName=Kinto_xkey Comment=Make Linux Type Like it's a Mac -Exec=/usr/bin/xhost +SI:localuser:root +Exec=/bin/bash -c "/usr/bin/xhost +SI:localuser:root && sudo /bin/systemctl restart xkeysnail" Terminal=false Type=Application X-GNOME-Autostart-enabled=true \ No newline at end of file diff --git a/xkeysnail-config/xkeysnail.service b/xkeysnail-config/xkeysnail.service index 2559a71..c5fc08d 100644 --- a/xkeysnail-config/xkeysnail.service +++ b/xkeysnail-config/xkeysnail.service @@ -4,7 +4,7 @@ Description=xkeysnail [Service] Type=simple KillMode=process -ExecStartPre=/sbin/runuser -l {username} -c /home/{username}/.config/kinto/prexk.sh +ExecStartPre=/usr/bin/xhost +SI:localuser:root;/sbin/runuser -l {username} -c /home/{username}/.config/kinto/prexk.sh ExecStart=/usr/bin/sudo /bin/bash -c '/home/{username}/.config/kinto/xkeystart.sh "/tmp/kinto/kinto.py"' ExecStop=/usr/bin/sudo /usr/bin/killall xkeysnail Restart=on-failure diff --git a/xkeysnail_service.sh b/xkeysnail_service.sh index 239789d..3d7f814 100755 --- a/xkeysnail_service.sh +++ b/xkeysnail_service.sh @@ -35,10 +35,14 @@ 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/prexk.sh ~/.config/kinto/prexk.sh + yes | cp -rf ./xkeysnail-config/start-xkeysnail.sh ~/.config/kinto/start-xkeysnail.sh yes | cp -rf ./xkeysnail-config/xkeysnail.service ./xkeysnail-config/xkeysnail.service.new + yes | cp -rf ./xkeysnail-config/user_xkeysnail.service ~/.config/systemd/user/xkeysnail.service + # yes | cp -rf ./xkeysnail-config/xkeysnail.timer ~/.config/systemd/user/xkeysnail.timer sed -i "s/{username}/`whoami`/g" ./xkeysnail-config/xkeysnail.service.new sed -i "s/{username}/`whoami`/g" ~/.config/kinto/prexk.sh sed -i "s/{displayid}/`echo "$DISPLAY"`/g" ./xkeysnail-config/xkeysnail.service.new + sed -i "s/{displayid}/`echo "$DISPLAY"`/g" ~/.config/kinto/prexk.sh elif ! [[ $1 == "4" || $1 == "uninstall" ]]; then echo "Expected argument was not provided" fi @@ -60,7 +64,7 @@ if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1 git clone --depth 1 https://github.com/rbreaves/xkeysnail.git cd xkeysnail sudo pip3 install --upgrade . - sudo systemctl enable xkeysnail + sudo systemctl enable xkeysnail.service sudo systemctl daemon-reload sudo systemctl restart xkeysnail @@ -86,8 +90,10 @@ elif ! [[ $1 == "4" || $1 == "uninstall" ]]; then else echo "Uninstalling Kinto - xkeysnail (udev)" echo '0' | sudo tee -a /sys/module/hid_apple/parameters/swap_opt_cmd;echo 'options hid_apple swap_opt_cmd=0' | sudo tee -a /etc/modprobe.d/hid_apple.conf;sudo update-initramfs -u -k all - sudo systemctl stop xkeysnail - sudo systemctl disable xkeysnail + # sudo systemctl stop xkeysnail.timer + # sudo systemctl disable xkeysnail.timer + sudo systemctl enable xkeysnail + sudo systemctl restart xkeysnail rm -rf ~/.config/kinto fi From 315a6a05411dcd6746a9c8d30aa9e0ffa614ca74 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Sun, 26 Apr 2020 01:23:43 -0500 Subject: [PATCH 11/48] - Updated xkeysnail installer and permissions --- xkeysnail-config/limitedadmins | 8 ++++---- xkeysnail-config/xkeysnail.desktop | 2 +- xkeysnail-config/xkeysnail.service | 2 +- xkeysnail_service.sh | 29 +++++++++++++++++++++-------- 4 files changed, 27 insertions(+), 14 deletions(-) diff --git a/xkeysnail-config/limitedadmins b/xkeysnail-config/limitedadmins index 3b196a8..abb66b0 100644 --- a/xkeysnail-config/limitedadmins +++ b/xkeysnail-config/limitedadmins @@ -1,5 +1,5 @@ # /etc/sudoers.d/limitedadmins -%{username} ALL=NOPASSWD: /bin/systemctl restart xkeysnail -%{username} ALL=NOPASSWD: /bin/systemctl start xkeysnail -%{username} ALL=NOPASSWD: /bin/systemctl stop xkeysnail -%{username} ALL=NOPASSWD: /bin/systemctl status xkeysnail +%{username} ALL=NOPASSWD: {systemctl} restart xkeysnail +%{username} ALL=NOPASSWD: {systemctl} start xkeysnail +%{username} ALL=NOPASSWD: {systemctl} stop xkeysnail +%{username} ALL=NOPASSWD: {systemctl} status xkeysnail diff --git a/xkeysnail-config/xkeysnail.desktop b/xkeysnail-config/xkeysnail.desktop index a875673..4ff6059 100644 --- a/xkeysnail-config/xkeysnail.desktop +++ b/xkeysnail-config/xkeysnail.desktop @@ -2,7 +2,7 @@ Name=Kinto_xkey GenericName=Kinto_xkey Comment=Make Linux Type Like it's a Mac -Exec=/bin/bash -c "/usr/bin/xhost +SI:localuser:root && sudo /bin/systemctl restart xkeysnail" +Exec=/bin/bash -c "{xhost} +SI:localuser:root && sudo {systemctl} restart xkeysnail" Terminal=false Type=Application X-GNOME-Autostart-enabled=true \ No newline at end of file diff --git a/xkeysnail-config/xkeysnail.service b/xkeysnail-config/xkeysnail.service index c5fc08d..ff76431 100644 --- a/xkeysnail-config/xkeysnail.service +++ b/xkeysnail-config/xkeysnail.service @@ -4,7 +4,7 @@ Description=xkeysnail [Service] Type=simple KillMode=process -ExecStartPre=/usr/bin/xhost +SI:localuser:root;/sbin/runuser -l {username} -c /home/{username}/.config/kinto/prexk.sh +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 '/home/{username}/.config/kinto/xkeystart.sh "/tmp/kinto/kinto.py"' ExecStop=/usr/bin/sudo /usr/bin/killall xkeysnail Restart=on-failure diff --git a/xkeysnail_service.sh b/xkeysnail_service.sh index 3d7f814..e64cea4 100755 --- a/xkeysnail_service.sh +++ b/xkeysnail_service.sh @@ -34,12 +34,18 @@ 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/start-xkeysnail.sh ~/.config/kinto/start-xkeysnail.sh yes | cp -rf ./xkeysnail-config/xkeysnail.service ./xkeysnail-config/xkeysnail.service.new - yes | cp -rf ./xkeysnail-config/user_xkeysnail.service ~/.config/systemd/user/xkeysnail.service # yes | cp -rf ./xkeysnail-config/xkeysnail.timer ~/.config/systemd/user/xkeysnail.timer sed -i "s/{username}/`whoami`/g" ./xkeysnail-config/xkeysnail.service.new + sed -i "s#{xhost}#`which xhost`#g" ./xkeysnail-config/xkeysnail.service.new + sed -i "s/{username}/`whoami`/g" ./xkeysnail-config/limitedadmins.new + sed -i "s#{systemctl}#`which systemctl`#g" ./xkeysnail-config/limitedadmins.new + sudo chown root:root ./xkeysnail-config/limitedadmins.new + sudo mv ./xkeysnail-config/limitedadmins.new /etc/sudoers.d/limitedadmins + sed -i "s#{systemctl}#`which systemctl`#g" ~/.config/autostart/xkeysnail.desktop + sed -i "s#{xhost}#`which xhost`#g" ~/.config/autostart/xkeysnail.desktop sed -i "s/{username}/`whoami`/g" ~/.config/kinto/prexk.sh sed -i "s/{displayid}/`echo "$DISPLAY"`/g" ./xkeysnail-config/xkeysnail.service.new sed -i "s/{displayid}/`echo "$DISPLAY"`/g" ~/.config/kinto/prexk.sh @@ -84,16 +90,23 @@ if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1 # grep -qF -- "$LINE" ~/.xinitrc || echo "$LINE" >> ~/.xinitrc # remove kintox11 login startup - rm ~/.config/autostart/kinto.desktop + if test -f "~/.config/autostart/kinto.desktop"; then + rm ~/.config/autostart/kinto.desktop + fi elif ! [[ $1 == "4" || $1 == "uninstall" ]]; then echo "Expected argument was not provided" else echo "Uninstalling Kinto - xkeysnail (udev)" - echo '0' | sudo tee -a /sys/module/hid_apple/parameters/swap_opt_cmd;echo 'options hid_apple swap_opt_cmd=0' | sudo tee -a /etc/modprobe.d/hid_apple.conf;sudo update-initramfs -u -k all - # sudo systemctl stop xkeysnail.timer - # sudo systemctl disable xkeysnail.timer - sudo systemctl enable xkeysnail - sudo systemctl restart xkeysnail + # Undo Apple keyboard cmd & alt swap + if test -f "/sys/module/hid_apple/parameters/swap_opt_cmd" && [ `cat /sys/module/hid_apple/parameters/swap_opt_cmd` == "1" ]; then + echo '0' | sudo tee -a /sys/module/hid_apple/parameters/swap_opt_cmd + echo 'options hid_apple swap_opt_cmd=0' | sudo tee -a /etc/modprobe.d/hid_apple.conf + sudo update-initramfs -u -k all + fi + sudo systemctl stop xkeysnail + sudo systemctl disable xkeysnail + sudo rm /etc/sudoers.d/limitedadmins + rm ~/.config/autostart/xkeysnail.desktop rm -rf ~/.config/kinto fi From 5593fdfe5a301087d8735435565316fa0e859ee2 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Sun, 26 Apr 2020 16:59:24 -0500 Subject: [PATCH 12/48] - Experimental caret checking support for Firefox & Chrome --- system-config/caret_status_xkey.sh | 130 ++++++++++++----------------- xkeysnail-config/xkeysnail.service | 2 +- xkeysnail_service.sh | 10 +++ 3 files changed, 63 insertions(+), 79 deletions(-) diff --git a/system-config/caret_status_xkey.sh b/system-config/caret_status_xkey.sh index d6172fe..3ca9195 100755 --- a/system-config/caret_status_xkey.sh +++ b/system-config/caret_status_xkey.sh @@ -1,97 +1,71 @@ #!/bin/bash -# silent_background() { -# { 2>&3 "$@"& } 3>&2 2>/dev/null -# disown &>/dev/null -# } - mkdir -p /tmp/kinto echo "0" > /tmp/kinto/caret -# background process that will check -# caret status and apply keymap -lastcheck=0 -ww=0 -while (true);do - sleep 0.2 - check=$(cat /tmp/kinto/caret) - if [ "${check}" == "ff ww 1" ] && [ "${lastcheck}" != 1 ]; then - echo "firefox wordwise" - # echo "$check" - # Sets original config - perl -pi -e "s/[^\n]\s{3}#\s(K.*)(# Beginning of Line)/\$2\$3/g" /tmp/kinto/kinto.py - perl -pi -e "s/[^\n]\s{3}#\s(K.*)(# End of Line)/\$2\$3/g" /tmp/kinto/kinto.py - perl -pi -e "s/[^\n]\s{3}(K.*)(# Firefox-nw)/ # \$1\$2/g" /tmp/kinto/kinto.py - lastcheck=1 - ww=1 - elif [ "${check}" == "ff nw" ] && [ "${lastcheck}" != 2 ]; then - echo "firefox no wordwise" - # echo "$check" - # Sets new config - perl -pi -e "s/[^\n]\s{3}#\s(K.*)(# Firefox-nw)/ \$1\$2/g" /tmp/kinto/kinto.py - perl -pi -e "s/[^\n]\s{3}(K.*)(# Beginning of Line)/ # \$1\$2/g" /tmp/kinto/kinto.py - perl -pi -e "s/[^\n]\s{3}(K.*)(# End of Line)/ # \$1\$2/g" /tmp/kinto/kinto.py - lastcheck=2 - ww=0 - elif [ "${check}" == "chrome ww 1" ] && [ "${lastcheck}" != 3 ]; then - echo "chrome wordwise" - # echo "$check" - # Sets original config - perl -pi -e "s/[^\n]\s{3}#\s(K.*)(# Beginning of Line)/ \$1\$2/g" /tmp/kinto/kinto.py - perl -pi -e "s/[^\n]\s{3}#\s(K.*)(# End of Line)/ \$1\$2/g" /tmp/kinto/kinto.py - lastcheck=3 - ww=1 - elif [ "${check}" == "chrome nw" ] && [ "${lastcheck}" != 4 ]; then - echo "chrome no wordwise" - # echo "$check" - # Sets new config - perl -pi -e "s/[^\n]\s{3}(K.*)(# Beginning of Line)/ # \$1\$2g" /tmp/kinto/kinto.py - perl -pi -e "s/[^\n]\s{3}(K.*)(# End of Line)/ # \$1\$2/g" /tmp/kinto/kinto.py - lastcheck=4 - ww=0 - elif [ "${check}" == "reset" ] && [ "${lastcheck}" != 5 ]; then - echo "reset" - cp /home/{username}/.config/kinto/kinto.py /tmp/kinto/kinto.py - lastcheck=5 - fi - # echo "outside loop $check" -done & -lastapp="None" -reset=false +millitime=`date +%s%3N` +echo "$millitime" > /tmp/kinto/millitime + IBUSADD=$(cat ~/.config/ibus/bus/`ls ~/.config/ibus/bus -1rt | tail -n1` | awk -F'IBUS_ADDRESS=' '{print $2}' | xargs) dbus-monitor --address $IBUSADD "path='/org/freedesktop/IBus/Panel',interface='org.freedesktop.IBus.Panel',member='FocusOut'" 2> /dev/null | grep --line-buffered -o -P '(?<=object path \"/org/freedesktop/IBus/InputContext_).*(?=[\"])' | while read ln do + newtime=`date +%s%3N` + difftime=$(( newtime - millitime )) + millitime="$newtime" + echo "$millitime" > /tmp/kinto/millitime appname=$(xprop -id `xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)" | awk '{print $5}'` | grep "WM_CLASS(STRING)" | awk '{print substr($4,2,length($4)-2)}') - # Enable wordwise - if (( $ln == 1 )); then - if [ "${appname}" == "Firefox" ] && [ "${laststatus}" != "1" ]; then - printf 'ff ww %s\n' "$ln" > /tmp/kinto/caret - reset=false - elif [ "${appname}" == "Chromium" ] || [ "${appname}" == "Chromium-browser" ] || [ "${appname}" == "Google-chrome" ] || [ "${appname}" == "Epiphany" ] && [ "${laststatus}" != "1" ]; then - printf 'chrome ww %s\n' "$ln" > /tmp/kinto/caret - reset=false - elif ! [ "${appname}" == "Firefox" ] || [ "${appname}" == "Chromium" ] || [ "${appname}" == "Chromium-browser" ] || [ "${appname}" == "Google-chrome" ] || [ "${appname}" == "Epiphany" ] && [ "${reset}" == false ]; then + if [ "${ln}" == "1" ]; then + appname=$(xprop -id `xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)" | awk '{print $5}'` | grep "WM_CLASS(STRING)" | awk '{print substr($4,2,length($4)-2)}') + if [ "${appname}" == "Firefox" ]; then + # echo "ff ww" + printf 'ff ww %s\n' "1" > /tmp/kinto/caret + elif [ "${appname}" == "Chromium" ] || [ "${appname}" == "Chromium-browser" ] || [ "${appname}" == "Google-chrome" ] || [ "${appname}" == "Epiphany" ]; then + # echo "chrome ww" + printf 'chrome ww %s\n' "1" > /tmp/kinto/caret + else echo "reset" > /tmp/kinto/caret - reset=true fi - - lastapp="$appname" - laststatus="$ln" - #printf '%s\n' "$ln" > /tmp/kinto/caret - # disable wordwise else - if [ "${appname}" == "Firefox" ] && [ "${laststatus}" == "1" ]; then + if [ "${appname}" == "Firefox" ]; then + # echo "ff nw" printf 'ff nw\n' > /tmp/kinto/caret - reset=false - elif [ "${appname}" == "Chromium" ] || [ "${appname}" == "Chromium-browser" ] || [ "${appname}" == "Google-chrome" ] || [ "${appname}" == "Epiphany" ] && [ "${laststatus}" == "1" ]; then + elif [ "${appname}" == "Chromium" ] || [ "${appname}" == "Chromium-browser" ] || [ "${appname}" == "Google-chrome" ] || [ "${appname}" == "Epiphany" ]; then + # echo "chrome nw" printf 'chrome nw\n' > /tmp/kinto/caret - reset=false - elif ! [ "${appname}" == "Firefox" ] || [ "${appname}" == "Chromium" ] || [ "${appname}" == "Chromium-browser" ] || [ "${appname}" == "Google-chrome" ] || [ "${appname}" == "Epiphany" ] && [ "${reset}" == false ]; then + else echo "reset" > /tmp/kinto/caret - reset=true fi - lastapp="$appname" - laststatus="$ln" + fi + +done& + +while (true);do + sleep 0.2 + appname2=$(xprop -id `xprop -root | grep "_NET_ACTIVE_WINDOW(WINDOW)" | awk '{print $5}'` | grep "WM_CLASS(STRING)" | awk '{print substr($4,2,length($4)-2)}') + check=$(cat /tmp/kinto/caret) + millitime=$(cat /tmp/kinto/millitime) + newtime=`date +%s%3N` + difftime=$(( newtime - millitime )) + if (( $difftime > 200 )); then + 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 + 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 + 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 + lastcheck=3 + fi fi done diff --git a/xkeysnail-config/xkeysnail.service b/xkeysnail-config/xkeysnail.service index ff76431..d91f5a3 100644 --- a/xkeysnail-config/xkeysnail.service +++ b/xkeysnail-config/xkeysnail.service @@ -5,7 +5,7 @@ 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 '/home/{username}/.config/kinto/xkeystart.sh "/tmp/kinto/kinto.py"' +ExecStart=/usr/bin/sudo /bin/bash -c '{experimental-caret}/home/{username}/.config/kinto/xkeystart.sh /tmp/kinto/kinto.py' ExecStop=/usr/bin/sudo /usr/bin/killall xkeysnail Restart=on-failure RestartSec=3 diff --git a/xkeysnail_service.sh b/xkeysnail_service.sh index e64cea4..052e5fa 100755 --- a/xkeysnail_service.sh +++ b/xkeysnail_service.sh @@ -16,6 +16,14 @@ if [ $# -eq 0 ]; then fi if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1 == "chromebook" ]]; then + while true; do + read -p "Would you like to enable experimental support for mac back/forward hotkeys in Firefox & Chrome (shares the same hotkey combo as wordwise when needed)? (y/n)" yn + case $yn in + [Yy]* ) exp='/sbin/runuser -l {username} -c "export DISPLAY={displayid};/home/{username}/.config/kinto/caret_status_xkey.sh\&";'; break;; + [Nn]* ) exp=" "; break;; + # * ) echo "Please answer yes or no.";; + esac + done sudo systemctl enable xkeysnail >/dev/null 2>&1 if ! [ -x "$(command -v inotifywait)" ]; then echo "Will need to install inotify-tools to restart key remapper live for config file changes..." @@ -36,8 +44,10 @@ if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1 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 ./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 + sed -i "s#{experimental-caret}#$exp#g" ./xkeysnail-config/xkeysnail.service.new sed -i "s/{username}/`whoami`/g" ./xkeysnail-config/xkeysnail.service.new sed -i "s#{xhost}#`which xhost`#g" ./xkeysnail-config/xkeysnail.service.new sed -i "s/{username}/`whoami`/g" ./xkeysnail-config/limitedadmins.new From 362c48953e59619781f0f3e8aaddb1d7c97813a5 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Sun, 26 Apr 2020 17:28:22 -0500 Subject: [PATCH 13/48] - Added in Chrome buttons for xkeysnail, caret check no detects self to prevent duplicate runs. --- system-config/caret_status_xkey.sh | 7 +++++++ xkeysnail-config/kinto.py | 2 ++ 2 files changed, 9 insertions(+) diff --git a/system-config/caret_status_xkey.sh b/system-config/caret_status_xkey.sh index 3ca9195..999bcb4 100755 --- a/system-config/caret_status_xkey.sh +++ b/system-config/caret_status_xkey.sh @@ -1,5 +1,12 @@ #!/bin/bash +for pid in $(pidof -x caret_status_xkey.sh); do + if [ $pid != $$ ]; then + echo "[$(date)] : caret_status_xkey.sh : Process is already running with PID $pid" + exit 1 + fi +done + mkdir -p /tmp/kinto echo "0" > /tmp/kinto/caret diff --git a/xkeysnail-config/kinto.py b/xkeysnail-config/kinto.py index 5cce379..d78f03a 100644 --- a/xkeysnail-config/kinto.py +++ b/xkeysnail-config/kinto.py @@ -68,6 +68,8 @@ define_keymap(None,{ K("RC-Right"): K("End"), # End of Line # K("RC-Left"): K("C-LEFT_BRACE"), # Firefox-nw - Back # K("RC-Right"): K("C-RIGHT_BRACE"), # Firefox-nw - Forward + # K("RC-Left"): K("M-LEFT"), # Chrome-nw - Back + # K("RC-Right"): K("M-RIGHT"), # Chrome-nw - Forward K("RC-Up"): K("C-Home"), # Beginning of File K("RC-Down"): K("C-End"), # End of File K("M-Backspace"): K("Delete"), # Delete From ca153cca933c0d5646a42e9c6b7adc8a91ea2a2a Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Sun, 26 Apr 2020 18:08:50 -0500 Subject: [PATCH 14/48] - Proper stop support on caret checking for xkeysnail --- xkeysnail-config/xkeysnail.service | 2 +- xkeysnail_service.sh | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/xkeysnail-config/xkeysnail.service b/xkeysnail-config/xkeysnail.service index d91f5a3..8fbc380 100644 --- a/xkeysnail-config/xkeysnail.service +++ b/xkeysnail-config/xkeysnail.service @@ -6,7 +6,7 @@ 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=/usr/bin/sudo /usr/bin/killall xkeysnail +ExecStop=/bin/bash -c '/usr/bin/killall xkeysnail;{kill-caret}' Restart=on-failure RestartSec=3 Environment=DISPLAY={displayid} diff --git a/xkeysnail_service.sh b/xkeysnail_service.sh index 052e5fa..76fa085 100755 --- a/xkeysnail_service.sh +++ b/xkeysnail_service.sh @@ -19,8 +19,8 @@ if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1 while true; do read -p "Would you like to enable experimental support for mac back/forward hotkeys in Firefox & Chrome (shares the same hotkey combo as wordwise when needed)? (y/n)" yn case $yn in - [Yy]* ) exp='/sbin/runuser -l {username} -c "export DISPLAY={displayid};/home/{username}/.config/kinto/caret_status_xkey.sh\&";'; break;; - [Nn]* ) exp=" "; break;; + [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;; # * ) echo "Please answer yes or no.";; esac done @@ -47,7 +47,12 @@ if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1 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 - sed -i "s#{experimental-caret}#$exp#g" ./xkeysnail-config/xkeysnail.service.new + sed -i "s#{experimental-caret}#$exp#g" ./xkeysnail-config/xkeysnail.service.new + if [ "$expsh" != " " ];then + sed -i "s#{kill-caret}#/usr/bin/pkill -f $expsh#g" ./xkeysnail-config/xkeysnail.service.new + else + sed -i "s#{kill-caret}#$expsh#g" ./xkeysnail-config/xkeysnail.service.new + fi sed -i "s/{username}/`whoami`/g" ./xkeysnail-config/xkeysnail.service.new sed -i "s#{xhost}#`which xhost`#g" ./xkeysnail-config/xkeysnail.service.new sed -i "s/{username}/`whoami`/g" ./xkeysnail-config/limitedadmins.new From 6230c189faaf68df37a3637175085e468bbd0665 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Sun, 26 Apr 2020 18:21:33 -0500 Subject: [PATCH 15/48] - Changed inotify for xkeysnail config to monitor mode --- xkeysnail-config/xkeystart.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/xkeysnail-config/xkeystart.sh b/xkeysnail-config/xkeystart.sh index 7a64e39..0c25068 100755 --- a/xkeysnail-config/xkeystart.sh +++ b/xkeysnail-config/xkeystart.sh @@ -1,8 +1,9 @@ #!/bin/bash # >/dev/null 2>&1 /usr/local/bin/xkeysnail --quiet --watch "$1" & -while true - do inotifywait -e close_write,moved_to,create -q "$1" - /usr/bin/killall xkeysnail - /usr/local/bin/xkeysnail --quiet --watch "$1" & + +inotifywait -m -e close_write,moved_to,create -q "$1" | +while read -r path; do + /usr/bin/killall xkeysnail + /usr/local/bin/xkeysnail --quiet --watch "$1" & done \ No newline at end of file From 11133786172d11403aa0d80f84ecec29ff5d3c43 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Sun, 26 Apr 2020 22:38:05 -0500 Subject: [PATCH 16/48] - Added Kinto xkeysnail to the official setup.py file. Updated installer to use mooz xkeysnail over my own fork of it. --- setup.py | 10 +++++++++- xkeysnail_service.sh | 19 ++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 4446977..81bde45 100755 --- a/setup.py +++ b/setup.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -import json, time, os, sys +import json, time, os, sys, subprocess, shlex from shutil import copyfile from subprocess import PIPE, Popen from prekinto import * @@ -329,10 +329,18 @@ if os.path.isdir(homedir + "/.config/kinto") == False: with open('defaults.json') as json_file: data = json.load(json_file) + color_arr = [bcolors.CBEIGE,bcolors.CRED2,bcolors.CGREEN,bcolors.CYELLOW ] print("\nKinto - Type in Linux like it's a Mac.\n") +kintotype = int(input(color_arr[2] + "1) Kinto - xkeysnail (udev/x11) - Recommended\n" + color_arr[0] + "2) Kinto - Original xkb/x11 implementation\n\n" + bcolors.ENDC)) +print("") +if(kintotype == 1): + setShortcuts() + subprocess.check_call(shlex.split("./xkeysnail_service.sh")) + exit() + for index, item in enumerate(data['defaulttypes']): ossym = "" if item == "windows": diff --git a/xkeysnail_service.sh b/xkeysnail_service.sh index 76fa085..5542f05 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 -p "Would you like to enable experimental support for mac back/forward hotkeys in Firefox & Chrome (shares the same hotkey combo as wordwise when needed)? (y/n)" yn + read -rep $'\nExperimental Support for Firefox/Chrome Back/Forward buttons (Cmd+Left/Right)? (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;; @@ -82,14 +82,14 @@ if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1 mv ./xkeysnail-config/kinto.py.new ~/.config/kinto/kinto.py sudo mv ./xkeysnail-config/xkeysnail.service.new /etc/systemd/system/xkeysnail.service xhost +SI:localuser:root - git clone --depth 1 https://github.com/rbreaves/xkeysnail.git + git clone --depth 1 https://github.com/mooz/xkeysnail.git cd xkeysnail sudo pip3 install --upgrade . sudo systemctl enable xkeysnail.service sudo systemctl daemon-reload sudo systemctl restart xkeysnail - echo "Adding xhost fix..." + echo -e "Adding xhost fix...\n" LINE='xhost +SI:localuser:root' @@ -108,6 +108,19 @@ if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1 if test -f "~/.config/autostart/kinto.desktop"; then rm ~/.config/autostart/kinto.desktop fi + + echo -e "Kinto install is \e[1m\e[32mcomplete\e[0m.\n" + if `sudo systemctl is-active --quiet xkeysnail`;then + echo -e "Kinto \e[1m\e[32mxkeysnail service is running\e[0m.\n" + echo "Commands for controlling Kinto's xkeysnail service" + echo "sudo systemctl restart xkeysnail" + echo "sudo systemctl stop xkeysnail" + echo "sudo systemctl start xkeysnail" + echo "sudo systemctl status xkeysnail" + else + echo -e "Kinto \e[1m\e[91mxkeysnail service has failed.\e[0m" + echo "You can run 'sudo systemctl status xkeysnail' for more info" + fi elif ! [[ $1 == "4" || $1 == "uninstall" ]]; then echo "Expected argument was not provided" else From aff8253831379d218057f2ab7f98ef175ae4f5b6 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Sun, 26 Apr 2020 22:49:10 -0500 Subject: [PATCH 17/48] - Added pip3 to xkeysnail installer --- xkeysnail_service.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/xkeysnail_service.sh b/xkeysnail_service.sh index 5542f05..13edb37 100755 --- a/xkeysnail_service.sh +++ b/xkeysnail_service.sh @@ -29,6 +29,11 @@ if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1 echo "Will need to install inotify-tools to restart key remapper live for config file changes..." sudo ./system-config/unipkg.sh inotify-tools fi + if ! [ -x "$(command -v pip3)" ]; then + echo "Will need to install python3-pip..." + sudo ./system-config/unipkg.sh python3-pip + fi + # echo "Transferring files..." mkdir -p ~/.config/kinto From 655a5f902730269d65f59835ee355ff1b42acd0d Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Sun, 26 Apr 2020 23:33:29 -0500 Subject: [PATCH 18/48] Updated readme for xkeysnail --- README.md | 358 ++++++++++-------------------------------------------- 1 file changed, 64 insertions(+), 294 deletions(-) diff --git a/README.md b/README.md index bffdd3d..4e6bbe1 100644 --- a/README.md +++ b/README.md @@ -27,8 +27,7 @@ Kinto works for standard Windows, Apple and Chromebook keyboards. The following - x11 - IBus* - Fedora/RHEL/Manjaro/Arch/Debian/Ubuntu based distro 16.04+ - -Binary is included and will be installed, but you can also compile kintox11.c on your system. You will need to compile and install json-c first as its libraries will be required to compile and run the program. +- xkeysnail (Recommended, but optional) *IBus is needed to support wordwise during browser app usage as the keymap will need to change slightly depending if the cursor/caret is on screen waiting for input. Setup.py will set it but you can manually set it as well or check your current Input Method. @@ -70,7 +69,7 @@ sudo apt install python3 To Uninstall Kinto ``` -./uninstall.sh +./setup.py ``` ## Other Notes Related to Install @@ -108,326 +107,46 @@ git pull origin master Under systemd this is how you control Kinto. +Kinto (xkb/x11) = keyswap + +Kinto (udev/xkeysnail/x11) = xkeysnail + Status ``` systemctl --user status keyswap +sudo systemctl status xkeysnail ``` Stop (your keymap will return to normal) ``` systemctl --user stop keyswap +sudo systemctl stop xkeysnail ``` Start ``` systemctl --user start keyswap +sudo systemctl start xkeysnail ``` Restart ``` systemctl --user restart keyswap +sudo systemctl restart xkeysnail ``` Enable ``` systemctl --user enable keyswap +sudo systemctl enable xkeysnail ``` Disable ``` systemctl --user disable keyswap +sudo systemctl disable xkeysnail ``` -## How to Add Setxkbmap Option inside Kinto - -To summarize you'll need to pull the partial out of the symbols file the option resides in and then add that to the mac_gui file and lastly reference it in the keymap file(s) you want it in. - -symbols directory -``` -/usr/share/X11/xkb/symbols/ -``` - -symbols file -``` -~/.xkb/symbols/mac_gui -``` - -keymap files -``` -~/.xkb/keymap/kbd.mac.gui -~/.xkb/keymap/kbd.mac.term -``` - -A more detailed explaination is here. -https://github.com/rbreaves/kinto/issues/50#issuecomment-595953373 - -## How to Add or Change keymaps for Applications - -Note: All of the following is already done in Kinto (but may also change as improvements are made). The following is purely for documentation and example sake as they are real examples of how to leverage the json config to support additional keymaps. - -**First it is important to understand how Kinto operates.** - -1. It listens for any focus/active window changes -2. It applies the proper keymap based on the programs name. -3. It may monitor your caret/cursor input status, if the app is known to cause shortcut conflicts with wordwise -4. It runs anywhere from 1 to 3 commands to fully remap your computer. - -Ok great, we've covered the basics, now what are your options on modifying functionality? -It depends. - -Do you want to remap keys using xkb or xbindkeys with xdotool, or something else entirely? -The choice is yours, but I'd recommend xbindkeys with xdotool for anyone that doesn't want to spend the time or learn xkb. I prefer xkb but it completely remaps your keyboard and it could break things if done poorly. - -**How to Remap using XBindKeys with Xdotool - Firefox** - -1. By default Firefox is mapped with the standard gui based xkb config, and only if no input has focus does it then run xbindkeys to map the Cmd+Left/Right arrow key location to the Back and Forwards functionality you'd expect. - -2. The xbindkeys script takes into account the xkb mapping being the base because it is actually remapping Home and End to Back and Forwards as there is no real reason to reload an entire xkb layout. - -~/.config/kinto/user_config.json -``` -... -{ - "name": "firefox", - "run": "setxkbmap -option;xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.mac.gui $DISPLAY", - "run_onInput": "killall xbindkeys > /dev/null 2>&1", - "run_offInput": "killall xbindkeys > /dev/null 2>&1;xbindkeys -f $HOME/.config/kinto/.firefox-nw", - "symbols": "", - "types": "", - "de": [ - 2 - ], - "appnames": [ - "Firefox" - ] -}, -... -``` -~/.config/kinto/.firefox-nw -``` -"xdotool key --delay 0 --clearmodifiers Control_L+bracketleft" - // Alt/Cmd + Left - Home + Release - -"xdotool key --delay 0 --clearmodifiers Control_L+bracketright" - // Alt/Cmd + Right - End + Release - -# Note additional keymaps can easily be added to this file and I will accept any PR's with keymaps that align with macs -``` - -Once you have made your changes you can restart the Kinto service and the changes will take affect. -``` -systemctl --user restart keyswap -``` - -Under normal circumstances this keymap would not have worked well had Firefox not included 2 keymap options for going forwards or back. In the next example, Chrome, you will see how to solve this very same problem but in xkb format and it is the only way to fix it for Chrome due to conflicting with wordwise shortcuts. - -Also the choice of xdotool over something like xte (xautomation) was explicit, xdotool allows you to hold down a modifier and continue to repeat the action(s) and xte does not. - -**How to Remap Using XKB - Chrome** - -This gets to be a little more complicated, but this is what you have to do to accomplish the same on the xkb level. - -**Summary** -1. Copy ~/.xkb/keymap/kbd.mac.gui and append the name of the app. (e.g. chrome) -2. Edit ~/.xkb/keymap/kbd.mac.gui.chrome -3. Add new keybindings to ~/.xkb/symbols/mac_gui -4. Only edit types if you absolutely need to add another modifier level (~/.xkb/types/mac_gui) - -Understand that as you add or modify the ~/.xkb/symbols/ files that these two groups **symbols[Group1]** and **actions[Group1]** will be following the order of the modifier levels that are configured in the related ~/.xkb/types/mac_gui or mac_term file. - -Also you will have to discover the proper xkb names for keys and that they will often follow *two different* labels/names. eg RGHT vs Right ... **replace key \** vs **symbols[Group1]= [ Right, ...**. - -A good place to get the proper names/labels are these two files. -``` -/usr/share/X11/xkb/symbols/us -/usr/share/X11/xkb/symbols/inet -``` - -Ok, so here are the detailed instructions. - -1. cp ~/.xkb/keymap/kbd.mac.gui ~/.xkb/keymap/kbd.mac.gui.chrome - -2. nano ~/.xkb/keymap/kbd.mac.gui.chrome -``` -# Change mac_gui(mac_levelssym) -... -xkb_symbols { include "pc+us+us:2+inet(evdev)+ctrl(swap_lwin_lctl)+ctrl(swap_rwin_rctl)+mac_gui(mac_levelssym)" }; -... -# To +mac_gui(mac_chrome) -xkb_symbols { include "pc+us+us:2+inet(evdev)+ctrl(swap_lwin_lctl)+ctrl(swap_rwin_rctl)+mac_gui(mac_chrome)" }; -... -}; -``` - -3. Add your new "partial xkb_symbols" via nano ~/.xkb/symbols/mac_gui -``` -partial xkb_symbols "mac_chrome" { - // Back Button - replace key { - type[Group1]= "ONE_LEVEL_CTRL", - symbols[Group1]= [ - Left, - Left, - Left - ], - actions[Group1]= [ - NoAction(), - RedirectKey(key=), - RedirectKey(key=,modifiers=Mod1,clearmods=Control) - ] - }; - // Forwards Button - replace key { - type[Group1]= "ONE_LEVEL_CTRL", - symbols[Group1]= [ - Right, - Right, - Right - ], - actions[Group1]= [ - NoAction(), - RedirectKey(key=), - RedirectKey(key=,modifiers=Mod1,clearmods=Control) - ] - }; -``` - -~/.config/kinto/user_config.json -``` -{ - "name": "chrome", - "run": "setxkbmap -option;xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.mac.gui.chrome $DISPLAY", - "run_onInput": "xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.mac.gui $DISPLAY", - "run_offInput": "xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.mac.gui.chrome $DISPLAY", - "symbols": "", - "types": "", - "de": [ - 2 - ], - "appnames": [ - "Chromium", - "Chromium-browser", - "Google-chrome" - ] -} -``` -4. Not making changes to types but it looks like this. It contains 5 levels of modifiers, Base, Alt, Control, Shift+Control, and Shift+Alt. Additional Levels can and may be added later, but please do not change the order of the Levels or existing symbols files will break!! You can add new levels however without issue. -``` -default partial xkb_types "addmac_levels" { - type "ONE_LEVEL_CTRL" { - modifiers= Mod1+Control+Shift; - map[Mod1]= Level2; - map[Control]= Level3; - map[Mod1+Control]= Level3; - map[Shift+Control]= Level4; - map[Shift+Mod1] = Level5; - level_name[Level1]= "Base"; - level_name[Level2]= "Alt"; - level_name[Level3]= "Control"; - level_name[Level4]= "Shift with Control"; - level_name[Level5] = "Shift Alt"; - }; -}; -``` - -Once you have made your changes you can restart the Kinto service and the changes will take affect. -``` -systemctl --user restart keyswap -``` - -## JSON config files - -Features -- Unlimited keyboard configurations per App/category (user_config.json - config -> create app object) -- Dynamic Desktop Environment shortcut capabilities (user_config.json - de -> create DE tweak/remap) - -Located at ~/.config/kinto/ you will find user_config.json which will look like the following after an install. You can modify the defaults.json file in the root directory of kinto to create additional keyboard layout types/support without needing to modify any of the underlying Kinto code. - -You can also add additional Desktop Environment related tweaks to user_config.json in the install directory as well and the installer will prompt you to install them. You may also fork and submit any json or additional .xkb configurations to me for approval if you believe it makes Linux more like typing on a Mac. - -``` -{"config":[ - // - // Each config category contains the category name, and references to the de tweaks - // And contains the default run commands plus what behavior they should exhibit for - // input fields on/off focus, if any. - // Symbols and types are not currently used - may later replace the need for static - // files with xkbcomp. - // - // If you use xbindkeys outside of Kinto then you may want to remove xbindkeys from - // this config after setup or rewrite the command to exclude your own xbindkeys. - // - { - "name":"gui", - "run":"setxkbmap -option;xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.mac.gui $DISPLAY", - "de":[2], - "appnames":[ "" ], - "run_onInput":"", - "run_offInput": "killall xbindkeys > /dev/null 2>&1", - "symbols":"", - "types":"", - "de":[], - "appnames":[ "" ] - }, - { - "name":"term", - "run":"setxkbmap -option;xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.mac.term $DISPLAY", - "de":[2], - "appnames":[ "Gnome-terminal","konsole","io.elementary.terminal","terminator","sakura","guake","tilda","xterm","eterm","kitty" ], - "run_onInput":"", - "run_offInput": "killall xbindkeys > /dev/null 2>&1", - "symbols":"", - "types":"", - "de":[], - "appnames":[ "" ] - }], - // Init - Array that references de objects by their ID and runs the "run" command - // when the app initially runs. - "init": [1], - // detypes - DE's with support or planned support - "detypes":["gnome2","gnome3","kde4","kde5","xfce","i3wm"], - // de - tweak objects and initial command to be ran on start. - // - // Intent - init or gui_term, to signify what type of tweak it is. - // run, run_term, run_gui - run is only relevant for init, and the - // other two relate to gui_term and running under those modes. - "de":[{ - "id": 1, - "type": ["gnome3"], - "active": false, - "intent":"init", - "name":"gnome-init", - "description":"Gnome - Remove Superkey Overlay keybinding to Activities Overview", - "run":"gsettings set org.gnome.mutter overlay-key ''", - "run_term":"", - "run_gui":"" - }, - { - "id": 2, - "type": ["gnome3"], - "active": false, - "intent":"gui_term", - "name":"Gnome Activities Overview", - "description":"Cmd+Space activates Activities Overview", - "run":"", - "run_term":"gsettings set org.gnome.desktop.wm.keybindings panel-main-menu \"['Space']\"", - "run_gui":"gsettings set org.gnome.desktop.wm.keybindings panel-main-menu \"['Space']\"" - }, - { - "id": 3, - "type": ["kde5"], - "active": false, - "intent":"init", - "name":"kde-init", - "description":"KDE Plasma 5 - Removes Superkey Overlay from the Launcher Menu", - "run":"kwriteconfig5 --file ~/.config/kwinrc --group ModifierOnlyShortcuts --key Meta \"\";qdbus org.kde.KWin /KWin reconfigure", - "run_term":"", - "run_gui":"" - }] -} -``` ## Learning macOS style hotkeys on Linux @@ -442,13 +161,25 @@ systemctl --user stop keyswap && setxkbmap -option;setxkbmap -option altwin:swap ### Does not start when you log in or after you reboot? +Kinto (xkb/x11) = keyswap + +Kinto (udev/xkeysnail/x11) = xkeysnail + 1. Check the status ``` systemctl --user status keyswap +sudo systemctl status xkeysnail ``` 2. Check the service journal ``` journalctl --user-unit=keyswap.service -b +sudo journalctl --unit=xkeysnail.service -b +``` + +Note: You can also watch your log live +``` +journalctl -l --user-unit=keyswap.service -b +sudo journalctl -l --unit=xkeysnail.service -b ``` You may need to manually set your DISPLAY in the systemd service file. Normally it pulls in the proper DISPLAY value but if it doesn't you can try this. @@ -460,6 +191,8 @@ echo $DISPLAY ``` nano ~/.config/systemd/user/keyswap.service + +sudo nano /etc/systemd/system/xkeysnail.service ``` ... [Service] @@ -473,18 +206,26 @@ If you continue to have issues then open a ticket and send me the info. ### Keyswap is not occurring, but it was working. -Now that Kinto is using a custom written C program I am not aware of any specific bugs or issues, but you can start here if you having difficulties and please report it if it is reproducible. +Kinto (xkb/x11) = keyswap + +Kinto (udev/xkeysnail/x11) = xkeysnail + +Now that Kinto (xkb/x11) is using a custom written C program I am not aware of any specific bugs or issues, but you can start here if you having difficulties and please report it if it is reproducible. + 1. Get status ``` systemctl --user status keyswap +sudo systemctl status xkeysnail ``` 2. Restart Kinto ``` systemctl --user restart keyswap +sudo systemctl restart xkeysnail ``` 3. Check the Status again and open a ticket if you need to. ``` systemctl --user status keyswap +sudo systemctl status xkeysnail ``` You can also do the following to see if it is an actual issue with kintox11 not running or your service file. @@ -497,12 +238,39 @@ cd ~/.config/kinto If all else fails you can now run Kinto in debug mode as of 1.0.6-2. The output will become more verbose and I'd recommend running this directly after stopping the service. +Kinto (xkb/x11) ``` systemctl --user stop keyswap cd ~/.config/kinto ./kintox11 --debug ``` +Kinto (udev/xkeysnail) + +Stop +``` +sudo systemctl stop xkeysnail +``` +nano ~/.config/kinto/xkeystart.sh + +Remove the 2 instances of --quiet and resave +``` +#!/bin/bash + +/usr/local/bin/xkeysnail --quiet --watch "$1" & + +inotifywait -m -e close_write,moved_to,create -q "$1" | +while read -r path; do + /usr/bin/killall xkeysnail + /usr/local/bin/xkeysnail --quiet --watch "$1" & +done +``` +Start +``` +sudo systemctl start xkeysnail +sudo systemctl status xkeysnail +``` + ## Language Support I'd appreciate any help from people with non-US based keyboards, to help ensure that these keymaps and keyswap methods work in all or most languages. @@ -547,5 +315,7 @@ Lastly these four people were also very helpful to me as well. @probonopd for be If I left anyone out then I apologize, that was not intentional. I am happy to say that this project is at a state of completion. Bug fixes will primarily be the only activity happening going forward and possibly a rewrite for Wayland at some point. Contributions as mentioned above are welcomed, and will be merged into master if they help with the goal of making typing on linux more like a mac. *https://askubuntu.com/questions/1010276/can-i-act-on-the-event-that-a-window-opens-without-polling + **https://gist.github.com/kui/2622504 + ***https://medium.com/@probonopd/make-it-simple-linux-desktop-usability-part-1-5fa0fb369b42 From cb6cf4f886092d333233ae7a4261bca6ca5befcb Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Sun, 26 Apr 2020 23:57:00 -0500 Subject: [PATCH 19/48] - Updated service to end additional xkeysnail processes --- xkeysnail-config/xkeysnail.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xkeysnail-config/xkeysnail.service b/xkeysnail-config/xkeysnail.service index 8fbc380..aeb9a23 100644 --- a/xkeysnail-config/xkeysnail.service +++ b/xkeysnail-config/xkeysnail.service @@ -6,7 +6,7 @@ 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 '/usr/bin/killall xkeysnail;{kill-caret}' +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}' Restart=on-failure RestartSec=3 Environment=DISPLAY={displayid} From 496240dfe151a9c681da81e42ca6caca87e1abf3 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Mon, 27 Apr 2020 01:11:28 -0500 Subject: [PATCH 20/48] - 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 From 1743b7d46dee9650a1d5b041648208bf19554e65 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Mon, 27 Apr 2020 01:18:27 -0500 Subject: [PATCH 21/48] Updated readme to include xkeysnail shortcut info --- README.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/README.md b/README.md index 4e6bbe1..d03cb28 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,35 @@ To Uninstall Kinto ./setup.py ``` +## Shortcut Creation + +**Keys** +C,Ctrl = Control +M,Alt = Alt/Option +Super = Win/Super + +You can define new keymaps for your specific app via this method. You also do not have to cancel out the original keybinding if you do not need or want to, but you can do so with "pass_through_key". + +### Defining Keymaps Per App +``` +# Keybindings for Sublime Text +define_keymap(re.compile("Sublime_text"),{ + K("C-h"): pass_through_key, # cancel replace + K("C-M-f"): K("C-h"), # replace + K("C-M-v"): [K("C-k"), K("C-v")], # paste_from_history +} +``` + +In the above example I am also showing that you can define a single shortcut to enact multiple shortcut keys if needed by defining an array of shortcuts to trigger. + +You can also make changes to the file in your /tmp/kinto/xkeysnail/kinto.py location and see them take affect in real time, but for your changes to be permanent you will need to make your changes in the ~/.config/kinto/kinto.py location & restart the xkeysnail service. + +``` +sudo systemctl restart xkeysnail +``` + +More information can be seen on the readme page of [xkeysnail](https://github.com/mooz/xkeysnail). + ## Other Notes Related to Install **Manjaro with Gnome there are issues.** From 15f9195da64b933cc75005edc1e9aef26724c96f Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Mon, 27 Apr 2020 01:37:57 -0500 Subject: [PATCH 22/48] - Adds selection based wordwise hotkeys to xkeysnail --- xkeysnail-config/kinto.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/xkeysnail-config/kinto.py b/xkeysnail-config/kinto.py index d78f03a..d5780dd 100644 --- a/xkeysnail-config/kinto.py +++ b/xkeysnail-config/kinto.py @@ -64,17 +64,21 @@ define_keymap(None,{ K("LC-Grave") : K("LC-Shift-Tab"), # Wordwise - K("RC-Left"): K("Home"), # Beginning of Line - K("RC-Right"): K("End"), # End of Line - # K("RC-Left"): K("C-LEFT_BRACE"), # Firefox-nw - Back - # K("RC-Right"): K("C-RIGHT_BRACE"), # Firefox-nw - Forward - # K("RC-Left"): K("M-LEFT"), # Chrome-nw - Back - # K("RC-Right"): K("M-RIGHT"), # Chrome-nw - Forward - K("RC-Up"): K("C-Home"), # Beginning of File - K("RC-Down"): K("C-End"), # End of File - K("M-Backspace"): K("Delete"), # Delete - # K(""): pass_through_key, # cancel - # K(""): K(""), # + K("RC-Left"): K("Home"), # Beginning of Line + K("RC-Shift-Left"): K("Shift-Home"), # Select all to Beginning of Line + K("RC-Right"): K("End"), # End of Line + K("RC-Shift-Right"): K("Shift-End"), # Select all to End of Line + # K("RC-Left"): K("C-LEFT_BRACE"), # Firefox-nw - Back + # K("RC-Right"): K("C-RIGHT_BRACE"), # Firefox-nw - Forward + # K("RC-Left"): K("M-LEFT"), # Chrome-nw - Back + # K("RC-Right"): K("M-RIGHT"), # Chrome-nw - Forward + K("RC-Up"): K("C-Home"), # Beginning of File + K("RC-Shift-Up"): K("C-Shift-Home"), # Select all to Beginning of File + K("RC-Down"): K("C-End"), # End of File + K("RC-Shift-Down"): K("C-Shift-End"), # Select all to End of File + K("M-Backspace"): K("Delete"), # Delete + # K(""): pass_through_key, # cancel + # K(""): K(""), # }) define_keymap(lambda wm_class: wm_class not in ("Code"),{ From bd84ad9cfcfd656aa58e03e8d1865a7e16ac209b Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Mon, 27 Apr 2020 02:03:23 -0500 Subject: [PATCH 23/48] - Updated wordwise xkeysnail for word select --- xkeysnail-config/kinto.py | 6 ++++-- xkeysnail-config/vscode_keybindings.json | 10 ++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/xkeysnail-config/kinto.py b/xkeysnail-config/kinto.py index d5780dd..2ab7fcb 100644 --- a/xkeysnail-config/kinto.py +++ b/xkeysnail-config/kinto.py @@ -83,8 +83,10 @@ define_keymap(None,{ define_keymap(lambda wm_class: wm_class not in ("Code"),{ # Wordwise remaining - for Everything but VS Code - K("M-Left"): K("C-Left"), # Left of Word - K("M-Right"): K("C-Right"), # Right of Word + K("M-Left"): K("C-Left"), # Left of Word + K("M-Shift-Left"): K("C-Shift-Left"), # Select Left of Word + K("M-Right"): K("C-Right"), # Right of Word + K("M-Shift-Right"): K("C-Shift-Right"), # Select Right of Word # ** VS Code fix ** # Electron issue precludes normal keybinding fix. # Alt menu auto-focus/toggle gets in the way. diff --git a/xkeysnail-config/vscode_keybindings.json b/xkeysnail-config/vscode_keybindings.json index 30d4657..750f5ac 100644 --- a/xkeysnail-config/vscode_keybindings.json +++ b/xkeysnail-config/vscode_keybindings.json @@ -17,5 +17,15 @@ { "key": "alt+left", "command": "cursorWordLeft" + }, + { + "key": "shift+alt+left", + "command": "cursorWordStartLeftSelect", + "when": "textInputFocus" + }, + { + "key": "shift+alt+right", + "command": "cursorWordEndRightSelect", + "when": "textInputFocus" } ] \ No newline at end of file From c442a0fceb7138aee6a5fbb41607a460e707eef2 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Mon, 27 Apr 2020 16:31:54 -0500 Subject: [PATCH 24/48] - Corrected typo that broke xkeysnail install. Closes #127 --- xkeysnail_service.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xkeysnail_service.sh b/xkeysnail_service.sh index 949a4df..bcad0cf 100755 --- a/xkeysnail_service.sh +++ b/xkeysnail_service.sh @@ -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/fprexk.sh ~/.config/kinto/prexk.sh + yes | cp -rf ./xkeysnail-config/prexk.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 From 31baab1b3499c07bfcba0f4edf86e5c36d8652d4 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Mon, 27 Apr 2020 16:58:44 -0500 Subject: [PATCH 25/48] Fixed formatting in readme --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d03cb28..176d383 100644 --- a/README.md +++ b/README.md @@ -75,9 +75,11 @@ To Uninstall Kinto ## Shortcut Creation **Keys** -C,Ctrl = Control -M,Alt = Alt/Option -Super = Win/Super +| Value| Description| +| ----- |:--------:| +|C,Ctrl|Control| +|M,Alt| Alt/Option| +|Super | Win/Super| You can define new keymaps for your specific app via this method. You also do not have to cancel out the original keybinding if you do not need or want to, but you can do so with "pass_through_key". @@ -86,7 +88,7 @@ You can define new keymaps for your specific app via this method. You also do no # Keybindings for Sublime Text define_keymap(re.compile("Sublime_text"),{ K("C-h"): pass_through_key, # cancel replace - K("C-M-f"): K("C-h"), # replace + K("Ctrl-Alt-f"): K("Ctrl-h"), # replace K("C-M-v"): [K("C-k"), K("C-v")], # paste_from_history } ``` From ce125d4c1f161c63b3859d1616f37018e8afc86d Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Mon, 27 Apr 2020 17:01:43 -0500 Subject: [PATCH 26/48] Additional format and description changes --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 176d383..1979b63 100644 --- a/README.md +++ b/README.md @@ -75,11 +75,11 @@ To Uninstall Kinto ## Shortcut Creation **Keys** -| Value| Description| -| ----- |:--------:| -|C,Ctrl|Control| -|M,Alt| Alt/Option| -|Super | Win/Super| +| Value| Description|Mac/Kinto Equivalent| +| ----- |:--------:|:--------:| +|C,Ctrl|Control|Cmd| +|M,Alt| Alt/Option|Alt/Option| +|Super | Win/Super|Ctrl| You can define new keymaps for your specific app via this method. You also do not have to cancel out the original keybinding if you do not need or want to, but you can do so with "pass_through_key". @@ -88,7 +88,7 @@ You can define new keymaps for your specific app via this method. You also do no # Keybindings for Sublime Text define_keymap(re.compile("Sublime_text"),{ K("C-h"): pass_through_key, # cancel replace - K("Ctrl-Alt-f"): K("Ctrl-h"), # replace + K("Ctrl-Alt-f"): K("Ctrl-h"), # replace K("C-M-v"): [K("C-k"), K("C-v")], # paste_from_history } ``` From 2f3e59b80c77ceff17ea3671800a5dbdc5d0166b Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Mon, 27 Apr 2020 17:05:22 -0500 Subject: [PATCH 27/48] Additional key legend for readme --- README.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1979b63..8047adb 100644 --- a/README.md +++ b/README.md @@ -72,15 +72,22 @@ To Uninstall Kinto ./setup.py ``` -## Shortcut Creation +## Shortcut Creation (Xkeysnail) -**Keys** +**GUI Keys** | Value| Description|Mac/Kinto Equivalent| | ----- |:--------:|:--------:| |C,Ctrl|Control|Cmd| |M,Alt| Alt/Option|Alt/Option| |Super | Win/Super|Ctrl| +**Terminal Keys** +| Value| Description|Mac/Kinto Equivalent| +| ----- |:--------:|:--------:| +|RC,RCtrl|Right Control on Left & Right Alt/Cmd key|Cmd| +|M,Alt| Alt/Option|Alt/Option| +|Ctrl | Ctrl|Ctrl| + You can define new keymaps for your specific app via this method. You also do not have to cancel out the original keybinding if you do not need or want to, but you can do so with "pass_through_key". ### Defining Keymaps Per App From 00cc80036c96fcf2226780ab7bb8bf5a43345b36 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Mon, 27 Apr 2020 20:04:00 -0500 Subject: [PATCH 28/48] - Corrected issue that prevented all xkeysnail service related threads from closing after service stops --- xkeysnail-config/xkeysnail.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xkeysnail-config/xkeysnail.service b/xkeysnail-config/xkeysnail.service index 0a07509..c817db8 100644 --- a/xkeysnail-config/xkeysnail.service +++ b/xkeysnail-config/xkeysnail.service @@ -6,7 +6,7 @@ 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/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}' +ExecStop=/bin/bash -c 'me=$$;ps -ef | grep \'[t]mp/kinto\' | 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} From 3f5064c28ccd09e5b341d00ce013fb2b9761f017 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Mon, 27 Apr 2020 20:13:21 -0500 Subject: [PATCH 29/48] - Added Nautilus Cmd-Arrows hotkeys for traversing directories. Closes #118 --- xkeysnail-config/kinto.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/xkeysnail-config/kinto.py b/xkeysnail-config/kinto.py index 2ab7fcb..202ae0a 100644 --- a/xkeysnail-config/kinto.py +++ b/xkeysnail-config/kinto.py @@ -51,6 +51,14 @@ define_conditional_modmap(re.compile("Gnome-terminal|konsole|io.elementary.termi # Key.RIGHT_CTRL: Key.LEFT_CTRL, # Mac }) +# Keybindings for Nautilus +define_keymap(re.compile("Org.gnome.Nautilus"),{ + K("RC-Up"): K("M-Up"), # Go Up dir + K("RC-Down"): K("M-Down"), # Go Down dir + K("RC-Left"): K("M-Left"), # Go Back + K("RC-Right"): K("M-Right"), # Go Forward +}) + define_keymap(None,{ # Cmd Tab - App Switching Default K("RC-Tab"): K("RC-F13"), From e4d710d5ae549ec6d6aacda6fe8f2e4c9cd76294 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Tue, 28 Apr 2020 00:59:29 -0500 Subject: [PATCH 30/48] - Corrected Cmd+Tab remaps for Gnome and KDE w/ xkeysnail --- setup.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/setup.py b/setup.py index 81bde45..9ea62ec 100755 --- a/setup.py +++ b/setup.py @@ -53,8 +53,12 @@ def setShortcuts(): if dename == "gnome": cmdline('dconf dump /org/gnome/desktop/wm/keybindings/ > keybindings_`date +"%Y.%m.%d-%s"`.conf') cmdline('dconf dump /org/gnome/mutter/keybindings/ > mutter_`date +"%Y.%m.%d-%s"`.conf') - cmdline("gsettings set org.gnome.desktop.wm.keybindings switch-applications \"['F13','F13','Tab']\"") - cmdline("gsettings set org.gnome.desktop.wm.keybindings switch-applications-backward \"['F14','F14','Tab']\"") + if(kintotype == 1): + cmdline("gsettings set org.gnome.desktop.wm.keybindings switch-applications \"['Tools','Tab']\"") + cmdline("gsettings set org.gnome.desktop.wm.keybindings switch-applications-backward \"['Tools','Tab']\"") + else: + cmdline("gsettings set org.gnome.desktop.wm.keybindings switch-applications \"['F13','F13','Tab']\"") + cmdline("gsettings set org.gnome.desktop.wm.keybindings switch-applications-backward \"['F14','F14','Tab']\"") cmdline("gsettings set org.gnome.desktop.wm.keybindings minimize \"['h','F9']\"") cmdline("gsettings set org.gnome.desktop.wm.keybindings panel-main-menu \"['Space','Space']\"") if distro == "ubuntu" and dename == "gnome": @@ -74,8 +78,12 @@ def setShortcuts(): cmdline("gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-left ['']") cmdline("gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-right ['']") elif distro == "elementary" and dename == "gnome": - cmdline("gsettings set org.gnome.desktop.wm.keybindings switch-applications \"['F13','F13','Tab']\"") - cmdline("gsettings set org.gnome.desktop.wm.keybindings switch-applications-backward \"['F14','F14','Tab']\"") + if(kintotype == 1): + cmdline("gsettings set org.gnome.desktop.wm.keybindings switch-applications \"['Tools','Tab']\"") + cmdline("gsettings set org.gnome.desktop.wm.keybindings switch-applications-backward \"['Tools','Tab']\"") + else: + cmdline("gsettings set org.gnome.desktop.wm.keybindings switch-applications \"['F13','F13','Tab']\"") + cmdline("gsettings set org.gnome.desktop.wm.keybindings switch-applications-backward \"['F14','F14','Tab']\"") cmdline("gsettings set org.gnome.desktop.wm.keybindings show-desktop \"['d','Down']\"") cmdline("gsettings set org.gnome.desktop.wm.keybindings toggle-maximized \"['F10','Up']\"") cmdline("gsettings set org.gnome.desktop.wm.keybindings panel-main-menu \"['Space','Space']\"") @@ -134,9 +142,13 @@ def setShortcuts(): cmdline('cp ~/.config/kglobalshortcutsrc ./kde_kglobalshortcutsrc_`date +"%Y.%m.%d-%s"`') cmdline('kwriteconfig5 --file "$HOME/.config/kglobalshortcutsrc" --group "kwin" --key "Switch to Previous Desktop" "Meta+Left,Meta+Left,Switch to Previous Desktop"') cmdline('kwriteconfig5 --file "$HOME/.config/kglobalshortcutsrc" --group "kwin" --key "Window Operations Menu" "none,Alt+F3,Window Operations Menu"') - cmdline('kwriteconfig5 --file "$HOME/.config/kglobalshortcutsrc" --group "kwin" --key "Walk Through Windows" "Ctrl+F13,Alt+Tab,Walk Through Windows"') + if(kintotype == 1): + cmdline('kwriteconfig5 --file "$HOME/.config/kglobalshortcutsrc" --group "kwin" --key "Walk Through Windows" "Ctrl+Tools,Alt+Tab,Walk Through Windows"') + cmdline('kwriteconfig5 --file "$HOME/.config/kglobalshortcutsrc" --group "kwin" --key "Walk Through Windows (Reverse)" "Ctrl+Shift+Tools,Alt+Shift+Backtab,Walk Through Windows (Reverse)"') + else: + cmdline('kwriteconfig5 --file "$HOME/.config/kglobalshortcutsrc" --group "kwin" --key "Walk Through Windows" "Ctrl+F13,Alt+Tab,Walk Through Windows"') + cmdline('kwriteconfig5 --file "$HOME/.config/kglobalshortcutsrc" --group "kwin" --key "Walk Through Windows (Reverse)" "Ctrl+Shift+F14,Alt+Shift+Backtab,Walk Through Windows (Reverse)"') cmdline('kwriteconfig5 --file "$HOME/.config/kglobalshortcutsrc" --group "kwin" --key "Walk Through Windows Alternative" "none,none,Walk Through Windows"') - cmdline('kwriteconfig5 --file "$HOME/.config/kglobalshortcutsrc" --group "kwin" --key "Walk Through Windows (Reverse)" "Ctrl+Shift+F14,Alt+Shift+Backtab,Walk Through Windows (Reverse)"') cmdline('kwriteconfig5 --file "$HOME/.config/kglobalshortcutsrc" --group "kwin" --key "Maximize Window" "none,Meta+PgUp,Maximize Window"') cmdline('kwriteconfig5 --file "$HOME/.config/kglobalshortcutsrc" --group "kwin" --key "Window Maximize" "Meta+Ctrl+F,Alt+F10,Maximize Window"') cmdline('kwriteconfig5 --file "$HOME/.config/kglobalshortcutsrc" --group "kwin" --key "Minimize Window" "Meta+h,Meta+PgDown,Minimize Window"') From 303023d90ffc4a6b83593da750d509813bbbc2f6 Mon Sep 17 00:00:00 2001 From: Ryan Reaves Date: Tue, 28 Apr 2020 01:48:48 -0500 Subject: [PATCH 31/48] - Corrected Cmd+Tab remaps for GalliumOS --- xkeysnail-config/kinto.py | 47 +++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/xkeysnail-config/kinto.py b/xkeysnail-config/kinto.py index 202ae0a..5b5c0b4 100644 --- a/xkeysnail-config/kinto.py +++ b/xkeysnail-config/kinto.py @@ -61,32 +61,35 @@ define_keymap(re.compile("Org.gnome.Nautilus"),{ define_keymap(None,{ # Cmd Tab - App Switching Default - K("RC-Tab"): K("RC-F13"), - K("RC-Shift-Tab"): K("RC-Shift-F13"), - K("RC-Grave"): K("RC-Shift-F13"), + K("RC-Tab"): K("RC-F13"), # Default + K("RC-Shift-Tab"): K("RC-Shift-F13"), # Default + K("RC-Grave"): K("RC-Shift-F13"), # Default + # K("RC-Tab"): K("RC-backslash"), # Chromebook + # K("RC-Shift-Tab"): K("RC-Shift-backslash"), # Chromebook + # K("RC-Grave"): K("RC-Shift-backslash"), # Chromebook # In-App Tab switching - # K("M-Tab"): K("C-Tab"), # Chromebook - In-App Tab switching - # K("M-Shift-Tab"): K("C-Shift-Tab"), # Chromebook - In-App Tab switching - K("Super-Tab"): K("LC-Tab"), # Default - K("Super-Shift-Tab"): K("LC-Shift-Tab"), # Default + # K("M-Tab"): K("C-Tab"), # Chromebook - In-App Tab switching + # K("M-Shift-Tab"): K("C-Shift-Tab"), # Chromebook - In-App Tab switching + K("Super-Tab"): K("LC-Tab"), # Default + K("Super-Shift-Tab"): K("LC-Shift-Tab"), # Default K("LC-Grave") : K("LC-Shift-Tab"), # Wordwise - K("RC-Left"): K("Home"), # Beginning of Line - K("RC-Shift-Left"): K("Shift-Home"), # Select all to Beginning of Line - K("RC-Right"): K("End"), # End of Line - K("RC-Shift-Right"): K("Shift-End"), # Select all to End of Line - # K("RC-Left"): K("C-LEFT_BRACE"), # Firefox-nw - Back - # K("RC-Right"): K("C-RIGHT_BRACE"), # Firefox-nw - Forward - # K("RC-Left"): K("M-LEFT"), # Chrome-nw - Back - # K("RC-Right"): K("M-RIGHT"), # Chrome-nw - Forward - K("RC-Up"): K("C-Home"), # Beginning of File - K("RC-Shift-Up"): K("C-Shift-Home"), # Select all to Beginning of File - K("RC-Down"): K("C-End"), # End of File - K("RC-Shift-Down"): K("C-Shift-End"), # Select all to End of File - K("M-Backspace"): K("Delete"), # Delete - # K(""): pass_through_key, # cancel - # K(""): K(""), # + K("RC-Left"): K("Home"), # Beginning of Line + K("RC-Shift-Left"): K("Shift-Home"), # Select all to Beginning of Line + K("RC-Right"): K("End"), # End of Line + K("RC-Shift-Right"): K("Shift-End"), # Select all to End of Line + # K("RC-Left"): K("C-LEFT_BRACE"), # Firefox-nw - Back + # K("RC-Right"): K("C-RIGHT_BRACE"), # Firefox-nw - Forward + # K("RC-Left"): K("M-LEFT"), # Chrome-nw - Back + # K("RC-Right"): K("M-RIGHT"), # Chrome-nw - Forward + K("RC-Up"): K("C-Home"), # Beginning of File + K("RC-Shift-Up"): K("C-Shift-Home"), # Select all to Beginning of File + K("RC-Down"): K("C-End"), # End of File + K("RC-Shift-Down"): K("C-Shift-End"), # Select all to End of File + K("M-Backspace"): K("Delete"), # Delete + # K(""): pass_through_key, # cancel + # K(""): K(""), # }) define_keymap(lambda wm_class: wm_class not in ("Code"),{ From da1e38d7519b07e08cb75d62b52f38daba2ee0c8 Mon Sep 17 00:00:00 2001 From: Ryan Reaves Date: Tue, 28 Apr 2020 02:02:32 -0500 Subject: [PATCH 32/48] - Added grave for reverse Ctrl+Tab, GalliumOS. --- xkeysnail-config/kinto.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/xkeysnail-config/kinto.py b/xkeysnail-config/kinto.py index 5b5c0b4..5e94bc0 100644 --- a/xkeysnail-config/kinto.py +++ b/xkeysnail-config/kinto.py @@ -70,9 +70,10 @@ define_keymap(None,{ # In-App Tab switching # K("M-Tab"): K("C-Tab"), # Chromebook - In-App Tab switching # K("M-Shift-Tab"): K("C-Shift-Tab"), # Chromebook - In-App Tab switching - K("Super-Tab"): K("LC-Tab"), # Default - K("Super-Shift-Tab"): K("LC-Shift-Tab"), # Default - K("LC-Grave") : K("LC-Shift-Tab"), + # K("M-Grave") : K("C-Shift-Tab"), # Chromebook - In-App Tab switching + K("Super-Tab"): K("LC-Tab"), # Default + K("Super-Shift-Tab"): K("LC-Shift-Tab"), # Default + K("LC-Grave") : K("LC-Shift-Tab"), # Default # Wordwise K("RC-Left"): K("Home"), # Beginning of Line From 4e428e79c18fa3e530586be7ab4c2b7ac79e11fa Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Tue, 28 Apr 2020 15:51:47 -0500 Subject: [PATCH 33/48] Updated readme to reference older shortcut method --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 8047adb..2cd56af 100644 --- a/README.md +++ b/README.md @@ -110,6 +110,9 @@ sudo systemctl restart xkeysnail More information can be seen on the readme page of [xkeysnail](https://github.com/mooz/xkeysnail). +## Shortcut Creation (XKB) +The older xkb shortcut method info can be read about in ticket [#125](https://github.com/rbreaves/kinto/issues/125). + ## Other Notes Related to Install **Manjaro with Gnome there are issues.** From fc551d265b122e5994f4619d827a86647507efd2 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Tue, 28 Apr 2020 16:44:19 -0500 Subject: [PATCH 34/48] - Proper closing of kintox11 on logout --- system-config/cleanup.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/system-config/cleanup.sh b/system-config/cleanup.sh index 62efa16..7165543 100755 --- a/system-config/cleanup.sh +++ b/system-config/cleanup.sh @@ -7,3 +7,4 @@ killall xbindkeys > /dev/null 2>&1 || : gsettings set org.gnome.desktop.wm.keybindings switch-applications "['Tab']" gsettings set org.gnome.desktop.wm.keybindings switch-applications-backward "['Tab']" +pkill -f /.config/kinto/xactive.sh \ No newline at end of file From 268a1bdbff4cca6cac51267785267a87d8f4b05a Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Fri, 1 May 2020 21:06:10 -0500 Subject: [PATCH 35/48] - Updated xkeysnail install to refer to my own fork to ensure users have the latest customizations --- xkeysnail_service.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/xkeysnail_service.sh b/xkeysnail_service.sh index bcad0cf..19f37fd 100755 --- a/xkeysnail_service.sh +++ b/xkeysnail_service.sh @@ -87,8 +87,16 @@ if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1 mv ./xkeysnail-config/kinto.py.new ~/.config/kinto/kinto.py sudo mv ./xkeysnail-config/xkeysnail.service.new /etc/systemd/system/xkeysnail.service xhost +SI:localuser:root - git clone --depth 1 https://github.com/mooz/xkeysnail.git + git clone --depth 1 https://github.com/rbreaves/xkeysnail.git cd xkeysnail + giturl=$(git ls-remote --get-url) + if [ "$geturl" != "https://github.com/rbreaves/xkeysnail.git" ];then + cd .. + rm -rf ./xkeysnail + git clone --depth 1 https://github.com/rbreaves/xkeysnail.git + cd xkeysnail + fi + git pull origin master sudo pip3 install --upgrade . sudo systemctl enable xkeysnail.service sudo systemctl daemon-reload From 31d7c736b0e326ebd2f15c5d312710def0932464 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Fri, 1 May 2020 22:05:01 -0500 Subject: [PATCH 36/48] - Better VS Code wordise fix for xkeysnail --- xkeysnail-config/kinto.py | 9 +++++++++ xkeysnail-config/vscode_keybindings.json | 18 ------------------ 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/xkeysnail-config/kinto.py b/xkeysnail-config/kinto.py index 5e94bc0..d9cd87f 100644 --- a/xkeysnail-config/kinto.py +++ b/xkeysnail-config/kinto.py @@ -117,6 +117,15 @@ define_keymap(lambda wm_class: wm_class not in ("Code"),{ # Keybindings for VS Code define_keymap(re.compile("Code"),{ + # Wordwise remaining - for VS Code + K("M-Left"): K("C-M-Left"), # Left of Word + K("M-Right"): K("C-M-Right"), # Right of Word + # Shift select word has a bug that prevents selection + # use ./xkeysnail-config/vscode_keybindings.json + # K("M-Shift-Left"): K("C-Shift-Left"), # Select Left of Word + # K("M-Shift-Right"): K("C-Shift-Right"), # Select Right of Word + + # VS Code Shortcuts K("C-g"): pass_through_key, # cancel Go to Line... K("Super-g"): K("C-g"), # Go to Line... K("F3"): pass_through_key, # cancel Find next diff --git a/xkeysnail-config/vscode_keybindings.json b/xkeysnail-config/vscode_keybindings.json index 750f5ac..fd455ac 100644 --- a/xkeysnail-config/vscode_keybindings.json +++ b/xkeysnail-config/vscode_keybindings.json @@ -1,23 +1,5 @@ // Place your key bindings in this file to override the defaultsauto[] [ - { - "key": "alt+left", - "command": "-workbench.action.terminal.focusPreviousPane", - "when": "terminalFocus" - }, - { - "key": "alt+right", - "command": "-workbench.action.terminal.focusNextPane", - "when": "terminalFocus" - }, - { - "key": "alt+right", - "command": "cursorWordRight" - }, - { - "key": "alt+left", - "command": "cursorWordLeft" - }, { "key": "shift+alt+left", "command": "cursorWordStartLeftSelect", From b5f533a83b8277f3135c205ee6710d69d5a62ead Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Fri, 1 May 2020 22:45:33 -0500 Subject: [PATCH 37/48] - Improved VS Code wordwise to work without any VS Code keybinding modifications required. --- xkeysnail-config/kinto.py | 8 ++++---- xkeysnail-config/vscode_keybindings.json | 13 ------------- 2 files changed, 4 insertions(+), 17 deletions(-) delete mode 100644 xkeysnail-config/vscode_keybindings.json diff --git a/xkeysnail-config/kinto.py b/xkeysnail-config/kinto.py index d9cd87f..ac73239 100644 --- a/xkeysnail-config/kinto.py +++ b/xkeysnail-config/kinto.py @@ -118,12 +118,12 @@ define_keymap(lambda wm_class: wm_class not in ("Code"),{ # Keybindings for VS Code define_keymap(re.compile("Code"),{ # Wordwise remaining - for VS Code + # Keeping Alt is a hack, but works K("M-Left"): K("C-M-Left"), # Left of Word K("M-Right"): K("C-M-Right"), # Right of Word - # Shift select word has a bug that prevents selection - # use ./xkeysnail-config/vscode_keybindings.json - # K("M-Shift-Left"): K("C-Shift-Left"), # Select Left of Word - # K("M-Shift-Right"): K("C-Shift-Right"), # Select Right of Word + # Alt-F19 hack fixes Alt menu activation + K("M-Shift-Left"): [K("M-F19"),K("C-Shift-Left")], # Select Left of Word + K("M-Shift-Right"): [K("M-F19"),K("C-Shift-Right")], # Select Right of Word # VS Code Shortcuts K("C-g"): pass_through_key, # cancel Go to Line... diff --git a/xkeysnail-config/vscode_keybindings.json b/xkeysnail-config/vscode_keybindings.json deleted file mode 100644 index fd455ac..0000000 --- a/xkeysnail-config/vscode_keybindings.json +++ /dev/null @@ -1,13 +0,0 @@ -// Place your key bindings in this file to override the defaultsauto[] -[ - { - "key": "shift+alt+left", - "command": "cursorWordStartLeftSelect", - "when": "textInputFocus" - }, - { - "key": "shift+alt+right", - "command": "cursorWordEndRightSelect", - "when": "textInputFocus" - } -] \ No newline at end of file From b2dd812f3fd4917eeea5e8a489e44450afc60034 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Sat, 2 May 2020 13:07:18 -0500 Subject: [PATCH 38/48] - Added uninstall shortcuts function to xkeysnail installer --- xkeysnail_service.sh | 67 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 3 deletions(-) diff --git a/xkeysnail_service.sh b/xkeysnail_service.sh index 19f37fd..5f582d6 100755 --- a/xkeysnail_service.sh +++ b/xkeysnail_service.sh @@ -3,6 +3,68 @@ # set about:config?filter=ui.key.menuAccessKeyFocuses # to false for wordwise to work in Firefox +function uninstall { + typeset -l dename + dename=$(./system-config/dename.sh | cut -d " " -f1) + + while true; do + read -rep $'\nPress R to restore your original shortcuts.\nPress F to reset to factory shortcuts. (f/r)\n' yn + case $yn in + [Ff]* ) yn="f"; break;; + [Rr]* ) yn="r";break;; + * ) echo "Please answer yes or no.";; + esac + done + + if [ "$yn" == "f" ];then + echo "Reset to factory shortcuts" + if [ "$dename" == "gnome" ];then + echo "Resetting DE hotkeys..." + echo "gsettings reset-recursively org.gnome.desktop.wm.keybindings" + gsettings reset-recursively org.gnome.desktop.wm.keybindings + echo "gsettings reset-recursively org.gnome.mutter.keybindings" + gsettings reset-recursively org.gnome.mutter.keybindings + elif [ "$dename" == "kde" ];then + echo "Resetting DE hotkeys..." + mv ~/.config/kwinrc ~/.config/kwinrc.kinto + mv ~/.config/kglobalshortcutsrc ~/.config/kglobalshortcutsrc.kinto + elif [ "$dename" == "xfce" ];then + echo "Resetting DE hotkeys..." + cp /etc/xdg/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml + fi + elif [ "$yn" == "r" ]; then + echo "Restore original user shortcuts" + if [ "$dename" == "gnome" ]; then + echo "Restoring DE hotkeys..." + wmkeys=$(ls | grep -m1 "keybinding") + mutterkeys=$(ls | grep -m1 "mutter") + if [[ ${#wmkeys} > 0 ]]; then + echo "dconf load /org/gnome/desktop/wm/keybindings/ < $wmkeys" + dconf load /org/gnome/desktop/wm/keybindings/ < "$wmkeys" + else + echo "Gnome Desktop keybindings backup not found..." + fi + if [[ ${#mutterkeys} > 0 ]]; then + echo "dconf load /org/gnome/mutter/keybindings/ < $mutterkeys" + dconf load /org/gnome/mutter/keybindings/ <"$mutterkeys" + fi + if [[ ${#wmkeys} > 0 ]] || [[ ${#mutterkeys} > 0 ]]; then + echo "Gnome hotkeys have been successfully restored." + fi + elif [ "$dename" == "kde" ]; then + echo "Restoring DE hotkeys..." + kwinkeys = $(ls | grep -m1 "kwinrc") + kdekeys = $(ls | grep -m1 "kglobalshortcutsrc") + cp ./"$kdekeys" ~/.config/kglobalshortcutsrc + cp ./"$kwinkeys" ~/.config/kwinrc + elif [ "$dename" == "xfce" ]; then + echo "Restoring DE hotkeys..." + xfcekeys = $(ls | grep -m1 "xfce4-keyboard") + cp ./"$xfcekeys" ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml + fi + fi +} + if [ $# -eq 0 ]; then echo "Install Kinto - xkeysnail (udev)" echo " 1) Windows & Mac (HID driver)" @@ -138,6 +200,7 @@ elif ! [[ $1 == "4" || $1 == "uninstall" ]]; then echo "Expected argument was not provided" else echo "Uninstalling Kinto - xkeysnail (udev)" + uninstall # Undo Apple keyboard cmd & alt swap if test -f "/sys/module/hid_apple/parameters/swap_opt_cmd" && [ `cat /sys/module/hid_apple/parameters/swap_opt_cmd` == "1" ]; then echo '0' | sudo tee -a /sys/module/hid_apple/parameters/swap_opt_cmd @@ -149,6 +212,4 @@ else sudo rm /etc/sudoers.d/limitedadmins rm ~/.config/autostart/xkeysnail.desktop rm -rf ~/.config/kinto -fi - - +fi \ No newline at end of file From da711e24219803fe15401629e1e5c3438d3a50db Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Sat, 2 May 2020 13:16:24 -0500 Subject: [PATCH 39/48] - Disable experimental features on non-dev or alpha branches. --- xkeysnail_service.sh | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/xkeysnail_service.sh b/xkeysnail_service.sh index 5f582d6..923f491 100755 --- a/xkeysnail_service.sh +++ b/xkeysnail_service.sh @@ -78,14 +78,21 @@ if [ $# -eq 0 ]; then 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 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;; - # * ) echo "Please answer yes or no.";; - esac - done + branch=$(git rev-parse --abbrev-ref HEAD) + if [ "$branch" == "dev" ] || [ "$branch" == "alpha" ];then + while true; do + 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;; + # * ) echo "Please answer yes or no.";; + esac + done + else + echo -e "\nSupport for Firefox/Chrome Back/Forward hotkeys (Cmd+Left/Right) disabled on $branch w/ xkeysnail \n" + exp=" " + expsh=" " + fi sudo systemctl enable xkeysnail >/dev/null 2>&1 if ! [ -x "$(command -v inotifywait)" ]; then echo "Will need to install inotify-tools to restart key remapper live for config file changes..." From 49d9cee34974b0bb5d1050cf9b26a6dc49a1cab1 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Sat, 2 May 2020 13:25:05 -0500 Subject: [PATCH 40/48] - Corrected VS Code wordwise further --- xkeysnail-config/kinto.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/xkeysnail-config/kinto.py b/xkeysnail-config/kinto.py index ac73239..21fe502 100644 --- a/xkeysnail-config/kinto.py +++ b/xkeysnail-config/kinto.py @@ -118,12 +118,11 @@ define_keymap(lambda wm_class: wm_class not in ("Code"),{ # Keybindings for VS Code define_keymap(re.compile("Code"),{ # Wordwise remaining - for VS Code - # Keeping Alt is a hack, but works - K("M-Left"): K("C-M-Left"), # Left of Word - K("M-Right"): K("C-M-Right"), # Right of Word # Alt-F19 hack fixes Alt menu activation - K("M-Shift-Left"): [K("M-F19"),K("C-Shift-Left")], # Select Left of Word - K("M-Shift-Right"): [K("M-F19"),K("C-Shift-Right")], # Select Right of Word + K("M-Left"): [K("M-F19"),K("C-Left")], # Left of Word + K("M-Right"): [K("M-F19"),K("C-Right")], # Right of Word + K("M-Shift-Left"): [K("M-F19"),K("C-Shift-Left")], # Select Left of Word + K("M-Shift-Right"): [K("M-F19"),K("C-Shift-Right")], # Select Right of Word # VS Code Shortcuts K("C-g"): pass_through_key, # cancel Go to Line... From 78efb692874612ee5fa5eccad28ea74cc7711706 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Sat, 2 May 2020 17:55:46 -0500 Subject: [PATCH 41/48] - xkeysnail install improvements wip --- xkeysnail-config/prexk.sh | 14 ++++++------- xkeysnail_service.sh | 41 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 44 insertions(+), 11 deletions(-) diff --git a/xkeysnail-config/prexk.sh b/xkeysnail-config/prexk.sh index e7f00a0..1b4053a 100755 --- a/xkeysnail-config/prexk.sh +++ b/xkeysnail-config/prexk.sh @@ -1,14 +1,12 @@ #!/bin/bash -if systemctl -q --user is-enabled keyswap.timer; then - systemctl --user stop keyswap.timer - systemctl --user disable keyswap.timer +if [ -f /home/{username}/.config/systemd/user/keyswap.timer ]; then + systemctl --user stop keyswap.timer >/dev/null 2>&1 + systemctl --user disable keyswap.timer >/dev/null 2>&1 fi -if systemctl -q --user is-active keyswap; then - systemctl --user stop keyswap -fi -if systemctl -q --user is-enabled keyswap; then - systemctl --user disable keyswap +if [ -f /home/{username}/.config/systemd/user/keyswap.service ]; then + systemctl --user stop keyswap >/dev/null 2>&1 + systemctl --user disable keyswap >/dev/null 2>&1 fi # export DISPLAY={displayid};/usr/bin/xhost +SI:localuser:root diff --git a/xkeysnail_service.sh b/xkeysnail_service.sh index 923f491..40d2394 100755 --- a/xkeysnail_service.sh +++ b/xkeysnail_service.sh @@ -3,6 +3,9 @@ # set about:config?filter=ui.key.menuAccessKeyFocuses # to false for wordwise to work in Firefox +typeset -l distro +distro=$(awk -F= '$1=="NAME" { print $2 ;}' /etc/os-release) + function uninstall { typeset -l dename dename=$(./system-config/dename.sh | cut -d " " -f1) @@ -102,7 +105,17 @@ if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1 echo "Will need to install python3-pip..." sudo ./system-config/unipkg.sh python3-pip fi - + if ! [ -x "$(command -v python3-config)" ]; then + if [ "$distro" == "ubuntu" ] || [ "$distro" == "debian" ]; then + pydev="python3-dev" + elif [ "$distro" == "fedora" ]; then + pydev="python3-devel" + fi + if [ "$distro" == "gnome" ] || [ "$distro" == "fedora" ] || [ "$distro" == "debian" ]; then + echo "Will need to install $pydev..." + sudo ./system-config/unipkg.sh "$pydev" + fi + fi # echo "Transferring files..." mkdir -p ~/.config/kinto @@ -154,7 +167,18 @@ fi if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1 == "chromebook" ]]; then mv ./xkeysnail-config/kinto.py.new ~/.config/kinto/kinto.py - sudo mv ./xkeysnail-config/xkeysnail.service.new /etc/systemd/system/xkeysnail.service + # if [ "$distro" == "fedora" ];then + sudo rm /etc/systemd/system/xkeysnail.service + sudo mv ./xkeysnail-config/xkeysnail.service.new /usr/lib/systemd/system/xkeysnail.service + sudo chown -R root:root /usr/lib/systemd/system/xkeysnail.service + sudo chmod 644 /usr/lib/systemd/system/xkeysnail.service + sudo ln -s /usr/lib/systemd/system/xkeysnail.service /etc/systemd/system/xkeysnail.service + sudo ln -s /usr/lib/systemd/system/xkeysnail.service /etc/systemd/system/graphical.target.wants/xkeysnail.service + # else + # sudo mv ./xkeysnail-config/xkeysnail.service.new /etc/systemd/system/xkeysnail.service + # sudo chown -R root:root /etc/systemd/system/xkeysnail.service + # sudo chmod 644 /etc/systemd/system/xkeysnail.service + # fi xhost +SI:localuser:root git clone --depth 1 https://github.com/rbreaves/xkeysnail.git cd xkeysnail @@ -167,8 +191,13 @@ if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1 fi git pull origin master sudo pip3 install --upgrade . - sudo systemctl enable xkeysnail.service sudo systemctl daemon-reload + sudo systemctl --state=not-found --all | grep xkeysnail + if [ "$distro" == "fedora" ];then + systemctl enable xkeysnail.service + else + sudo systemctl enable xkeysnail.service + fi sudo systemctl restart xkeysnail echo -e "Adding xhost fix...\n" @@ -219,4 +248,10 @@ else sudo rm /etc/sudoers.d/limitedadmins rm ~/.config/autostart/xkeysnail.desktop rm -rf ~/.config/kinto + sudo rm /etc/systemd/system/xkeysnail.service + sudo rm /etc/systemd/system/graphical.target.wants/xkeysnail.service + sudo rm /usr/lib/systemd/system/xkeysnail.service + sudo systemctl daemon-reload + sudo systemctl --state=not-found --all | grep xkeysnail + exit 0 fi \ No newline at end of file From 954049a2511878dd2a31b2f90c862bb30c58fc3b Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Sat, 2 May 2020 18:27:56 -0500 Subject: [PATCH 42/48] - Updated unipkg script to autoinstall packages on apt-get --- system-config/unipkg.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system-config/unipkg.sh b/system-config/unipkg.sh index fe69aa8..d76313d 100755 --- a/system-config/unipkg.sh +++ b/system-config/unipkg.sh @@ -3,7 +3,7 @@ if pkgmgr="$( which apt-get )" 2> /dev/null; then echo "Debian" $pkgmgr update - $pkgmgr install "$1" + $pkgmgr --yes --force-yes install "$1" elif pkgmgr="$( which dnf )" 2> /dev/null; then echo "dnf" $pkgmgr check-update; $pkgmgr install -y "$1" From 6a4ad3f92a6521a621307a4fea2e1955e8034c87 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Sat, 2 May 2020 19:10:51 -0500 Subject: [PATCH 43/48] - Added KDE Neon support for xkeysnail --- xkeysnail_service.sh | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/xkeysnail_service.sh b/xkeysnail_service.sh index 40d2394..bbc5c37 100755 --- a/xkeysnail_service.sh +++ b/xkeysnail_service.sh @@ -169,16 +169,18 @@ if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1 mv ./xkeysnail-config/kinto.py.new ~/.config/kinto/kinto.py # if [ "$distro" == "fedora" ];then sudo rm /etc/systemd/system/xkeysnail.service - sudo mv ./xkeysnail-config/xkeysnail.service.new /usr/lib/systemd/system/xkeysnail.service - sudo chown -R root:root /usr/lib/systemd/system/xkeysnail.service - sudo chmod 644 /usr/lib/systemd/system/xkeysnail.service - sudo ln -s /usr/lib/systemd/system/xkeysnail.service /etc/systemd/system/xkeysnail.service - sudo ln -s /usr/lib/systemd/system/xkeysnail.service /etc/systemd/system/graphical.target.wants/xkeysnail.service - # else - # sudo mv ./xkeysnail-config/xkeysnail.service.new /etc/systemd/system/xkeysnail.service - # sudo chown -R root:root /etc/systemd/system/xkeysnail.service - # sudo chmod 644 /etc/systemd/system/xkeysnail.service - # fi + if [ -d /usr/lib/systemd/system ];then + echo "1" + xkeypath="/usr/lib/systemd/system/" + elif [ -d /lib/systemd/system ];then + echo "2" + xkeypath="/lib/systemd/system/" + fi + sudo mv ./xkeysnail-config/xkeysnail.service.new "$xkeypath"xkeysnail.service && echo "Service file added to "$xkeypath"xkeysnail.service" + sudo chown -R root:root "$xkeypath"xkeysnail.service && echo "Ownership set for root..." || echo "Failed to set ownership..." + sudo chmod 644 "$xkeypath"xkeysnail.service && echo "Permissions set to 644..." || echo "Failed to set permissions..." + sudo ln -s "$xkeypath"xkeysnail.service /etc/systemd/system/xkeysnail.service && echo "Created soft symlink..." || echo "Failed to create soft symlink..." + sudo ln -s "$xkeypath"xkeysnail.service /etc/systemd/system/graphical.target.wants/xkeysnail.service && echo "Created soft symlink for graphical target..." || echo "Failed to create soft symlink for graphical target..." xhost +SI:localuser:root git clone --depth 1 https://github.com/rbreaves/xkeysnail.git cd xkeysnail @@ -231,6 +233,7 @@ if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1 else echo -e "Kinto \e[1m\e[91mxkeysnail service has failed.\e[0m" echo "You can run 'sudo systemctl status xkeysnail' for more info" + echo "You can also run 'sudo journalctl -u xkeysnail'" fi elif ! [[ $1 == "4" || $1 == "uninstall" ]]; then echo "Expected argument was not provided" From af9036ec246db22fb5e835266d971aba00b95aa1 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Sat, 2 May 2020 19:27:40 -0500 Subject: [PATCH 44/48] - Updated pacman to auto yes in unipkg script. --- system-config/unipkg.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system-config/unipkg.sh b/system-config/unipkg.sh index d76313d..3a22fe7 100755 --- a/system-config/unipkg.sh +++ b/system-config/unipkg.sh @@ -9,7 +9,7 @@ elif pkgmgr="$( which dnf )" 2> /dev/null; then $pkgmgr check-update; $pkgmgr install -y "$1" elif pkgmgr="$( which pacman )" 2> /dev/null; then echo "Arch-based" - $pkgmgr -Syy; $pkgmr -S "$1" + $pkgmgr -Syy; yes | pkgmr -S "$1" else echo "Package manager not found, please install $1" >&2 exit 1 From ae36d7f9559b9d1c79bafa50e23f4e7a568b5094 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Sat, 2 May 2020 19:42:34 -0500 Subject: [PATCH 45/48] - Added support for Manjaro Gnome and KDE for xkeysnail --- system-config/unipkg.sh | 2 +- xkeysnail-config/xkeystart.sh | 14 ++++++++++++-- xkeysnail_service.sh | 7 +++++-- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/system-config/unipkg.sh b/system-config/unipkg.sh index 3a22fe7..a425d78 100755 --- a/system-config/unipkg.sh +++ b/system-config/unipkg.sh @@ -9,7 +9,7 @@ elif pkgmgr="$( which dnf )" 2> /dev/null; then $pkgmgr check-update; $pkgmgr install -y "$1" elif pkgmgr="$( which pacman )" 2> /dev/null; then echo "Arch-based" - $pkgmgr -Syy; yes | pkgmr -S "$1" + $pkgmgr -Syy;yes | $pkgmgr -S "$1" else echo "Package manager not found, please install $1" >&2 exit 1 diff --git a/xkeysnail-config/xkeystart.sh b/xkeysnail-config/xkeystart.sh index e590e39..bcfffb3 100755 --- a/xkeysnail-config/xkeystart.sh +++ b/xkeysnail-config/xkeystart.sh @@ -1,9 +1,19 @@ #!/bin/bash # >/dev/null 2>&1 -/usr/local/bin/xkeysnail --quiet --watch "$1" & + +if [ -f /usr/local/bin/xkeysnail ];then + xkeyfullpath="/usr/local/bin/xkeysnail" +elif [ -f /usr/bin/xkeysnail ];then + xkeyfullpath="/usr/bin/xkeysnail" +else + xkeyfullpath=`which xkeysnail` +fi + +"$xkeyfullpath" --quiet --watch "$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" & + "$xkeyfullpath" --quiet --watch "$1" & done \ No newline at end of file diff --git a/xkeysnail_service.sh b/xkeysnail_service.sh index bbc5c37..e9ea046 100755 --- a/xkeysnail_service.sh +++ b/xkeysnail_service.sh @@ -116,6 +116,11 @@ if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1 sudo ./system-config/unipkg.sh "$pydev" fi fi + if ! [ -x "$(command -v xhost)" ]; then + if [ "$distro" == "\"manjaro linux\"" ]; then + sudo ./system-config/unipkg.sh xorg-xhost + fi + fi # echo "Transferring files..." mkdir -p ~/.config/kinto @@ -170,10 +175,8 @@ if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1 # if [ "$distro" == "fedora" ];then sudo rm /etc/systemd/system/xkeysnail.service if [ -d /usr/lib/systemd/system ];then - echo "1" xkeypath="/usr/lib/systemd/system/" elif [ -d /lib/systemd/system ];then - echo "2" xkeypath="/lib/systemd/system/" fi sudo mv ./xkeysnail-config/xkeysnail.service.new "$xkeypath"xkeysnail.service && echo "Service file added to "$xkeypath"xkeysnail.service" From e6b17933484d083598a7be419ecaac81df3ab5fe Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Sat, 2 May 2020 20:36:34 -0500 Subject: [PATCH 46/48] - Fixed Elementary Terminal tab switching for xkeysnail --- xkeysnail-config/kinto.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/xkeysnail-config/kinto.py b/xkeysnail-config/kinto.py index 21fe502..622986c 100644 --- a/xkeysnail-config/kinto.py +++ b/xkeysnail-config/kinto.py @@ -27,7 +27,7 @@ define_conditional_modmap(lambda wm_class: wm_class not in ("Gnome-terminal","ko }) # [Conditional modmap] Change modifier keys in certain applications -define_conditional_modmap(re.compile("Gnome-terminal|konsole|io.elementary.terminal|terminator|sakura|guake|tilda|xterm|eterm|kitty"), { +define_conditional_modmap(re.compile("Gnome-terminal|konsole|Io.elementary.terminal|terminator|sakura|guake|tilda|xterm|eterm|kitty"), { # # Chromebook # Key.LEFT_ALT: Key.RIGHT_CTRL, # Chromebook # # Left Ctrl Stays Left Ctrl @@ -216,11 +216,19 @@ define_keymap(re.compile("konsole"),{ }, "Konsole tab switching") -define_keymap(re.compile("Gnome-terminal|konsole|io.elementary.terminal|terminator|sakura|guake|tilda|xterm|eterm|kitty"),{ +define_keymap(re.compile("Io.elementary.terminal"),{ # Ctrl Tab - In App Tab Switching - K("LC-Tab") : K("LC-PAGE_DOWN"), - K("LC-Shift-Tab") : K("LC-PAGE_UP"), - K("LC-Grave") : K("LC-PAGE_UP"), + K("LC-Tab") : K("LC-Shift-Right"), + K("LC-Shift-Tab") : K("LC-Shift-Left"), + K("LC-Grave") : K("LC-Shift-Left"), + +}, "Elementary Terminal tab switching") + +define_keymap(re.compile("Gnome-terminal|konsole|Io.elementary.terminal|terminator|sakura|guake|tilda|xterm|eterm|kitty"),{ + # Ctrl Tab - In App Tab Switching + # K("LC-Tab") : K("LC-PAGE_DOWN"), + # K("LC-Shift-Tab") : K("LC-PAGE_UP"), + # K("LC-Grave") : K("LC-PAGE_UP"), # Converts Cmd to use Ctrl-Shift K("RC-Tab"): K("RC-F13"), K("RC-Shift-Tab"): K("RC-Shift-F13"), From 9d3cd94ca03172bb59b6c3c475314672c347cf14 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Sat, 2 May 2020 20:52:49 -0500 Subject: [PATCH 47/48] Updated readme --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2cd56af..1950c32 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,8 @@ Kinto works for standard Windows, Apple and Chromebook keyboards. The following - systemd - x11 - IBus* -- Fedora/RHEL/Manjaro/Arch/Debian/Ubuntu based distro 16.04+ +- Manjaro/Arch/Debian/Ubuntu based distro 16.04+ +- Fedora/RHEL (may not work w/ xkeysnail, but original xkb version does) - xkeysnail (Recommended, but optional) *IBus is needed to support wordwise during browser app usage as the keymap will need to change slightly depending if the cursor/caret is on screen waiting for input. Setup.py will set it but you can manually set it as well or check your current Input Method. From 4cae4d2d6fe3a4af7386b6033e2da7b29118cdc8 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Sat, 2 May 2020 20:54:46 -0500 Subject: [PATCH 48/48] Updated readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1950c32..9f63604 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ \- Type in Linux & Windows like it's a Mac. \- -Seamless copy and paste with all apps and terminals. Also the only linux remapper that is aware of your cursor/caret status - meaning it avoids shortcut conflicts within an app versus wordwise shortcuts when a text field is in use. +Seamless copy and paste with all apps and terminals. Also the only linux remapper that is aware of your cursor/caret status - meaning it avoids shortcut conflicts within an app versus wordwise shortcuts when a text field is in use. (xkeysnail implementation of Kinto has caret checking disabled in master for now.) ## What does this do exactly?