From 78efb692874612ee5fa5eccad28ea74cc7711706 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Sat, 2 May 2020 17:55:46 -0500 Subject: [PATCH 1/6] - 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 2/6] - 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 3/6] - 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 4/6] - 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 5/6] - 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 6/6] - 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"),