Skip to content

Commit

Permalink
Merge pull request #174 from rbreaves/dev
Browse files Browse the repository at this point in the history
- Budgie patch for App Switching. Also fixes Ctrl-Tab regression.
  • Loading branch information
rbreaves authored May 15, 2020
2 parents ac34350 + 6298c6c commit 5320685
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 9 deletions.
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ def setShortcuts():
cmdline('perl -pi -e "s/(\w.*)(\/\/ Default cmdtab)/\/\/ \$1\$2/g" ~/.xkb/symbols/mac_term')
cmdline('perl -pi -e "s/(\/\/ )(.*)(\/\/ Elementary cmdtab)/\$2\$3/g" ~/.xkb/symbols/mac_gui')
cmdline('perl -pi -e "s/(\w.*)(\/\/ Default cmdtab)/\/\/ \$1\$2/g" ~/.xkb/symbols/mac_gui')
# elif distro == "budgie" and dename == "gnome":
# print("Apply budgie shortcuts here")
elif distro == "galliumos" and dename == "xfce":
print("Applying GalliumOS (xfce) shortcuts...")
cmdline('cp ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml ./xfce4-keyboard-shortcuts_`date +"%Y.%m.%d-%s"`.xml')
Expand Down Expand Up @@ -382,6 +384,7 @@ def kintoImpOne():
subprocess.check_call(shlex.split("./xkeysnail_service.sh"))
if os.path.isdir(homedir + "/.config/kinto") == True:
setShortcuts()
subprocess.check_call(shlex.split("./xkeysnail_service.sh budgieUpdate"))
exit()

