- Updated xkeysnail installer to properly copy desktop autostart and to restart service on config file changes

This commit is contained in:
Ben Reaves
2020-04-21 17:39:20 -05:00
parent 3b802d1d49
commit c1e2db9a2e
5 changed files with 49 additions and 7 deletions

21
system-config/unipkg.sh Executable file
View File

@@ -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 $?

View File

@@ -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

View File

@@ -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

8
xkeysnail-config/xkeystart.sh Executable file
View File

@@ -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

View File

@@ -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