From 4a65034713156b5a2eb8e5208cf7b5d55dccde97 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Mon, 3 May 2021 01:33:46 -0500 Subject: [PATCH 1/9] Adding support for sysvinit for mxlinux w/ xfce --- linux/gui/kinto-gui.py | 68 ++++++++++++++---- linux/kinto-service.sh | 57 +++++++++++++++ linux/limitedadmins | 5 +- linux/trayapps/appindicator/kintotray.py | 48 ++++++++++--- linux/xkeysnail_sysv.desktop | 8 +++ xkeysnail_service.sh | 92 ++++++++++++++++-------- 6 files changed, 225 insertions(+), 53 deletions(-) create mode 100755 linux/kinto-service.sh create mode 100755 linux/xkeysnail_sysv.desktop diff --git a/linux/gui/kinto-gui.py b/linux/gui/kinto-gui.py index 335aac7..863cfda 100755 --- a/linux/gui/kinto-gui.py +++ b/linux/gui/kinto-gui.py @@ -54,7 +54,15 @@ class MyWindow(Gtk.Window): openWin = False global child_pid - kinto_status = Popen("while :; do clear; systemctl is-active xkeysnail; sleep 2; done", stdout=PIPE, shell=True) + global sysv + try: + sysv = int(Popen("pidof systemd >/dev/null 2>&1 && echo '0' || echo '1'", stdout=PIPE, shell=True).communicate()[0].strip().decode('UTF-8')) + except: + sysv = 2 + if sysv: + kinto_status = Popen("while :; do clear; pgrep 'xkeysnail' && echo 'active'; sleep 2; done", stdout=PIPE, shell=True) + else: + kinto_status = Popen("while :; do clear; systemctl is-active xkeysnail; sleep 2; done", stdout=PIPE, shell=True) child_pid = kinto_status.pid winkb = Gtk.RadioMenuItem(label='Windows') @@ -114,9 +122,15 @@ class MyWindow(Gtk.Window): None, ) if self.args.debug: - self.command = 'sudo systemctl stop xkeysnail && sudo pkill -f bin/xkeysnail && sudo xkeysnail ~/.config/kinto/kinto.py\n' + if sysv: + self.command = 'sudo /etc/init.d/kinto stop && sudo pkill -f bin/xkeysnail && sudo xkeysnail ~/.config/kinto/kinto.py\n' + else: + self.command = 'sudo systemctl stop xkeysnail && sudo pkill -f bin/xkeysnail && sudo xkeysnail ~/.config/kinto/kinto.py\n' else: - self.command = "journalctl -f --unit=xkeysnail.service -b\n" + if sysv: + self.command = "tail -f /tmp/kinto.log\n" + else: + self.command = "journalctl -f --unit=xkeysnail.service -b\n" self.InputToTerm(self.command) @@ -343,7 +357,6 @@ class MyWindow(Gtk.Window): self.menuitem_systray.signal_id = self.menuitem_systray.connect('activate',self.checkTray,False) restartsvc = True - def initSetup(self): global win,openWin,restartsvc @@ -456,7 +469,7 @@ class MyWindow(Gtk.Window): def image2pixbuf(self,im): data = im.tobytes() w, h = im.size - print(im.size) + # print(im.size) data = GLib.Bytes.new(data) pix = GdkPixbuf.Pixbuf.new_from_bytes(data, GdkPixbuf.Colorspace.RGB,True, 8, w, h, w * 4) return pix @@ -517,7 +530,10 @@ class MyWindow(Gtk.Window): return def runDebug(self,button): - command = 'send \003 sudo systemctl stop xkeysnail && sudo pkill -f bin/xkeysnail && sudo xkeysnail ~/.config/kinto/kinto.py\n' + if sysv: + command = 'send \003 sudo /etc/init.d/kinto stop && sudo pkill -f bin/xkeysnail && sudo xkeysnail ~/.config/kinto/kinto.py\n' + else: + command = 'send \003 sudo systemctl stop xkeysnail && sudo pkill -f bin/xkeysnail && sudo xkeysnail ~/.config/kinto/kinto.py\n' self.InputToTerm(command) def openSupport(self,button): @@ -610,7 +626,10 @@ class MyWindow(Gtk.Window): self.queryConfig(killspawn) time.sleep(1) global child_pid - self.kinto_status = Popen("while :; do clear; systemctl is-active xkeysnail; sleep 2; done", stdout=PIPE, shell=True) + if sysv: + self.kinto_status = Popen("while :; do clear; pgrep 'xkeysnail'; sleep 2; done", stdout=PIPE, shell=True) + else: + self.kinto_status = Popen("while :; do clear; systemctl is-active xkeysnail; sleep 2; done", stdout=PIPE, shell=True) child_pid = self.kinto_status.pid self.menuitem_systray.disconnect(self.menuitem_systray.signal_id) self.menuitem_systray.set_active(False) @@ -618,6 +637,7 @@ class MyWindow(Gtk.Window): return def setKB(self,button,kbtype): + global sysv try: if kbtype == "win": setkb = 's/^(\s{3})(\s{1}#)(.*# WinMac.*)|^(?!\s{4}#)(\s{3})(\s{1})(.*)( # )(Mac.*)|^(?!\s{4}#)(\s{3})(\s{1})(.*)( # )(IBM.*)|^(?!\s{4}#)(\s{3})(\s{1})(.*)( # )(Chromebook.*)|^(\s{3})(\s{1}# )(-)( Default Win)|^(\s{3})(\s{1}# )(-)(- Default Mac*)/ $3$7$6$7$8$12$11$12$13$17$16$17$18$20$21$21$22$24$26/g' @@ -654,7 +674,10 @@ class MyWindow(Gtk.Window): elif kbtype == "ibm": setkb ='s/^(\s{3})(\s{1}#)(.*# IBM.*)|^(?!\s{4}#)(\s{3})(\s{1})(.*)( # )(WinMac.*)|^(?!\s{4}#)(\s{3})(\s{1})(.*)( # )(Mac.*)|^(?!\s{4}#)(\s{3})(\s{1})(.*)( # )(Chromebook.*)|^(\s{3})(\s{1}# )(-)(- Default (Win|Mac.*))/ $3$7$6$7$8$12$11$12$13$17$16$17$18$20$22/g' - restart = ['sudo', 'systemctl','restart','xkeysnail'] + if sysv: + restart = ['sudo', '-E','/etc/init.d/kinto','restart'] + else: + restart = ['sudo', 'systemctl','restart','xkeysnail'] cmds = ['perl','-pi','-e',setkb,self.kconfig] cmdsTerm = Popen(cmds) @@ -746,11 +769,14 @@ class MyWindow(Gtk.Window): } def on_delete_event(event, self, widget): - global restartsvc, openWin + global restartsvc, openWin, sysv if restartsvc == True: try: - restartcmd = ['sudo', 'systemctl','restart','xkeysnail'] + if sysv: + restartcmd = ['sudo', '-E','/etc/init.d/kinto','restart'] + else: + restartcmd = ['sudo', 'systemctl','restart','xkeysnail'] Popen(restartcmd) restartsvc = False @@ -870,8 +896,12 @@ class MyWindow(Gtk.Window): return def runRestart(self,button): + global sysv try: - stop = Popen(['sudo', 'systemctl','stop','xkeysnail']) + if sysv: + stop = Popen(['sudo', '-E','/etc/init.d/kinto','stop']) + else: + stop = Popen(['sudo', 'systemctl','stop','xkeysnail']) stop.wait() time.sleep(1) res = Popen(['pgrep','xkeysnail']) @@ -880,15 +910,23 @@ class MyWindow(Gtk.Window): if res.returncode == 0: pkillxkey = Popen(['sudo', 'pkill','-f','bin/xkeysnail']) pkillxkey.wait() - Popen(['sudo', 'systemctl','start','xkeysnail']) - self.command = "send \003 journalctl -f --unit=xkeysnail.service -b\n" + if sysv: + Popen(['sudo','-E','/etc/init.d/kinto','start']) + self.command = "send \003 tail -f /tmp/kinto.log\n" + else: + Popen(['sudo','systemctl','start','xkeysnail']) + self.command = "send \003 journalctl -f --unit=xkeysnail.service -b\n" self.InputToTerm(self.command) except: Popen(['notify-send','Kinto: Errror restarting Kinto!']) def runStop(self,button): + global sysv try: - stop = Popen(['sudo', 'systemctl','stop','xkeysnail']) + if sysv: + stop = Popen(['sudo', '-E','/etc/init.d/kinto','stop']) + else: + stop = Popen(['sudo', 'systemctl','stop','xkeysnail']) stop.wait() time.sleep(1) res = Popen(['pgrep','xkeysnail']) @@ -1077,7 +1115,7 @@ class MyWindow(Gtk.Window): except: pass - print(Vte.get_minor_version()) + # print(Vte.get_minor_version()) # def on_menu_auto(self, widget): # print("add file open dialog") diff --git a/linux/kinto-service.sh b/linux/kinto-service.sh new file mode 100755 index 0000000..9bdc4f1 --- /dev/null +++ b/linux/kinto-service.sh @@ -0,0 +1,57 @@ +#!/bin/bash +# +# chkconfig: 35 90 12 +# description: Kinto service +# + +# Get function from functions library +# . /etc/init.d/functions + +# Start the service +start() { + echo -n "Starting Kinto (xkeynsail)" | logger + xkeycount=$(pgrep 'xkeysnail' | wc -l) + + if [[ $xkeycount -eq 0 ]]; then + /usr/bin/xhost +SI:localuser:root && script -q -c "xkeysnail --quiet --watch `echo $HOME`/.config/kinto/kinto.py" /dev/null | tee -a /tmp/kinto.log & + ### Create the lock file ### + touch /var/lock/subsys/kinto + success $"Kinto (xkeynsail) started" + else + echo "Kinto (xkeynsail) service is already running." + fi + + echo +} + +# Restart the service +stop() { + echo -n "Stopping Kinto (xkeynsail)" | logger + pgrep 'xkeysnail' | xargs -r -n1 sudo kill + ### Now, delete the lock file ### + rm -f /var/lock/subsys/kinto + echo +} + +### main logic ### +case "$1" in + start) + start + ;; + stop) + stop + ;; + status) + status + ;; + restart|reload|condrestart) + stop + sleep 2 + start + ;; + *) + echo $"Usage: $0 {start|stop|restart|reload|status}" + exit 1 +esac + +exit 0 \ No newline at end of file diff --git a/linux/limitedadmins b/linux/limitedadmins index 1a3e933..2b8e588 100644 --- a/linux/limitedadmins +++ b/linux/limitedadmins @@ -1,4 +1,7 @@ # /etc/sudoers.d/limitedadmins +Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11/bin" +Defaults!/etc/init.d/kinto setenv,env_reset,env_delete+=PATH,env_delete+=LD_PRELOAD,env_delete+=LD_LIBRARY_PATH,env_delete+=SSH_AUTH_SOCK,env_delete+=PYTHONPATH,env_delete+=PERL5LIB +%{username} ALL=NOPASSWD: /etc/init.d/kinto * %{username} ALL=NOPASSWD: {systemctl} restart xkeysnail %{username} ALL=NOPASSWD: {systemctl} start xkeysnail %{username} ALL=NOPASSWD: {systemctl} stop xkeysnail @@ -6,5 +9,5 @@ %{username} ALL=(root) NOPASSWD: /usr/local/bin/logoff.sh %{username} ALL=NOPASSWD: {pkill} -f logoff %{username} ALL=NOPASSWD: {pkill} -f bin/xkeysnail -%{username} ALL=NOPASSWD: {xkeysnail} /home/{username}/.config/kinto/kinto.py +%{username} ALL=NOPASSWD: {xkeysnail} * %{username} ALL=NOPASSWD: {systemctl} is-active --quiet xkeysnail diff --git a/linux/trayapps/appindicator/kintotray.py b/linux/trayapps/appindicator/kintotray.py index 2eeeb06..3b7fc3d 100755 --- a/linux/trayapps/appindicator/kintotray.py +++ b/linux/trayapps/appindicator/kintotray.py @@ -7,7 +7,7 @@ gi.require_version('AppIndicator3', '0.1') gi.require_version('Notify', '0.7') import signal,time,os,fcntl,datetime,re -from subprocess import Popen, PIPE, CalledProcessError +from subprocess import Popen, PIPE, CalledProcessError, check_output from shutil import which from gi.repository import Gtk,GLib,GdkPixbuf from gi.repository import AppIndicator3 as appindicator @@ -29,7 +29,15 @@ APPINDICATOR_ID = 'Kinto' class Indicator(): global child_pid - kinto_status = Popen("while :; do clear; systemctl is-active xkeysnail; sleep 2s; done", stdout=PIPE, shell=True) + global sysv + try: + sysv = check_output("pidof systemd >/dev/null 2>&1 && echo '0' || echo '1'").strip().decode('UTF-8') + except: + sysv = 1 + if sysv: + kinto_status = Popen("while :; do clear; pgrep 'xkeysnail' && echo 'active'; sleep 2; done", stdout=PIPE, shell=True) + else: + kinto_status = Popen("while :; do clear; systemctl is-active xkeysnail; sleep 2; done", stdout=PIPE, shell=True) child_pid = kinto_status.pid homedir = os.path.expanduser("~") @@ -79,7 +87,15 @@ class Indicator(): last_status = "" def __init__(self): - res = Popen(['sudo', 'systemctl','is-active','--quiet','xkeysnail']) + global sysv + try: + sysv = check_output("pidof systemd >/dev/null 2>&1 && echo '0' || echo '1'").strip().decode('UTF-8') + except: + sysv = 1 + if sysv: + res = Popen(['pgrep','xkeysnail']) + else: + res = Popen(['sudo', 'systemctl','is-active','--quiet','xkeysnail']) res.wait() if res.returncode == 0: @@ -446,7 +462,10 @@ class Indicator(): global restartsvc if restartsvc == True: try: - restartcmd = ['sudo', 'systemctl','restart','xkeysnail'] + if sysv: + restartcmd = ['sudo', '-E','/etc/init.d/kinto','restart'] + else: + restartcmd = ['sudo', 'systemctl','restart','xkeysnail'] Popen(restartcmd) restartsvc = False @@ -555,8 +574,12 @@ class Indicator(): return def runRestart(self,button): + global sysv try: - stop = Popen(['sudo', 'systemctl','stop','xkeysnail']) + if sysv: + stop = Popen(['sudo', '-E','/etc/init.d/kinto','stop']) + else: + stop = Popen(['sudo', 'systemctl','stop','xkeysnail']) stop.wait() time.sleep(1) res = Popen(['pgrep','xkeysnail']) @@ -567,13 +590,19 @@ class Indicator(): pkillxkey = Popen(['sudo', 'pkill','-f','bin/xkeysnail']) pkillxkey.wait() - Popen(['sudo', 'systemctl','start','xkeysnail']) + if sysv: + Popen(['sudo', '-E','/etc/init.d/kinto','start']) + else: + Popen(['sudo', 'systemctl','start','xkeysnail']) except: Popen(['notify-send','Kinto: Error restarting Kinto!']) def runStop(self,button): try: - stop = Popen(['sudo', 'systemctl','stop','xkeysnail']) + if sysv: + stop = Popen(['sudo', '-E','/etc/init.d/kinto','stop']) + else: + stop = Popen(['sudo', 'systemctl','stop','xkeysnail']) stop.wait() time.sleep(1) res = Popen(['pgrep','xkeysnail']) @@ -689,7 +718,10 @@ class Indicator(): cmdsTerm = Popen(cmds) cmdsTerm.wait() - restart = ['sudo', 'systemctl','restart','xkeysnail'] + if sysv: + restart = ['sudo', '-E','/etc/init.d/kinto','restart'] + else: + restart = ['sudo', 'systemctl','restart','xkeysnail'] Popen(restart) except CalledProcessError: diff --git a/linux/xkeysnail_sysv.desktop b/linux/xkeysnail_sysv.desktop new file mode 100755 index 0000000..782ec98 --- /dev/null +++ b/linux/xkeysnail_sysv.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Name=Kinto_xkey +GenericName=Kinto_xkey +Comment=Make Linux Type Like it's a Mac +Exec=/bin/bash -c "grep -q 'autostart = true' {homedir}/.config/kinto/kinto.py && sudo -E /etc/init.d/kinto restart" +Terminal=false +Type=Application +X-GNOME-Autostart-enabled=true \ No newline at end of file diff --git a/xkeysnail_service.sh b/xkeysnail_service.sh index b8b5e7d..acc393d 100755 --- a/xkeysnail_service.sh +++ b/xkeysnail_service.sh @@ -3,11 +3,18 @@ # set about:config?filter=ui.key.menuAccessKeyFocuses # to false for wordwise to work in Firefox +function pause(){ + read -s -n 1 -p "Press any key to continue . . ." + echo "" +} + typeset -l distro distro=$(awk -F= '$1=="NAME" { gsub("[\",!,_, ]","",$2);print $2 ;}' /etc/os-release) typeset -l dename dename=$(./linux/system-config/dename.sh | cut -d " " -f1) +sysv=$(pidof systemd >/dev/null 2>&1 && echo "1" || echo "0") + function uninstall { echo -e "\nNote: Restoring keys is only relevant if you had installed a version prior to 1.2 of Kinto. You should skip this step if 1.2+ is all you have installed." @@ -352,12 +359,12 @@ if ! [ -x "$(command -v pip3)" ]; then sudo ./linux/system-config/unipkg.sh python3-pip fi if ! [ -x "$(command -v python3-config)" ]; then - if [ "$distro" == "ubuntu" ] || [ "$distro" == "debian" ] || [ "$distro" == 'linuxmint' ]; then + if [ "$distro" == "ubuntu" ] || [ "${distro::6}" == "debian" ] || [ "$distro" == 'linuxmint' ]; then pydev="python3-dev" elif [ "$distro" == "fedora" ]; then pydev="python3-devel" fi - if [ "$distro" == "gnome" ] || [ "$distro" == "fedora" ] || [ "$distro" == "debian" ] || [ "$distro" == 'linuxmint' ]; then + if [ "$distro" == "gnome" ] || [ "$distro" == "fedora" ] || [ "${distro::6}" == "debian" ] || [ "$distro" == 'linuxmint' ]; then echo "Will need to install $pydev..." sudo ./linux/system-config/unipkg.sh "$pydev" fi @@ -370,8 +377,10 @@ if ! [ -x "$(command -v xhost)" ] || ! [ -x "$(command -v gcc)" ]; then sudo ./linux/system-config/unipkg.sh "xorg-xhost gcc" fi fi -if [ "$distro" == 'linuxmint' ]; then +if [ "$distro" == 'linuxmint' ] ; then pip3 install setuptools +elif [ "${distro::6}" == "debian" ]; then + sudo pip3 install setuptools wheel fi pip3 install pillow @@ -386,7 +395,11 @@ mkdir -p ~/.config/kinto # KDE startup - xhost fix mkdir -p ~/.config/autostart -yes | cp -rf ./linux/xkeysnail.desktop ~/.config/kinto/xkeysnail.desktop +if [ ! "$sysv" -eq 0 ];then + yes | cp -rf ./linux/xkeysnail.desktop ~/.config/kinto/xkeysnail.desktop +else + yes | cp -rf ./linux/xkeysnail_sysv.desktop ~/.config/kinto/xkeysnail.desktop +fi # yes | cp -rf ./linux/xkeystart.sh ~/.config/kinto/xkeystart.sh @@ -411,7 +424,6 @@ else fi yes | cp -rf ./linux/kinto.py ./linux/kinto.py.new -yes | cp -rf ./linux/limitedadmins ./linux/limitedadmins.new yes | cp -rf ./linux/gui/ ~/.config/kinto/ yes | cp -nrf ./linux/initkb ~/.config/kinto/initkb yes | cp -rf ./linux/killdups.sh ~/.config/kinto/killdups.sh @@ -424,29 +436,36 @@ yes | cp -rf ./linux/trayapps/appindicator/icons/kinto-invert-16.svg ~/.config/k yes | cp -rf ./linux/trayapps/appindicator/icons/kinto-solid-16.svg ~/.config/kinto/kinto-solid.svg yes | cp -rf ./linux/trayapps/appindicator/icons/kinto.svg ~/.config/kinto/kinto.svg # yes | cp -rf ./linux/system-config/caret_status_xkey.sh ~/.config/kinto/caret_status_xkey.sh -yes | cp -rf ./linux/xkeysnail.service ./linux/xkeysnail.service.new -# yes | cp -rf ./linux/xkeysnail.timer ~/.config/systemd/user/xkeysnail.timer -sed -i "s#{experimental-caret}#$exp#g" ./linux/xkeysnail.service.new -if [ "$expsh" != " " ];then - sed -i "s#{kill-caret}#/usr/bin/pkill -f $expsh#g" ./linux/xkeysnail.service.new + +yes | cp -rf ./linux/limitedadmins ./linux/limitedadmins.new +sed -i "s/{username}/`whoami`/g" ./linux/limitedadmins.new +sed -i "s#{systemctl}#`\\which systemctl`#g" ./linux/limitedadmins.new +sed -i "s#{pkill}#`\\which pkill`#g" ./linux/limitedadmins.new +if [ ! "$sysv" -eq 0 ];then + echo "Using systemd..." + yes | cp -rf ./linux/xkeysnail.service ./linux/xkeysnail.service.new + # yes | cp -rf ./linux/xkeysnail.timer ~/.config/systemd/user/xkeysnail.timer + sed -i "s#{experimental-caret}#$exp#g" ./linux/xkeysnail.service.new + if [ "$expsh" != " " ];then + sed -i "s#{kill-caret}#/usr/bin/pkill -f $expsh#g" ./linux/xkeysnail.service.new + else + sed -i "s#{kill-caret}#$expsh#g" ./linux/xkeysnail.service.new + fi + sed -i "s/{username}/`whoami`/g" ./linux/xkeysnail.service.new + sed -i "s#{homedir}#`echo "$HOME"`#g" ./linux/xkeysnail.service.new + sed -i "s#{xhost}#`\\which xhost`#g" ./linux/xkeysnail.service.new + sed -i "s/{displayid}/`echo "$DISPLAY"`/g" ./linux/xkeysnail.service.new else - sed -i "s#{kill-caret}#$expsh#g" ./linux/xkeysnail.service.new + echo "Using sysvinit..." fi -sed -i "s/{username}/`whoami`/g" ./linux/xkeysnail.service.new -sed -i "s#{homedir}#`echo "$HOME"`#g" ./linux/xkeysnail.service.new sed -i "s#{homedir}#`echo "$HOME"`#g" ~/.config/kinto/kintotray.desktop sed -i "s#{homedir}#`echo "$HOME"`#g" ~/.config/kinto/gui/kinto-gui.py sed -i "s#{homedir}#`echo "$HOME"`#g" ./linux/gui/kinto.desktop.new sudo mv ./linux/gui/kinto.desktop.new /usr/share/applications/kinto.desktop -sed -i "s#{xhost}#`\\which xhost`#g" ./linux/xkeysnail.service.new -sed -i "s/{username}/`whoami`/g" ./linux/limitedadmins.new -sed -i "s#{systemctl}#`\\which systemctl`#g" ./linux/limitedadmins.new -sed -i "s#{pkill}#`\\which pkill`#g" ./linux/limitedadmins.new sed -i "s#{systemctl}#`\\which systemctl`#g" ~/.config/kinto/xkeysnail.desktop sed -i "s#{xhost}#`\\which xhost`#g" ~/.config/kinto/xkeysnail.desktop sed -i "s#{homedir}#`echo "$HOME"`#g" ~/.config/kinto/xkeysnail.desktop # sed -i "s#{homedir}#`echo "$HOME"`#g" ~/.config/kinto/prexk.sh -sed -i "s/{displayid}/`echo "$DISPLAY"`/g" ./linux/xkeysnail.service.new # sed -i "s/{displayid}/`echo "$DISPLAY"`/g" ~/.config/kinto/prexk.sh if [[ $dename == "budgie" ]]; then @@ -493,7 +512,13 @@ fi if ! [[ $1 == "5" || $1 == "uninstall" || $1 == "Uninstall" ]]; then mv ./linux/kinto.py.new ~/.config/kinto/kinto.py # if [ "$distro" == "fedora" ];then - sudo rm /etc/systemd/system/xkeysnail.service >/dev/null 2>&1 + if [ ! "$sysv" -eq 0 ];then + # echo "Using systemd..." + sudo rm /etc/systemd/system/xkeysnail.service >/dev/null 2>&1 + else + # echo "Using sysvinit..." + echo "" + fi if [ -d /usr/lib/systemd/system ];then xkeypath="/usr/lib/systemd/system/" elif [ -d /lib/systemd/system ];then @@ -521,19 +546,27 @@ if ! [[ $1 == "5" || $1 == "uninstall" || $1 == "Uninstall" ]]; then echo -e "Run 'sudo pip3 install --upgrade .' to debug issue" exit 0 fi - sed -i "s#{xkeysnail}#`which xkeysnail`#g" ./linux/xkeysnail.service.new sed -i "s#{xkeysnail}#`which xkeysnail`#g" ./linux/limitedadmins.new - sudo mv ./linux/xkeysnail.service.new "$xkeypath"xkeysnail.service && echo "Service file added to "$xkeypath"xkeysnail.service" sudo chown root:root ./linux/limitedadmins.new # Add a check here for xkeysnail path resolving sudo mv ./linux/limitedadmins.new /etc/sudoers.d/limitedadmins - 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..." - sudo systemctl daemon-reload - sudo systemctl disable xkeysnail - sudo systemctl stop xkeysnail + if [ ! "$sysv" -eq 0 ];then + # echo "Using systemd..." + sed -i "s#{xkeysnail}#`which xkeysnail`#g" ./linux/xkeysnail.service.new + sudo mv ./linux/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..." + sudo systemctl daemon-reload + sudo systemctl disable xkeysnail + sudo systemctl stop xkeysnail + else + # echo "Using sysvinit..." + echo "" + sudo -E /etc/init.d/kinto stop & + fi # sudo systemctl --state=not-found --all | grep xkeysnail # if [ "$distro" == "fedora" ];then # systemctl enable xkeysnail.service @@ -541,7 +574,8 @@ if ! [[ $1 == "5" || $1 == "uninstall" || $1 == "Uninstall" ]]; then # sudo systemctl enable xkeysnail.service # fi # sudo systemctl restart xkeysnail - sudo pkill -f kintotray >/dev/null 2>&1 + sudo pkill -f kintotray & + # >/dev/null 2>&1 if [[ $dename == "gnome" || $dename == "kde" ]];then sed -i "s/systray = true/systray = false/g" ~/.config/kinto/initkb fi From eeb5cc9ecb084fb3d15250540e634bc7f42f3bed Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Tue, 4 May 2021 17:17:26 -0500 Subject: [PATCH 2/9] Quieted most warnings & updated gtk methods --- linux/gui/kinto-gui.py | 106 ++++++++++++++++++++++------------------- 1 file changed, 56 insertions(+), 50 deletions(-) diff --git a/linux/gui/kinto-gui.py b/linux/gui/kinto-gui.py index 863cfda..37c0b29 100755 --- a/linux/gui/kinto-gui.py +++ b/linux/gui/kinto-gui.py @@ -1,6 +1,8 @@ #!/usr/bin/env python3 import gi,os,time,fcntl,argparse,re +import warnings +warnings.filterwarnings("ignore") gi.require_version('Gtk', '3.0') gi.require_version('Vte', '2.91') from gi.repository import Gtk,Gdk,GdkPixbuf @@ -48,7 +50,7 @@ class MyWindow(Gtk.Window): page = 1 label = Gtk.Label() - label.set_alignment(1, 0) + label.set_halign(Gtk.Align.END) ostype = os.environ.get('XDG_CURRENT_DESKTOP') global openWin openWin = False @@ -195,19 +197,19 @@ class MyWindow(Gtk.Window): menubar.append(menuitem_edit) submenu_edit = Gtk.Menu() menuitem_edit.set_submenu(submenu_edit) - edititem_tweaks = Gtk.MenuItem("Tweaks") + edititem_tweaks = Gtk.MenuItem(label="Tweaks") edititem_tweaks.connect('activate',self.setTweaks) submenu_edit.append(edititem_tweaks) - edititem_config = Gtk.MenuItem("Kinto Config (shortcuts)") + edititem_config = Gtk.MenuItem(label="Kinto Config (shortcuts)") edititem_config.connect('activate',self.setConfig) submenu_edit.append(edititem_config) - edititem_service = Gtk.MenuItem("Kinto Service") + edititem_service = Gtk.MenuItem(label="Kinto Service") edititem_service.connect('activate',self.setService) submenu_edit.append(edititem_service) - edititem_shortcuts = Gtk.MenuItem("System Shortcuts") + edititem_shortcuts = Gtk.MenuItem(label="System Shortcuts") edititem_shortcuts.connect('activate',self.setSysKB) submenu_edit.append(edititem_shortcuts) - edititem_language = Gtk.MenuItem("Change Language") + edititem_language = Gtk.MenuItem(label="Change Language") edititem_language.connect('activate',self.setRegion) submenu_edit.append(edititem_language) @@ -221,11 +223,11 @@ class MyWindow(Gtk.Window): helpitem_debug = Gtk.MenuItem(label="Debug") helpitem_debug.connect('activate',self.runDebug) submenu_help.append(helpitem_debug) - helpitem_support = Gtk.MenuItem("Support") + helpitem_support = Gtk.MenuItem(label="Support") helpitem_support.connect('activate',self.openSupport) submenu_help.append(helpitem_support) menuitem_help.set_submenu(submenu_help) - helpitem_about = Gtk.MenuItem("About") + helpitem_about = Gtk.MenuItem(label="About") helpitem_about.connect('activate',self.runAbout) submenu_help.append(helpitem_about) @@ -433,21 +435,20 @@ class MyWindow(Gtk.Window): pixbuf = GdkPixbuf.Pixbuf.new_from_file(os.environ['HOME']+'/.config/kinto/gui/tuxcry4.png') pixbuf = pixbuf.scale_simple(600, 360, GdkPixbuf.InterpType.BILINEAR) self.bgsuccess4 = self.bgsuccess4.new_from_pixbuf(pixbuf) - self.bgsuccess4.set_alignment(0, 1) + self.bgsuccess4.set_valign(Gtk.Align.END) pixbuf = GdkPixbuf.Pixbuf.new_from_file(os.environ['HOME']+'/.config/kinto/gui/tuxuninstall.png') pixbuf = pixbuf.scale_simple(600, 360, GdkPixbuf.InterpType.BILINEAR) self.bguninstall = self.bguninstall.new_from_pixbuf(pixbuf) - self.bguninstall.set_alignment(0, 1) + self.bguninstall.set_valign(Gtk.Align.END) pixbuf = GdkPixbuf.Pixbuf.new_from_file(os.environ['HOME']+'/.config/kinto/gui/tuxbg.png') pixbuf = pixbuf.scale_simple(600, 360, GdkPixbuf.InterpType.BILINEAR) self.background = self.background.new_from_pixbuf(pixbuf) - self.background.set_alignment(0, 1) + self.background.set_valign(Gtk.Align.END) self.bgcaps = self.bgcaps.new_from_pixbuf(pixbuf2) - self.bgcaps.set_alignment(0, 1) self.bgspace = self.bgspace.new_from_pixbuf(pixbuf3) - self.bgspace.set_alignment(0, 1) + self.bgspace.set_valign(Gtk.Align.END) self.overlay.add(self.background) self.overlay.add_overlay(self.container) self.setupwin.add(self.container) @@ -1144,34 +1145,36 @@ class UninstallPage(Gtk.Box): label_start = Gtk.Label() label_start.set_markup('Uninstall\n\n\n\nWould you like to uninstall kinto?\n\n If you need support please visit kinto.sh.') - label_start.set_alignment(0,0) + label_start.set_valign(Gtk.Align.START) + label_start.set_halign(Gtk.Align.START) + label_start.set_line_wrap(True) vbox.add(label_start) scroller.add(vbox) hbox = Gtk.HBox() - previous = Gtk.Button("Uninstall") + previous = Gtk.Button(label="Uninstall") previous.connect("clicked", self.goback) - previous.set_margin_right(206) + previous.set_margin_end(206) hbox.add(previous) - onward = Gtk.Button("Continue") + onward = Gtk.Button(label="Continue") onward.connect("clicked", self.forward) hbox.add(onward) hbox.set_hexpand(False) hbox.set_vexpand(False) hbox.set_margin_bottom(6) - hbox.set_margin_right(25) + hbox.set_margin_end(25) scroller.set_hexpand(True) scroller.set_vexpand(True) vbox_container.add(scroller) vbox_container.set_margin_top(55) - vbox_container.set_margin_right(25) - self.grid.set_margin_left(157) + vbox_container.set_margin_end(25) + self.grid.set_margin_start(157) vbox_container.set_margin_bottom(18) - vbox.set_margin_right(10) + vbox.set_margin_end(10) vbox.set_margin_bottom(18) self.grid.add(vbox_container) self.grid.attach_next_to(hbox, vbox_container, Gtk.PositionType.BOTTOM, 2, 1) @@ -1203,18 +1206,19 @@ class FirstPage(Gtk.Box): label_start = Gtk.Label() label_start.set_markup("Before we continue please make sure you do not have any other remappers running. Kinto works best when it is the only application remapping your keys.\n\nBy continuing you also agree that Kinto is not held liable for any harm, damage(s) or unexpected behaviors.\nThis software is free, open-source, and provided as-is.\n\n© 2019, 2020 by Ben Reaves ~ Kinto is licensed on GPLv2.") - label_start.set_alignment(0,0) + label_start.set_valign(Gtk.Align.START) + label_start.set_halign(Gtk.Align.START) label_start.set_line_wrap(True) vbox.add(label_start) scroller.add(vbox) hbox = Gtk.HBox() - previous = Gtk.Button("") + previous = Gtk.Button(label="") for child in previous.get_children(): child.set_label("Decline") child.set_use_markup(True) previous.connect("clicked", self.goback) - previous.set_margin_right(245) + previous.set_margin_end(245) hbox.add(previous) self.__parent_window.first_onward.set_label("") @@ -1228,16 +1232,16 @@ class FirstPage(Gtk.Box): hbox.set_hexpand(False) hbox.set_vexpand(False) hbox.set_margin_bottom(6) - hbox.set_margin_right(25) + hbox.set_margin_end(25) scroller.set_hexpand(True) scroller.set_vexpand(True) vbox_container.add(scroller) vbox_container.set_margin_top(55) - vbox_container.set_margin_right(28) - self.grid.set_margin_left(157) + vbox_container.set_margin_end(28) + self.grid.set_margin_start(157) vbox_container.set_margin_bottom(18) - vbox.set_margin_right(10) + vbox.set_margin_end(10) vbox.set_margin_bottom(18) self.grid.add(vbox_container) self.grid.attach_next_to(hbox, vbox_container, Gtk.PositionType.BOTTOM, 2, 1) @@ -1276,37 +1280,38 @@ class SecondPage(Gtk.Box): label_start = Gtk.Label() label_start.set_markup('Identifying your Keyboard...\n\nPress the 2nd key Left of the spacebar.\n\nIf stuck here then unset Overlay (Super) key on your DE.') - label_start.set_alignment(0,0) + label_start.set_valign(Gtk.Align.START) + label_start.set_halign(Gtk.Align.START) label_start.set_line_wrap(True) vbox.add(label_start) scroller.add(vbox) hbox = Gtk.HBox() - previous = Gtk.Button("") + previous = Gtk.Button(label="") for child in previous.get_children(): child.set_label("Go Back") child.set_use_markup(True) previous.connect("clicked", self.goback) - previous.set_margin_right(315) + previous.set_margin_end(315) hbox.add(previous) - # onward = Gtk.Button("Continue") + # onward = Gtk.Button(label="Continue") # onward.connect("clicked", self.forward) # hbox.add(onward) hbox.set_hexpand(False) hbox.set_vexpand(False) hbox.set_margin_bottom(6) - hbox.set_margin_right(25) + hbox.set_margin_end(25) scroller.set_hexpand(True) scroller.set_vexpand(True) vbox_container.add(scroller) vbox_container.set_margin_top(55) - vbox_container.set_margin_right(25) - self.grid.set_margin_left(157) + vbox_container.set_margin_end(25) + self.grid.set_margin_start(157) vbox_container.set_margin_bottom(18) - vbox.set_margin_right(10) + vbox.set_margin_end(10) vbox.set_margin_bottom(18) self.grid.add(vbox_container) self.grid.attach_next_to(hbox, vbox_container, Gtk.PositionType.BOTTOM, 2, 1) @@ -1360,37 +1365,38 @@ class CapsPage(Gtk.Box): label_start = Gtk.Label() label_start.set_markup('Identifying your Keyboard...\n\nPress the capslock key twice.') - label_start.set_alignment(0,0) + label_start.set_valign(Gtk.Align.START) + label_start.set_halign(Gtk.Align.START) label_start.set_line_wrap(True) vbox.add(label_start) scroller.add(vbox) hbox = Gtk.HBox() - previous = Gtk.Button("") + previous = Gtk.Button(label="") for child in previous.get_children(): child.set_label("Go Back") child.set_use_markup(True) previous.connect("clicked", self.goback) - previous.set_margin_right(315) + previous.set_margin_end(315) hbox.add(previous) - # onward = Gtk.Button("Continue") + # onward = Gtk.Button(label="Continue") # onward.connect("clicked", self.forward) # hbox.add(onward) hbox.set_hexpand(False) hbox.set_vexpand(False) hbox.set_margin_bottom(6) - hbox.set_margin_right(25) + hbox.set_margin_end(25) scroller.set_hexpand(True) scroller.set_vexpand(True) vbox_container.add(scroller) vbox_container.set_margin_top(55) - vbox_container.set_margin_right(25) - self.grid.set_margin_left(157) + vbox_container.set_margin_end(25) + self.grid.set_margin_start(157) vbox_container.set_margin_bottom(18) - vbox.set_margin_right(10) + vbox.set_margin_end(10) vbox.set_margin_bottom(18) self.grid.add(vbox_container) self.grid.attach_next_to(hbox, vbox_container, Gtk.PositionType.BOTTOM, 2, 1) @@ -1427,9 +1433,9 @@ class SuccessPage(Gtk.Box): self.grid = Gtk.Grid() hbox = Gtk.HBox() - previous = Gtk.Button(" ") + previous = Gtk.Button(label=" ") previous.props.relief = Gtk.ReliefStyle.NONE - previous.set_margin_right(245) + previous.set_margin_end(245) hbox.add(previous) self.__parent_window.last_onward.set_label("") @@ -1442,7 +1448,7 @@ class SuccessPage(Gtk.Box): hbox.set_hexpand(False) hbox.set_vexpand(False) hbox.set_margin_bottom(6) - hbox.set_margin_right(25) + hbox.set_margin_end(25) scroller = Gtk.ScrolledWindow() scroller.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.NEVER) @@ -1451,11 +1457,11 @@ class SuccessPage(Gtk.Box): vbox = Gtk.VBox() vbox_container = Gtk.VBox() vbox_container.set_margin_top(55) - vbox_container.set_margin_right(28) + vbox_container.set_margin_end(28) vbox_container.add(scroller) - self.grid.set_margin_left(157) + self.grid.set_margin_start(157) vbox_container.set_margin_bottom(18) - vbox.set_margin_right(10) + vbox.set_margin_end(10) vbox.set_margin_bottom(18) self.grid.add(vbox_container) self.grid.attach_next_to(hbox, vbox_container, Gtk.PositionType.BOTTOM, 2, 1) From 32fba15d75a03a1e251048dfdb472fbc868a1763 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Tue, 4 May 2021 18:19:46 -0500 Subject: [PATCH 3/9] Aligning systray w/ GUI app for sysv detection --- linux/trayapps/appindicator/kintotray.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/linux/trayapps/appindicator/kintotray.py b/linux/trayapps/appindicator/kintotray.py index 3b7fc3d..9e332ad 100755 --- a/linux/trayapps/appindicator/kintotray.py +++ b/linux/trayapps/appindicator/kintotray.py @@ -7,7 +7,7 @@ gi.require_version('AppIndicator3', '0.1') gi.require_version('Notify', '0.7') import signal,time,os,fcntl,datetime,re -from subprocess import Popen, PIPE, CalledProcessError, check_output +from subprocess import Popen, PIPE, CalledProcessError from shutil import which from gi.repository import Gtk,GLib,GdkPixbuf from gi.repository import AppIndicator3 as appindicator @@ -31,9 +31,9 @@ class Indicator(): global child_pid global sysv try: - sysv = check_output("pidof systemd >/dev/null 2>&1 && echo '0' || echo '1'").strip().decode('UTF-8') + sysv = int(Popen("pidof systemd >/dev/null 2>&1 && echo '0' || echo '1'", stdout=PIPE, shell=True).communicate()[0].strip().decode('UTF-8')) except: - sysv = 1 + sysv = 2 if sysv: kinto_status = Popen("while :; do clear; pgrep 'xkeysnail' && echo 'active'; sleep 2; done", stdout=PIPE, shell=True) else: From 9a3521d05c5d3063d517dcbc557e563ac9781786 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Tue, 4 May 2021 23:58:09 -0500 Subject: [PATCH 4/9] Added missing sysvinit file copy --- xkeysnail_service.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xkeysnail_service.sh b/xkeysnail_service.sh index acc393d..cb4589a 100755 --- a/xkeysnail_service.sh +++ b/xkeysnail_service.sh @@ -196,6 +196,7 @@ if [[ $1 == "5" || $1 == "uninstall" || $1 == "Uninstall" ]]; then echo "rm /etc/systemd/system/graphical.target.wants/xkeysnail.service" echo "rm /usr/lib/systemd/system/xkeysnail.service" echo "rm /lib/systemd/system/xkeysnail.service" + sudo rm /etc/init.d/kinto >/dev/null 2>&1 sudo rm /etc/systemd/system/xkeysnail.service >/dev/null 2>&1 sudo rm /etc/systemd/system/graphical.target.wants/xkeysnail.service >/dev/null 2>&1 sudo rm /usr/lib/systemd/system/xkeysnail.service >/dev/null 2>&1 @@ -565,6 +566,7 @@ if ! [[ $1 == "5" || $1 == "uninstall" || $1 == "Uninstall" ]]; then else # echo "Using sysvinit..." echo "" + sudo cp ./linux/kinto-service.sh /etc/init.d/kinto sudo -E /etc/init.d/kinto stop & fi # sudo systemctl --state=not-found --all | grep xkeysnail From 7375dd78bf91e016a8bad2860698acfb769aba58 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Wed, 5 May 2021 14:46:50 -0500 Subject: [PATCH 5/9] Updated hotkeys for xfce4 --- linux/kinto.py | 24 ++++++++---------------- xkeysnail_service.sh | 21 ++++++++++++++++++++- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/linux/kinto.py b/linux/kinto.py index 1eb64a1..3dee91f 100755 --- a/linux/kinto.py +++ b/linux/kinto.py @@ -435,11 +435,11 @@ define_keymap(lambda wm_class: wm_class.casefold() not in remotes,{ # K("Super-Left"):K("C-M-Left"), # Default SL - Change workspace (budgie) K("RC-Q"): K("M-F4"), # Default SL - not-popos K("RC-H"):K("Super-h"), # Default SL - Minimize app (gnome/budgie/popos/fedora) - K("M-Tab"): pass_through_key, # Default not-xfce4 - Cmd Tab - App Switching Default - K("RC-Tab"): K("M-Tab"), # Default not-xfce4 - Cmd Tab - App Switching Default - K("RC-Shift-Tab"): K("M-Shift-Tab"), # Default not-xfce4 - Cmd Tab - App Switching Default - K("RC-Grave"): K("M-Grave"), # Default not-xfce4 - Cmd ` - Same App Switching - K("RC-Shift-Grave"): K("M-Shift-Grave"), # Default not-xfce4 - Cmd ` - Same App Switching + K("M-Tab"): pass_through_key, # Default - Cmd Tab - App Switching Default + K("RC-Tab"): K("M-Tab"), # Default - Cmd Tab - App Switching Default + K("RC-Shift-Tab"): K("M-Shift-Tab"), # Default - Cmd Tab - App Switching Default + K("RC-Grave"): K("M-Grave"), # Default - Cmd ` - Same App Switching + K("RC-Shift-Grave"): K("M-Shift-Grave"), # Default - Cmd ` - Same App Switching # K("Super-Right"):K("Super-Page_Up"), # SL - Change workspace (ubuntu/fedora) # K("Super-Left"):K("Super-Page_Down"), # SL - Change workspace (ubuntu/fedora) # K("Super-Right"):K("Super-C-Up"), # SL - Change workspace (popos) @@ -455,10 +455,6 @@ define_keymap(lambda wm_class: wm_class.casefold() not in remotes,{ # Basic App hotkey functions # K("RC-H"):K("M-F9"), # SL - Minimize app xfce4 # K("RC-LC-f"):K("Super-PAGE_DOWN"), # SL - Minimize app manjaro - # Cmd Tab - App Switching Default - # K("RC-Tab"): K("RC-backslash"), # xfce4 - # K("RC-Shift-Tab"): K("RC-Shift-backslash"), # xfce4 - # K("RC-Grave"): K("RC-Shift-backslash"), # xfce4 # In-App Tab switching # K("M-Tab"): K("C-Tab"), # Chromebook/IBM - In-App Tab switching # K("M-Shift-Tab"): K("C-Shift-Tab"), # Chromebook/IBM - In-App Tab switching @@ -668,13 +664,9 @@ define_keymap(re.compile(termStr, re.IGNORECASE),{ K("LC-Tab") : K("LC-PAGE_DOWN"), K("LC-Shift-Tab") : K("LC-PAGE_UP"), K("LC-Grave") : K("LC-PAGE_UP"), - # K("M-Tab"): pass_through_key, # Default not-xfce4 - Cmd Tab - App Switching Default - # K("RC-Tab"): K("M-Tab"), # Default not-xfce4 - Cmd Tab - App Switching Default - # K("RC-Shift-Tab"): K("M-Shift-Tab"), # Default not-xfce4 - Cmd Tab - App Switching Default - # Cmd Tab - App Switching Default - # K("RC-Tab"): K("RC-backslash"), # xfce4 - # K("RC-Shift-Tab"): K("RC-Shift-backslash"), # xfce4 - # K("RC-Grave"): K("RC-Shift-backslash"), # xfce4 + # K("M-Tab"): pass_through_key, # Default - Cmd Tab - App Switching Default + # K("RC-Tab"): K("M-Tab"), # Default - Cmd Tab - App Switching Default + # K("RC-Shift-Tab"): K("M-Shift-Tab"), # Default - Cmd Tab - App Switching Default # Converts Cmd to use Ctrl-Shift K("RC-MINUS"): K("C-Shift-MINUS"), K("RC-EQUAL"): K("C-Shift-EQUAL"), diff --git a/xkeysnail_service.sh b/xkeysnail_service.sh index cb4589a..b350337 100755 --- a/xkeysnail_service.sh +++ b/xkeysnail_service.sh @@ -45,7 +45,11 @@ function uninstall { 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 + if test -f "/etc/mx-version";then + cp /etc/skel/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml + else + cp /etc/xdg/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml + fi fi elif [ "$yn" == "r" ]; then echo "Restore original user shortcuts" @@ -84,6 +88,12 @@ function uninstall { echo -e "\nWill still be restoring the overlay key" echo -e "gsettings set org.gnome.mutter overlay-key 'super'\n" gsettings set org.gnome.mutter overlay-key 'super' + # Repetitive - xfce restore factory or backup does this + # Also needs to check if whiskermenu is even being used + # elif [[ $dename == "xfce" ]]; then + # echo -e "\nWill still be restoring the overlay key" + # echo -e "xfconf-query --channel xfce4-keyboard-shortcuts --property \"/commands/custom/Super_L\" --create --type string --set \"xfce4-popup-whiskermenu\"" + # xfconf-query --channel xfce4-keyboard-shortcuts --property "/commands/custom/Super_L" --create --type string --set "xfce4-popup-whiskermenu" fi } @@ -244,6 +254,15 @@ if [[ $dename == 'gnome' || $dename == 'budgie' ]];then echo "Overlay key, " $bound ", detected. Will be removing so Super-Space can remap to Cmd-Space for app launching.." gsettings set org.gnome.mutter overlay-key '' fi +elif [[ $dename == 'xfce' ]];then + # xfconf-query --channel xfce4-keyboard-shortcuts --property "/commands/custom/Super_L" --reset + launcher=$(cat ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml | grep 'name="Super_L"' | sed 's:.*="::') + nlauncher=${launcher::-3} + # Replace Alt-F1 help file w/ whisker menu alternative hotkey + xfconf-query --channel xfce4-keyboard-shortcuts --property "/commands/custom/F1" --reset + # Clear Alt-F3 App Finder for sublime text global replace + xfconf-query --channel xfce4-keyboard-shortcuts --property "/commands/custom/F3" --reset + xfconf-query --channel xfce4-keyboard-shortcuts --property "/commands/custom/F1" --create --type string --set "$nlauncher" && echo "$nlauncher has been set to Alt-F1 for Cmd-Space to work." fi # if ls /etc/apt/sources.list.d/system76* 1> /dev/null 2>&1; then From 5d1b1d65983e5f68ffb4f2e853093f5a32d17239 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Wed, 5 May 2021 05:30:59 -0500 Subject: [PATCH 6/9] XFCE super key install conflict resolved. Improved launcher detection/remapping. --- linux/kinto-service.sh | 4 ++-- xkeysnail_service.sh | 54 +++++++++++++++++++++++++++++++++++------- 2 files changed, 48 insertions(+), 10 deletions(-) diff --git a/linux/kinto-service.sh b/linux/kinto-service.sh index 9bdc4f1..2b87d5c 100755 --- a/linux/kinto-service.sh +++ b/linux/kinto-service.sh @@ -27,7 +27,7 @@ start() { # Restart the service stop() { echo -n "Stopping Kinto (xkeynsail)" | logger - pgrep 'xkeysnail' | xargs -r -n1 sudo kill + pgrep 'bin\xkeysnail' | xargs -r -n1 sudo kill ### Now, delete the lock file ### rm -f /var/lock/subsys/kinto echo @@ -46,7 +46,7 @@ case "$1" in ;; restart|reload|condrestart) stop - sleep 2 + sleep 5 start ;; *) diff --git a/xkeysnail_service.sh b/xkeysnail_service.sh index b350337..47efc6d 100755 --- a/xkeysnail_service.sh +++ b/xkeysnail_service.sh @@ -225,6 +225,9 @@ fi sudo systemctl stop xkeysnail >/dev/null 2>&1 sudo systemctl disable xkeysnail >/dev/null 2>&1 sudo pkill -f bin/xkeysnail >/dev/null 2>&1 +sudo pkill -f kinto-gui.py >/dev/null 2>&1 +sudo pkill -f kintotray.py >/dev/null 2>&1 +ps aux | awk '/[s]h -c while/ {print $2}' | xargs -r -n1 sudo kill sudo pkill -f "is-active xkeysnail" >/dev/null 2>&1 if [ "$distro" == "manjarolinux" ]; then @@ -255,14 +258,29 @@ if [[ $dename == 'gnome' || $dename == 'budgie' ]];then gsettings set org.gnome.mutter overlay-key '' fi elif [[ $dename == 'xfce' ]];then - # xfconf-query --channel xfce4-keyboard-shortcuts --property "/commands/custom/Super_L" --reset launcher=$(cat ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml | grep 'name="Super_L"' | sed 's:.*="::') - nlauncher=${launcher::-3} - # Replace Alt-F1 help file w/ whisker menu alternative hotkey - xfconf-query --channel xfce4-keyboard-shortcuts --property "/commands/custom/F1" --reset - # Clear Alt-F3 App Finder for sublime text global replace - xfconf-query --channel xfce4-keyboard-shortcuts --property "/commands/custom/F3" --reset - xfconf-query --channel xfce4-keyboard-shortcuts --property "/commands/custom/F1" --create --type string --set "$nlauncher" && echo "$nlauncher has been set to Alt-F1 for Cmd-Space to work." + # echo "${#launcher}" + if [[ "${#launcher}" -eq 0 ]]; then + xfconf-query --channel xfce4-keyboard-shortcuts --property "/commands/custom/Super_L" --create --type string --set "xfce4-popup-whiskermenu" + echo "Resetting Super_L, please wait..." + sleep 6 + launcher=$(cat ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml | grep 'name="Super_L"' | sed 's:.*="::') + if [[ "${#launcher}" -gt 0 ]]; then + echo "Success." + else + echo "Failed. Skipping setup of Cmd-Space." + fi + fi + if [[ "${#launcher}" -gt 0 ]]; then + nlauncher=${launcher::-3} + # Replace Alt-F1 help file w/ whisker menu alternative hotkey + xfconf-query --channel xfce4-keyboard-shortcuts --property "/commands/custom/F1" --reset + # Clear Alt-F3 App Finder for sublime text global replace + xfconf-query --channel xfce4-keyboard-shortcuts --property "/commands/custom/F3" --reset + xfconf-query --channel xfce4-keyboard-shortcuts --property "/commands/custom/F1" --create --type string --set "$nlauncher" && echo "$nlauncher has been set to Alt-F1 for Cmd-Space to work." + # Unset Super_L to avoid issues during setup, will re-apply at the end + xfconf-query --channel xfce4-keyboard-shortcuts --property "/commands/custom/Super_L" --reset + fi fi # if ls /etc/apt/sources.list.d/system76* 1> /dev/null 2>&1; then @@ -530,6 +548,7 @@ if [[ $dename == "xfce" ]] && ls /etc/apt/sources.list.d/enso* 1> /dev/null 2>&1 fi if ! [[ $1 == "5" || $1 == "uninstall" || $1 == "Uninstall" ]]; then + mv ./linux/kinto.py.new ~/.config/kinto/kinto.py # if [ "$distro" == "fedora" ];then if [ ! "$sysv" -eq 0 ];then @@ -586,7 +605,8 @@ if ! [[ $1 == "5" || $1 == "uninstall" || $1 == "Uninstall" ]]; then # echo "Using sysvinit..." echo "" sudo cp ./linux/kinto-service.sh /etc/init.d/kinto - sudo -E /etc/init.d/kinto stop & + sudo -E /etc/init.d/kinto stop + mv /tmp/kinto.log /tmp/kinto.log.bak fi # sudo systemctl --state=not-found --all | grep xkeysnail # if [ "$distro" == "fedora" ];then @@ -628,6 +648,24 @@ if ! [[ $1 == "5" || $1 == "uninstall" || $1 == "Uninstall" ]]; then echo -e "~/.config/kinto/gui/kinto-gui.py\n" echo -e "You can then either \e]8;;https://google.com\a\e[1m\e[36mG\033[0;91mo\033[0;93mo\e[1m\e[36mg\e[1m\e[32ml\033[0;91me\e[0m\e]8;;\a what dependencies you may be missing\nor \e]8;;https://github.com/rbreaves/kinto/issues/new\?assignees=rbreaves&labels=bug&template=bug_report.md&title=\aopen an issue ticket.\e]8;;\a\n" + echo -e "\033[0;91mAfter the installer completes press Any key to re-apply your overlay (Super key) menu launcher.\e[0m\n" + + if [[ $dename == 'gnome' || $dename == 'budgie' ]];then + echo "GNOME: gsettings set org.gnome.mutter overlay-key 'super'" + elif [[ $dename == 'xfce' ]];then + echo "XFCE: xfconf-query --channel xfce4-keyboard-shortcuts --property \"/commands/custom/Super_L\" --create --type string --set \"$nlauncher\"" + fi + + read -n 1 -s -r -p "" + + if [[ $dename == 'gnome' || $dename == 'budgie' ]];then + gsettings set org.gnome.mutter overlay-key 'super' + elif [[ $dename == 'xfce' ]];then + echo -e "\nSetting xfce4 launcher $nlauncher back to Super_L." + xfconf-query --channel xfce4-keyboard-shortcuts --property "/commands/custom/Super_L" --create --type string --set "$nlauncher" && echo "Success." + fi + + if [ "$distro" == "manjarolinux" ]; then echo "If you are using Manjaro and see an error about 'GLIBC_2.xx not found' appears then please update your system." echo "sudo pacman -Syu" From e1f1907e46e36858b2d6e75202845d3a91638938 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Wed, 5 May 2021 06:17:06 -0500 Subject: [PATCH 7/9] Reverted adding back of Super for now, fixed Ctrl-Tab for xfce4 --- xkeysnail_service.sh | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/xkeysnail_service.sh b/xkeysnail_service.sh index 47efc6d..902cd59 100755 --- a/xkeysnail_service.sh +++ b/xkeysnail_service.sh @@ -280,7 +280,12 @@ elif [[ $dename == 'xfce' ]];then xfconf-query --channel xfce4-keyboard-shortcuts --property "/commands/custom/F1" --create --type string --set "$nlauncher" && echo "$nlauncher has been set to Alt-F1 for Cmd-Space to work." # Unset Super_L to avoid issues during setup, will re-apply at the end xfconf-query --channel xfce4-keyboard-shortcuts --property "/commands/custom/Super_L" --reset + xfconf-query --channel xfce4-keyboard-shortcuts --property "/commands/custom/Tab" --reset + xfconf-query --channel xfce4-keyboard-shortcuts --property "/commands/custom/Tab" --create --type string --set "" fi + # Unset Super-Tab, breaks Ctrl-Tab. switch_window_key + sed -i '/.*name=\"<Super>Tab.*$/d' ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml + fi # if ls /etc/apt/sources.list.d/system76* 1> /dev/null 2>&1; then @@ -648,22 +653,22 @@ if ! [[ $1 == "5" || $1 == "uninstall" || $1 == "Uninstall" ]]; then echo -e "~/.config/kinto/gui/kinto-gui.py\n" echo -e "You can then either \e]8;;https://google.com\a\e[1m\e[36mG\033[0;91mo\033[0;93mo\e[1m\e[36mg\e[1m\e[32ml\033[0;91me\e[0m\e]8;;\a what dependencies you may be missing\nor \e]8;;https://github.com/rbreaves/kinto/issues/new\?assignees=rbreaves&labels=bug&template=bug_report.md&title=\aopen an issue ticket.\e]8;;\a\n" - echo -e "\033[0;91mAfter the installer completes press Any key to re-apply your overlay (Super key) menu launcher.\e[0m\n" + # echo -e "\033[0;91mAfter the installer completes press Any key to re-apply your overlay (Super key) menu launcher.\e[0m\n" - if [[ $dename == 'gnome' || $dename == 'budgie' ]];then - echo "GNOME: gsettings set org.gnome.mutter overlay-key 'super'" - elif [[ $dename == 'xfce' ]];then - echo "XFCE: xfconf-query --channel xfce4-keyboard-shortcuts --property \"/commands/custom/Super_L\" --create --type string --set \"$nlauncher\"" - fi + # if [[ $dename == 'gnome' || $dename == 'budgie' ]];then + # echo "GNOME: gsettings set org.gnome.mutter overlay-key 'super'" + # elif [[ $dename == 'xfce' ]];then + # echo "XFCE: xfconf-query --channel xfce4-keyboard-shortcuts --property \"/commands/custom/Super_L\" --create --type string --set \"$nlauncher\"" + # fi - read -n 1 -s -r -p "" + # read -n 1 -s -r -p "" - if [[ $dename == 'gnome' || $dename == 'budgie' ]];then - gsettings set org.gnome.mutter overlay-key 'super' - elif [[ $dename == 'xfce' ]];then - echo -e "\nSetting xfce4 launcher $nlauncher back to Super_L." - xfconf-query --channel xfce4-keyboard-shortcuts --property "/commands/custom/Super_L" --create --type string --set "$nlauncher" && echo "Success." - fi + # if [[ $dename == 'gnome' || $dename == 'budgie' ]];then + # gsettings set org.gnome.mutter overlay-key 'super' + # elif [[ $dename == 'xfce' ]];then + # echo -e "\nSetting xfce4 launcher $nlauncher back to Super_L." + # xfconf-query --channel xfce4-keyboard-shortcuts --property "/commands/custom/Super_L" --create --type string --set "$nlauncher" && echo "Success." + # fi if [ "$distro" == "manjarolinux" ]; then From c298bd2b5a52570926233132d66c8de5bdc8b6b4 Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Wed, 5 May 2021 06:55:42 -0500 Subject: [PATCH 8/9] Fixes Cmd-Grave for In-App switching --- linux/kinto.py | 9 ++++++--- xkeysnail_service.sh | 5 ++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/linux/kinto.py b/linux/kinto.py index 3dee91f..679d44c 100755 --- a/linux/kinto.py +++ b/linux/kinto.py @@ -438,8 +438,10 @@ define_keymap(lambda wm_class: wm_class.casefold() not in remotes,{ K("M-Tab"): pass_through_key, # Default - Cmd Tab - App Switching Default K("RC-Tab"): K("M-Tab"), # Default - Cmd Tab - App Switching Default K("RC-Shift-Tab"): K("M-Shift-Tab"), # Default - Cmd Tab - App Switching Default - K("RC-Grave"): K("M-Grave"), # Default - Cmd ` - Same App Switching - K("RC-Shift-Grave"): K("M-Shift-Grave"), # Default - Cmd ` - Same App Switching + K("RC-Grave"): K("M-Grave"), # Default not-xfce4 - Cmd ` - Same App Switching + K("RC-Shift-Grave"): K("M-Shift-Grave"), # Default not-xfce4 - Cmd ` - Same App Switching + # K("RC-Grave"): K("Super-Tab"), # xfce4 Switch within app group + # K("RC-Shift-Grave"): K("Super-Shift-Tab"), # xfce4 Switch within app group # K("Super-Right"):K("Super-Page_Up"), # SL - Change workspace (ubuntu/fedora) # K("Super-Left"):K("Super-Page_Down"), # SL - Change workspace (ubuntu/fedora) # K("Super-Right"):K("Super-C-Up"), # SL - Change workspace (popos) @@ -650,6 +652,8 @@ define_keymap(re.compile("Io.elementary.terminal|kitty", re.IGNORECASE),{ }, "Elementary Terminal tab switching") define_keymap(re.compile(termStr, re.IGNORECASE),{ + # K("RC-Grave"): K("Super-Tab"), # xfce4 Switch within app group + # K("RC-Shift-Grave"): K("Super-Shift-Tab"), # xfce4 Switch within app group # K("LC-Right"):K("C-M-Right"), # Default SL - Change workspace (budgie) # K("LC-Left"):K("C-M-Left"), # Default SL - Change workspace (budgie) # K("LC-Left"):K("C-M-End"), # SL - Change workspace xfce4 @@ -694,7 +698,6 @@ define_keymap(re.compile(termStr, re.IGNORECASE),{ K("RC-SEMICOLON"): K("C-Shift-SEMICOLON"), K("RC-APOSTROPHE"): K("C-Shift-APOSTROPHE"), K("RC-GRAVE"): K("C-Shift-GRAVE"), - K("RC-BACKSLASH"): K("C-Shift-BACKSLASH"), K("RC-Z"): K("C-Shift-Z"), K("RC-X"): K("C-Shift-X"), K("RC-C"): K("C-Shift-C"), diff --git a/xkeysnail_service.sh b/xkeysnail_service.sh index 902cd59..4eb251a 100755 --- a/xkeysnail_service.sh +++ b/xkeysnail_service.sh @@ -280,12 +280,11 @@ elif [[ $dename == 'xfce' ]];then xfconf-query --channel xfce4-keyboard-shortcuts --property "/commands/custom/F1" --create --type string --set "$nlauncher" && echo "$nlauncher has been set to Alt-F1 for Cmd-Space to work." # Unset Super_L to avoid issues during setup, will re-apply at the end xfconf-query --channel xfce4-keyboard-shortcuts --property "/commands/custom/Super_L" --reset - xfconf-query --channel xfce4-keyboard-shortcuts --property "/commands/custom/Tab" --reset - xfconf-query --channel xfce4-keyboard-shortcuts --property "/commands/custom/Tab" --create --type string --set "" + # xfconf-query --channel xfce4-keyboard-shortcuts --property "/commands/custom/grave" --create --type string --set "switch_window_key" + fi # Unset Super-Tab, breaks Ctrl-Tab. switch_window_key sed -i '/.*name=\"<Super>Tab.*$/d' ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml - fi # if ls /etc/apt/sources.list.d/system76* 1> /dev/null 2>&1; then From eb113125b5a92a248c82b18f86b581e546ee9c5a Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Wed, 5 May 2021 21:11:30 -0500 Subject: [PATCH 9/9] Corrected the killing of xkeysnail under sysvinit --- linux/kinto-service.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux/kinto-service.sh b/linux/kinto-service.sh index 2b87d5c..e02279c 100755 --- a/linux/kinto-service.sh +++ b/linux/kinto-service.sh @@ -27,7 +27,7 @@ start() { # Restart the service stop() { echo -n "Stopping Kinto (xkeynsail)" | logger - pgrep 'bin\xkeysnail' | xargs -r -n1 sudo kill + sudo pkill -f bin/xkeysnail >/dev/null 2>&1 ### Now, delete the lock file ### rm -f /var/lock/subsys/kinto echo