if(kintotype == 3):
Expand Down
1 change: 1 addition & 0 deletions system-config/budgie-daemon_10.5.1.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3cd35e15350ca7dac0c3cbfce1c661f7 /usr/bin/budgie-daemon
1 change: 1 addition & 0 deletions system-config/budgie-desktop_10.5.1.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8660c2f8e0a9d3cff896254f6c0f9159 /usr/bin/budgie-desktop
2 changes: 1 addition & 1 deletion user_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"symbols":"",
"types":"",
"de":[],
"appnames":[ "Gnome-terminal","konsole","io.elementary.terminal","terminator","sakura","guake","tilda","xterm","eterm","kitty","alacritty","mate-terminal" ]
"appnames":[ "Gnome-terminal","konsole","io.elementary.terminal","terminator","sakura","guake","tilda","xterm","eterm","kitty","alacritty","mate-terminal","tilix" ]
},
{
"name": "firefox",
Expand Down
14 changes: 11 additions & 3 deletions xkeysnail-config/kinto.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
import re
from xkeysnail.transform import *

terminals = ["gnome-terminal","konsole","io.elementary.terminal","terminator","sakura","guake","tilda","xterm","eterm","kitty","alacritty","mate-terminal"]
terminals = ["gnome-terminal","konsole","io.elementary.terminal","terminator","sakura","guake","tilda","xterm","eterm","kitty","alacritty","mate-terminal","tilix"]
terminals = [term.casefold() for term in terminals]
termStr = "|".join(str(x) for x in terminals)

mscodes = ["code","vscodium"]
codeStr = "|".join(str(x) for x in mscodes)

# [Global modemap] Change modifier keys as in xmodmap
define_conditional_modmap(lambda wm_class: wm_class.casefold() not in terminals,{
# # Chromebook
Expand Down Expand Up @@ -97,7 +100,7 @@
# K(""): K(""), #
})

define_keymap(lambda wm_class: wm_class.casefold() not in ("code"),{
define_keymap(lambda wm_class: wm_class.casefold() not in mscodes,{
# Wordwise remaining - for Everything but VS Code
K("M-Left"): K("C-Left"), # Left of Word
K("M-Shift-Left"): K("C-Shift-Left"), # Select Left of Word
Expand All @@ -120,14 +123,19 @@
})

# Keybindings for VS Code
define_keymap(re.compile("code", re.IGNORECASE),{
define_keymap(re.compile(codeStr, re.IGNORECASE),{
# Wordwise remaining - for VS Code
# Alt-F19 hack fixes Alt menu activation
K("M-Left"): [K("M-F19"),K("C-Left")], # Left of Word
K("M-Right"): [K("M-F19"),K("C-Right")], # Right of Word
K("M-Shift-Left"): [K("M-F19"),K("C-Shift-Left")], # Select Left of Word
K("M-Shift-Right"): [K("M-F19"),K("C-Shift-Right")], # Select Right of Word

# K("C-PAGE_DOWN"): pass_through_key, # cancel next_view
# K("C-PAGE_UP"): pass_through_key, # cancel prev_view
K("C-M-Left"): K("C-PAGE_UP"), # next_view
K("C-M-Right"): K("C-PAGE_DOWN"), # prev_view

# VS Code Shortcuts
K("C-g"): pass_through_key, # cancel Go to Line...
K("Super-g"): K("C-g"), # Go to Line...
Expand Down
80 changes: 75 additions & 5 deletions xkeysnail_service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,69 @@ function uninstall {
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..."
bdmd5="$(md5sum /usr/bin/budgie-daemon | awk '{ print $1 }')"
oldbdmd5=$(md5sum ./budgie-daemon_10.5.1.bak | awk '{ print $1 }')
if [ "$bdmd5" != "$oldbdmd5" ]; then
echo -e "\nReplacing budgie-daemon with backup..."
sudo pkill budgie-daemon && sudo cp ./budgie-daemon_10.5.1.bak /usr/bin/budgie-daemon
else
echo -e "\nBudgie-daemon is already an original."
fi
fi
}

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
case $yn in
[Yy]* ) yn="y"; break;;
[Nn]* ) yn="n";break;;
* ) echo "Please answer yes or no.";;
esac
done
if [ "$yn" == "y" ]; then
budgieVersion="$(/usr/bin/budgie-desktop --version | awk '{ print $2; }' | head -n1)"
if [ "$budgieVersion" == "10.5.1" ]; then
if ! [ -f ./system-config/budgie-daemon_10.5.1 ]; then
wget https://github.com/rbreaves/budgie-desktop/raw/43d3b44243b0bcaee3262a79818024a651475b58/binaries/budgie-daemon_10.5.1 -O ./system-config/budgie-daemon_10.5.1
fi
bdmd5=$(md5sum /usr/bin/budgie-daemon | awk '{ print $1 }')
newbdmd5=$(md5sum ./system-config/budgie-daemon_10.5.1 | awk '{ print $1 }')
if [ "$bdmd5" != "$newbdmd5" ]; then
cp /usr/bin/budgie-daemon ./budgie-daemon_"$budgieVersion".bak
sudo pkill budgie-daemon && sudo cp ./system-config/budgie-daemon_10.5.1 /usr/bin/budgie-daemon
echo "Updated Budgie to use App Switching Patch"
else
echo "Budgie-daemon already patched, skipping replacement."
fi
else
echo "Your Budgie version was $budgieVersion and the patch is for 10.5.1."
while true; do
read -rep $'Would you like to replace it any ways? (y/n)\n(A backup will be made)\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
if ! [ -f ./system-config/budgie-daemon_10.5.1 ]; then
wget https://github.com/rbreaves/budgie-desktop/raw/43d3b44243b0bcaee3262a79818024a651475b58/binaries/budgie-daemon_10.5.1 -O ./system-config/budgie-daemon_10.5.1
fi
cp /usr/bin/budgie-daemon ./budgie-daemon_"$budgieVersion".bak
sudo pkill budgie-daemon && sudo cp ./system-config/budgie-daemon_10.5.1 /usr/bin/budgie-daemon
echo "Updated Budgie to use App Switching Patch"
fi
fi
fi
fi
}

if [ $# -eq 0 ]; then
echo "Install Kinto - xkeysnail (udev)"
echo " 1) Windows & Mac (HID driver)"
Expand Down Expand Up @@ -125,6 +188,7 @@ if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1
sudo ./system-config/unipkg.sh "xorg-xhost gcc"
fi
fi

# echo "Transferring files..."
mkdir -p ~/.config/kinto

Expand Down Expand Up @@ -189,17 +253,20 @@ if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1
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
git clone --depth 5 https://github.com/rbreaves/xkeysnail.git
git checkout 51c369084e0045a8410d227bab52411bf84fb65b
cd xkeysnail
giturl=$(git ls-remote --get-url)
if [ "$geturl" != "https://github.com/rbreaves/xkeysnail.git" ];then
cd ..
rm -rf ./xkeysnail
git clone --depth 1 https://github.com/rbreaves/xkeysnail.git
git clone --depth 5 https://github.com/rbreaves/xkeysnail.git
git checkout 51c369084e0045a8410d227bab52411bf84fb65b
cd xkeysnail
fi
git pull origin master
sudo pip3 install --upgrade .
cd ..
sudo systemctl daemon-reload
sudo systemctl --state=not-found --all | grep xkeysnail
if [ "$distro" == "fedora" ];then
Expand Down Expand Up @@ -242,9 +309,7 @@ if [[ $1 == "1" || $1 == "2" || $1 == "3" || $1 == "winmac" || $1 == "mac" || $1
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"
else
elif [[ $1 == "4" || $1 == "uninstall" || $1 == "Uninstall" ]]; then
echo "Uninstalling Kinto - xkeysnail (udev)"
uninstall
# Undo Apple keyboard cmd & alt swap
Expand All @@ -263,5 +328,10 @@ else
sudo rm /usr/lib/systemd/system/xkeysnail.service
sudo systemctl daemon-reload
sudo systemctl --state=not-found --all | grep xkeysnail
budgieUninstall
exit 0
elif [[ $1 == "5" || $1 == "budgieUpdate" ]]; then
budgieUpdate
else
echo "Expected argument was not provided"
fi

0 comments on commit 5320685

Please sign in to comment.