Skip to content

Commit

Permalink
- Updated xkb configs to accept macOS word-wise text manipulations. C…
Browse files Browse the repository at this point in the history
…loses #2.
  • Loading branch information
rbreaves committed Aug 4, 2019
1 parent bd4cbe2 commit eb096d2
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 9 deletions.
26 changes: 26 additions & 0 deletions .xkb/symbols/mac_onelvl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
default partial xkb_symbols "mac_onelvlsym" {
// LEFT to Begin Line
replace key <LEFT> {
type[Group1]= "ONE_LEVEL_CTRL",
symbols[Group1]= [ Left, Left, NoSymbol ],
actions[Group1]= [ NoAction(), NoAction(), RedirectKey(key=<HOME>,clearmods=Control)]
};
// Right to End of Line
replace key <RGHT> {
type[Group1]= "ONE_LEVEL_CTRL",
symbols[Group1]= [ Right, Right, NoSymbol ],
actions[Group1]= [ NoAction(), NoAction(), RedirectKey(key=<END>,clearmods=Control)]
};
// Up to Mac Home
replace key <UP> {
type[Group1]= "ONE_LEVEL_CTRL",
symbols[Group1]= [ Up, NoSymbol ],
actions[Group1]= [ NoAction(), NoAction(), RedirectKey(key=<HOME>)]
};
// Done to Mac End
replace key <DOWN> {
type[Group1]= "ONE_LEVEL_CTRL",
symbols[Group1]= [ Down, NoSymbol ],
actions[Group1]= [ NoAction(), NoAction(), RedirectKey(key=<END>)]
};
};
11 changes: 11 additions & 0 deletions .xkb/types/mac_onelvl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
default partial xkb_types "addmac_onelvl" {
type "ONE_LEVEL_CTRL" {
modifiers= Shift+Control;
map[Shift]= Level2;
map[Control]= Level3;
map[Shift+Control]= Level3;
level_name[Level1]= "Base";
level_name[Level2]= "Caps";
level_name[Level3]= "With Control";
};
};
5 changes: 3 additions & 2 deletions install.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,12 @@ def keyboard_detect():
system_type = "mac"

if system_type == "windows" or system_type == "mac":
cmdgui = '"/usr/bin/setxkbmap -option;/usr/bin/setxkbmap -option altwin:ctrl_alt_win"'
subprocess.check_output('/bin/bash -c ./mac_wordwise.sh', shell=True).decode('utf-8')
cmdgui = '"/usr/bin/setxkbmap -option;xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.mac.onelvl $DISPLAY"'
# subprocess.check_output('echo "1" > /sys/module/hid_apple/parameters/swap_opt_cmd', shell=True).decode('utf-8')
elif system_type == "chromebook":
cmdgui = '"setxkbmap -option;xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.gui $DISPLAY"'
subprocess.check_output('/bin/bash -c ./chromebook.sh', shell=True).decode('utf-8')
cmdgui = '"setxkbmap -option;xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.chromebook.gui $DISPLAY"'

# password = getpass("Please enter your password to complete the keyswap: ")
# proc = Popen("echo '1' | sudo tee -a /sys/module/hid_apple/parameters/swap_opt_cmd".split(), stdin=PIPE, stdout=PIPE, stderr=PIPE)
Expand Down
8 changes: 8 additions & 0 deletions mac_wordwise.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
mkdir -p ~/.xkb/{keymap,symbols,types}
cp ./.xkb/symbols/mac_onelvl ~/.xkb/symbols/mac_onelvl
cp ./.xkb/types/mac_onelvl ~/.xkb/types/mac_onelvl
setxkbmap -option
setxkbmap -print > ~/.xkb/keymap/kbd.mac.onelvl
line=$(cat ~/.xkb/keymap/kbd.mac.onelvl | grep -n 'xkb_symbols' | cut -f1 -d:)
sed -ie "${line}s/)\"/)+altwin(ctrl_alt_win)+mac_onelvl(mac_onelvlsym)\"/g" ~/.xkb/keymap/kbd.mac.onelvl
14 changes: 7 additions & 7 deletions system-config/xactive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@ swapbehavior=$4
swapcmd_term="setxkbmap -option;setxkbmap -option altwin:swap_alt_win"
fallbackcmd_gui=""
if [[ "$systemtype" == "windows" || "$systemtype" == "mac" ]]; then
swapcmd_gui="setxkbmap -option;setxkbmap -option altwin:ctrl_alt_win"
check_gt="setxkbmap -query | grep -q 'ctrl_alt_win'"
check_tg="setxkbmap -query | grep -v 'ctrl_alt_win' 1>/dev/null"
swapcmd_gui="setxkbmap -option;xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.mac.onelvl $DISPLAY"
check_gt="setxkbmap -query | grep -v 'swap_alt_win' 1>/dev/null"
check_tg="setxkbmap -query | grep -q 'swap_alt_win'"
elif [[ "$swapbehavior" == "both_mac" ]]; then
swapcmd_gui="setxkbmap -option;setxkbmap -option ctrl:swap_lwin_lctl; xkbcomp -w0 -i $internalid -I$HOME/.xkb ~/.xkb/keymap/kbd.gui $DISPLAY"
swapcmd_gui="setxkbmap -option;setxkbmap -option ctrl:swap_lwin_lctl; xkbcomp -w0 -i $internalid -I$HOME/.xkb ~/.xkb/keymap/kbd.chromebook.gui $DISPLAY"
swapcmd_term="setxkbmap -option;setxkbmap -device $internalid -option 'altwin:swap_alt_win'"
check_gt="setxkbmap -query | grep -v 'swap_alt_win' 1>/dev/null"
check_tg="setxkbmap -query | grep -q 'swap_alt_win'"
elif [[ "$swapbehavior" == "both_win" ]]; then
swapcmd_gui="setxkbmap -option;xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.gui $DISPLAY; setxkbmap -device $usbid -option altwin:ctrl_alt_win"
fallbackcmd_gui="setxkbmap -option;xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.gui $DISPLAY"
swapcmd_gui="setxkbmap -option;xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.chromebook.gui $DISPLAY; setxkbmap -device $usbid -option altwin:ctrl_alt_win"
fallbackcmd_gui="setxkbmap -option;xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.chromebook.gui $DISPLAY"
check_gt="setxkbmap -query | grep -q 'ctrl_alt_win'"
check_tg="setxkbmap -query | grep -v 'ctrl_alt_win' 1>/dev/null"
elif [[ "$swapbehavior" == "none" ]]; then
swapcmd_gui="setxkbmap -option;xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.gui $DISPLAY"
swapcmd_gui="setxkbmap -option;xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.chromebook.gui $DISPLAY"
check_gt="setxkbmap -query | grep -v 'swap_alt_win' 1>/dev/null"
check_tg="setxkbmap -query | grep -q 'swap_alt_win'"
fi
Expand Down

0 comments on commit eb096d2

Please sign in to comment.