From 57d56261ed19f06240d56cde528e05e3e194dd1f Mon Sep 17 00:00:00 2001 From: Ben Reaves Date: Fri, 31 Jul 2020 21:22:50 -0500 Subject: [PATCH] - WIP Updated installer to setup budgie system tray --- xkeysnail-config/limitedadmins | 2 +- .../BudgieApplet/KintoApplet/Kinto.plugin | 2 +- .../BudgieApplet/KintoApplet/kinto.py | 6 +- xkeysnail-config/xkeysnail.service | 1 - xkeysnail_service.sh | 78 ++++++++++++++----- 5 files changed, 62 insertions(+), 27 deletions(-) diff --git a/xkeysnail-config/limitedadmins b/xkeysnail-config/limitedadmins index 0818189..7ccec01 100644 --- a/xkeysnail-config/limitedadmins +++ b/xkeysnail-config/limitedadmins @@ -3,4 +3,4 @@ %{username} ALL=NOPASSWD: {systemctl} start xkeysnail %{username} ALL=NOPASSWD: {systemctl} stop xkeysnail %{username} ALL=NOPASSWD: {systemctl} status xkeysnail -%{username} ALL=NOPASSWD: {systemctl} is-active --quiet xkeysnail \ No newline at end of file +%{username} ALL=NOPASSWD: {systemctl} is-active --quiet xkeysnail diff --git a/xkeysnail-config/trayapps/BudgieApplet/KintoApplet/Kinto.plugin b/xkeysnail-config/trayapps/BudgieApplet/KintoApplet/Kinto.plugin index f1453f2..2c915b6 100644 --- a/xkeysnail-config/trayapps/BudgieApplet/KintoApplet/Kinto.plugin +++ b/xkeysnail-config/trayapps/BudgieApplet/KintoApplet/Kinto.plugin @@ -6,4 +6,4 @@ Description=Kinto Applet Authors=Ben Reaves Copyright=Copyright © 2020 Ben Reaves Website=github.com/rbreaves -Icon=kinto-invert +Icon=kinto-solid diff --git a/xkeysnail-config/trayapps/BudgieApplet/KintoApplet/kinto.py b/xkeysnail-config/trayapps/BudgieApplet/KintoApplet/kinto.py index ac888dd..c1937c3 100644 --- a/xkeysnail-config/trayapps/BudgieApplet/KintoApplet/kinto.py +++ b/xkeysnail-config/trayapps/BudgieApplet/KintoApplet/kinto.py @@ -63,7 +63,7 @@ class KintoApplet(Budgie.Applet): chkautostart_id=0 autostart_bool = False - subprocess.Popen(['sh',homedir+'/.config/kinto/logoff.sh']) + # subprocess.Popen(['sh',homedir+'/.config/kinto/logoff.sh']) with open(kconfig) as configfile: autostart_line = configfile.read().split('\n')[1] @@ -87,11 +87,11 @@ class KintoApplet(Budgie.Applet): self.checkbox_autostart.set_label("Autostart") # self.checkbox_autostart.modify_fg(Gtk.STATE_NORMAL, Gtk.Gdk.color_parse('#366B7E')); if self.autostart_bool: - subprocess.Popen(['sudo', 'systemctl','restart','xkeysnail']) + # subprocess.Popen(['sudo', 'systemctl','restart','xkeysnail']) self.checkbox_autostart.set_active(True) self.chkautostart_id = self.checkbox_autostart.connect("clicked",self.setAutostart,False) else: - subprocess.Popen(['sudo', 'systemctl','stop','xkeysnail']) + # subprocess.Popen(['sudo', 'systemctl','stop','xkeysnail']) self.checkbox_autostart.set_active(False) self.chkautostart_id = self.checkbox_autostart.connect("clicked",self.setAutostart,True) # self.chkautostart_id = self.checkbox_autostart.connect("clicked",self.setAutostart,True) diff --git a/xkeysnail-config/xkeysnail.service b/xkeysnail-config/xkeysnail.service index 6935d75..d11ff4f 100644 --- a/xkeysnail-config/xkeysnail.service +++ b/xkeysnail-config/xkeysnail.service @@ -5,7 +5,6 @@ Description=xkeysnail Type=simple KillMode=process ExecStart=/usr/bin/sudo /bin/bash -c '/usr/bin/xhost +SI:localuser:root && /usr/local/bin/xkeysnail --quiet --watch {homedir}/.config/kinto/kinto.py' -ExecStop=/usr/bin/pkill -f xkeysnail Restart=on-failure RestartSec=3 Environment=DISPLAY={displayid} diff --git a/xkeysnail_service.sh b/xkeysnail_service.sh index 37df637..ddbe8a3 100755 --- a/xkeysnail_service.sh +++ b/xkeysnail_service.sh @@ -86,6 +86,39 @@ function removeAppleKB { fi } +function trayApp { + if [ -f /usr/bin/budgie-desktop ];then + while true; do + read -rep $'Would you like to install the Kinto Budgie Applet? (y/n)\n(You will need log off & back on and go to Budgie Desktop Settings & add Kinto to your top panel.)\n' yn + case $yn in + [Yy]* ) yn="y"; break;; + [Nn]* ) yn="n";break;; + * ) echo "Please answer yes or no.";; + esac + done + if [ "$yn" == "y" ]; then + cd ./xkeysnail-config/trayapps/BudgieApplet/ + sudo ./install-applet.sh + cd ../../../ + echo "Please logoff and back on for the Applet to be available for the top panel." + ~/.config/kinto/gnome_logoff.sh& + fi + else + while true; do + read -rep $'Would you like to install the Kinto Gnome/XFCE System Tray? (y/n)\n' yn + case $yn in + [Yy]* ) yn="y"; break;; + [Nn]* ) yn="n";break;; + * ) echo "Please answer yes or no.";; + esac + done + if [ "$yn" == "y" ]; then + echo "Kinto Gnome/XFCE System Tray Installed." + fi + fi +} + + function budgieUninstall { if [ -f /usr/bin/budgie-desktop ];then read -n 1 -s -r -p "Your system may log you off immediately during the restoration of budgie-daemon. Press any key to continue..." @@ -104,7 +137,7 @@ function budgieUpdate { # Check for budgie and install App Switching hack if [ -f /usr/bin/budgie-desktop ];then while true; do - read -rep $'Would you like to update Budgie to support proper App Switching? (y/n)\n(Your system will immediately log you out after this runs.)\n' yn + read -rep $'Would you like to update Budgie to support proper App Switching? (y/n)\n(Your system may immediately log you out after this runs.)\n' yn case $yn in [Yy]* ) yn="y"; break;; [Nn]* ) yn="n";break;; @@ -197,10 +230,10 @@ if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1 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..." - sudo ./system-config/unipkg.sh inotify-tools - fi + # 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 if ! [ -x "$(command -v pip3)" ]; then echo "Will need to install python3-pip..." sudo ./system-config/unipkg.sh python3-pip @@ -229,20 +262,20 @@ if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1 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 + # mkdir -p ~/.kde/Autostart + # echo -e '#!/bin/sh\rxhost +SI:localuser:root' > ~/.kde/Autostart/kintohost.sh + # chmod +x ~/.kde/Autostart/kintohost.sh # KDE startup - xhost fix mkdir -p ~/.config/autostart 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/xkeystart.sh ~/.config/kinto/xkeystart.sh yes | cp -rf ./xkeysnail-config/gnome_logoff.sh ~/.config/kinto/gnome_logoff.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 ./system-config/caret_status_xkey.sh ~/.config/kinto/caret_status_xkey.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 sed -i "s#{experimental-caret}#$exp#g" ./xkeysnail-config/xkeysnail.service.new @@ -255,16 +288,15 @@ if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1 sed -i "s#{homedir}#`echo "$HOME"`#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#{homedir}#`echo "$HOME"`#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#{homedir}#`echo "$HOME"`#g" ~/.config/autostart/xkeysnail.desktop - sed -i "s#{homedir}#`echo "$HOME"`#g" ~/.config/kinto/prexk.sh + # sed -i "s#{homedir}#`echo "$HOME"`#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 + # sed -i "s/{displayid}/`echo "$DISPLAY"`/g" ~/.config/kinto/prexk.sh if $vssublime ; then perl -pi -e "s/(# )(.*)(- Sublime)/\$2\$3/g" ./xkeysnail-config/kinto.py.new >/dev/null 2>&1 @@ -333,12 +365,13 @@ if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1 sudo pip3 install --upgrade . cd .. 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 disable xkeysnail + # 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" @@ -381,6 +414,9 @@ if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1 if $rightalt ; then echo -e "\e[1m\e[32mEnabled\e[0m mutli-language support." fi + + trayApp + elif [[ $1 == "5" || $1 == "uninstall" || $1 == "Uninstall" ]]; then echo "Uninstalling Kinto - xkeysnail (udev)" uninstall @@ -397,7 +433,7 @@ elif [[ $1 == "5" || $1 == "uninstall" || $1 == "Uninstall" ]]; then sudo systemctl --state=not-found --all | grep xkeysnail budgieUninstall exit 0 -elif [[ $1 == "5" || $1 == "budgieUpdate" ]]; then +elif [[ $1 == "budgieUpdate" ]]; then budgieUpdate else echo "Expected argument was not provided"