Skip to content

Commit

Permalink
Merge pull request #498 from rbreaves/dev
Browse files Browse the repository at this point in the history
Add support for sysvinit & mxlinux w/ xfce
  • Loading branch information
rbreaves authored May 6, 2021
2 parents e4540af + eb11312 commit 1d1971f
Show file tree
Hide file tree
Showing 7 changed files with 354 additions and 118 deletions.
174 changes: 109 additions & 65 deletions linux/gui/kinto-gui.py

Large diffs are not rendered by default.

57 changes: 57 additions & 0 deletions linux/kinto-service.sh
Original file line number Diff line number Diff line change
@@ -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
sudo pkill -f bin/xkeysnail >/dev/null 2>&1
### 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 5
start
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|status}"
exit 1
esac

exit 0
25 changes: 10 additions & 15 deletions linux/kinto.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,11 +435,13 @@
# 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("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 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)
Expand All @@ -455,10 +457,6 @@
# 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
Expand Down Expand Up @@ -654,6 +652,8 @@
}, "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
Expand All @@ -668,13 +668,9 @@
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"),
Expand Down Expand Up @@ -702,7 +698,6 @@
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"),
Expand Down
5 changes: 4 additions & 1 deletion linux/limitedadmins
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# /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
%{username} ALL=NOPASSWD: {systemctl} status xkeysnail
%{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
46 changes: 39 additions & 7 deletions linux/trayapps/appindicator/kintotray.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,15 @@ def kill_child():
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 = 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

homedir = os.path.expanduser("~")
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -446,7 +462,10 @@ def on_delete_event(event, self, widget):
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

Expand Down Expand Up @@ -555,8 +574,12 @@ def setCaps2Cmd(self,button):
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'])
Expand All @@ -567,13 +590,19 @@ def runRestart(self,button):
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'])
Expand Down Expand Up @@ -689,7 +718,10 @@ def setKB(self,button,kbtype):
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:
Expand Down
8 changes: 8 additions & 0 deletions linux/xkeysnail_sysv.desktop
Original file line number Diff line number Diff line change
@@ -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
Loading

0 comments on commit 1d1971f

Please sign in to comment.