- Relocated files not relevant to install under references, deleted others

This commit is contained in:
Ben Reaves
2020-05-03 22:39:07 -05:00
parent 3de9a1dd9d
commit a48246d3e3
18 changed files with 440 additions and 3 deletions

View File

@@ -0,0 +1,16 @@
#!/bin/bash
mkdir -p ~/.xkb/{keymap,symbols,types}
cp ./.xkb/symbols/chromebook ~/.xkb/symbols/chromebook
cp ./.xkb/symbols/mac_gui ~/.xkb/symbols/mac_gui
cp ./.xkb/types/mac_gui ~/.xkb/types/mac_gui
setxkbmap -option
setxkbmap -print > ~/.xkb/keymap/kbd.chromebook.gui
setxkbmap -print > ~/.xkb/keymap/kbd.chromebook.term
line=$(cat ~/.xkb/keymap/kbd.chromebook.gui | grep -n 'xkb_symbols' | cut -f1 -d:)
sed -ie "${line}s/\"/+chromebook(swap_lalt_lctrl)+mac_gui(mac_levelssym)\"/2" ~/.xkb/keymap/kbd.chromebook.gui
sleep 1
line=$(cat ~/.xkb/keymap/kbd.chromebook.gui | grep -n 'xkb_types' | cut -f1 -d:)
sed -ie "${line}s/\"/+mac_gui(addmac_levels)\"/2" ~/.xkb/keymap/kbd.chromebook.gui
sleep 1
line=$(cat ~/.xkb/keymap/kbd.chromebook.term | grep -n 'xkb_symbols' | cut -f1 -d:)
sed -ie "${line}s/\"/+altwin(swap_alt_win)+mac_term(mac_levelssym)\"/2" ~/.xkb/keymap/kbd.chromebook.term

176
references/old-files/install.py Executable file
View File

@@ -0,0 +1,176 @@
#!/usr/bin/env python3
import os, platform, sysconfig, sys, subprocess, time
yellow = "\033[1;33m"
green = "\033[0;32m"
red = "\033[1;31m"
italic = "\033[3m"
reset = "\033[0;0m"
platform_name = platform.system()
# print sysconfig.get_platform()
sys.stdout.write(yellow)
cloud = '\u2601'
circleo = '\u25CE'
clocko = '\u2B6E'
syme = '\u0250'
syma = '\u0251'
# bang = '\u1F589'.decode('unicode-escape')
internalid = 0
usbid = 0
def keyboard_detect():
global internalid, usbid, chromeswap, system_type
internal_kbname = ""
usb_kbname = ""
# If chromebook
if system_type == "2":
print()
print("Looking for keyboards...")
print()
result = subprocess.check_output('xinput list | grep -iv "Virtual\|USB" | grep -i "keyboard.*keyboard" | grep -o -P "(?<=↳).*(?=id\=)";exit 0', shell=True).decode('utf-8')
if result != "":
internal_kbname = result.strip()
internalid = subprocess.check_output('xinput list | grep -iv "Virtual\|USB" | grep -i "keyboard.*keyboard" | cut -d "=" -f 2- | awk \'{print $1}\' | tail -1;exit 0', shell=True).decode('utf-8')
print("Internal Keyboard\nName: " + internal_kbname + "\nID: " + internalid)
result = subprocess.check_output('udevadm info -e | grep -o -P "(?<=by-id/usb-).*(?=-event-kbd)" | head -1;exit 0', shell=True).decode('utf-8')
if result != "":
usb_kbname = result.strip()
# Loop the following to ensure the id is picked up after 5-10 tries
usbid = ""
usbcount=0
while usbid == "":
usbid = subprocess.check_output('udevadm info -e | stdbuf -oL grep -o -P "(?<=event-kbd /dev/input/by-path/pci-0000:00:).*(?=.0-usb) | head -n 1";exit 0', shell=True).decode('utf-8')
if usbid == "":
usbcount += 1
# print('usbid not found '+ str(usbcount))
if usbcount == 5:
usbid = "0"
time.sleep(1)
print("\nUSB Keyboard\n" + "Name: " + usb_kbname + "\nID: " + usbid)
if system_type == "1":
system_type = "windows"
elif system_type == "2":
system_type = "chromebook"
elif system_type == "3":
result = subprocess.check_output('lsmod | grep hid_apple 1>/dev/null; echo $?', shell=True).decode('utf-8')
if result.strip() == "0":
system_type = "mac"
else:
system_type = "mac_only"
print("Apple hid_apple driver is not loaded, a keymap that is specific for only Apple keyboards will be used.")
if system_type == "windows" or system_type == "mac":
subprocess.check_output('/bin/bash -c ./mac_wordwise.sh', shell=True).decode('utf-8')
cmdgui = '"setxkbmap -option;xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.mac.gui $DISPLAY"'
elif system_type == "mac_only":
subprocess.check_output('/bin/bash -c ./mac_only.sh', shell=True).decode('utf-8')
cmdgui = '"setxkbmap -option;xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.mac.gui $DISPLAY"'
elif system_type == "chromebook":
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)
# proc.communicate(password.encode())
if swap_behavior == 1:
print("Setting up " + system_type + " keyswap as a service.")
print("You can disable and remove the service by using the following command in the Kinto directory.")
print("./uninstall.sh")
keyswapcmd = '/bin/bash -c "./keyswap_service.sh 1 0 ' + system_type + ' ' + str(internalid).strip() + ' ' + str(usbid).strip() + ' ' + str(chromeswap) + '"'
# print(keyswapcmd)
subprocess.check_output(keyswapcmd, shell=True).decode('utf-8')
else:
print("Setting up " + system_type + " keyswap inside your profiles ~/.Xsession file.")
print("You can modify or remove the file if you want you want to remove the modification.")
keyswapcmd = '/bin/bash -c \'./keyswap_service.sh 0 ' + cmdgui + '\''
subprocess.check_output(keyswapcmd, shell=True).decode('utf-8')
if system_type == "mac":
print()
print("An Apple keyboard with the hid_apple driver was detected.")
print("Please run the following commands to swap alt/option and Command.")
print("Your Kinto keymapping will not work right on Apple keyboards without it.")
print()
print("echo '1' | sudo tee -a /sys/module/hid_apple/parameters/swap_opt_cmd")
print('echo "options hid_apple swap_opt_cmd=1" | sudo tee -a /etc/modprobe.d/hid_apple.conf')
print('sudo update-initramfs -u -k all')
def os_detect():
print()
print("Checking for OS and system information...")
print()
print("OS Type")
# print(" Platform: " + platform_name)
if platform_name == 'Linux':
result = subprocess.check_output("lsb_release -a | grep -v LSB ", shell=True).decode('ascii')
print(result)
def hwinfo():
print("Requires user password to display hardware information...")
result = subprocess.check_output('sudo dmidecode | grep -A 9 "System Information" | grep -v "UUID\|Serial\|SKU\|Wake"', shell=True).decode('ascii')
print(result)
def kblist():
result = subprocess.check_output('xinput list', shell=True).decode('ascii')
print(result)
print()
print()
print(" Kint" + circleo)
sys.stdout.write(reset)
print(italic + " - F!x the d" + syma + "mn k" + syme + "yb" + circleo + syma + "rd. - ")
sys.stdout.write(reset)
print()
input("Press Enter to begin...")
system_type = input("\nWhat type of keyboard are you using? (If Mac and Windows then select Mac)\n\
1) Windows\n\
2) Chromebook\n\
3) Mac\n")
swap_behavior = 1
chromeswap = 0
# Chromebook
if system_type == "2":
if not input("\nWould you like to swap Alt to Super/Win and Search key to Ctrl when using terminal applications? (y/n)\n\
Note: For a more mac like experience & less issues with terminal based interactions y is recommended.\n").lower().strip()[:1] == "y":
swap_behavior = 0
# Windows
if system_type == "1":
if not input("\nWould you like to swap Alt to Super/Win and Ctrl key back to Ctrl when using terminal applications? (y/n)\n\
Note: For a more mac like experience & less issues with terminal based interactions y is recommended.\n").lower().strip()[:1] == "y":
swap_behavior = 0
# Mac
if system_type == "3":
if not input("\nWould you like to swap Command back to Super/Win and Ctrl key back to Ctrl when using terminal applications? (y/n)\n\
Note: For a more mac like experience & less issues with terminal based interactions y is recommended.\n").lower().strip()[:1] == "y":
swap_behavior = 0
if int(system_type) == 2 and swap_behavior == 1:
chromeswap = input("\nIf the keyswap is applied on a chromebook with both an internal and external Apple keyboard\n\
you may need to press a key on the external Apple keyboard any time you switch between the terminal and gui based apps.\n\
Are you ok with that, or would you like to only apply the keyswap on one keyboard type?\n\
1) Built-in\n\
2) Both - (Chromebook & Windows)\n\
3) Both - (Chromebook & Mac)\n\
4) USB External - (Mac)\n")
if chromeswap == "1":
chromeswap = "none"
elif chromeswap == "2":
chromeswap = "both_win"
elif chromeswap == "3" or chromeswap == "4":
chromeswap = "both_mac"
keyboard_detect()

View File

@@ -0,0 +1,15 @@
#!/bin/bash
mkdir -p ~/.xkb/{keymap,symbols,types}
cp ./.xkb/symbols/mac_gui ~/.xkb/symbols/mac_gui
cp ./.xkb/types/mac_gui ~/.xkb/types/mac_gui
setxkbmap -option
setxkbmap -print > ~/.xkb/keymap/kbd.mac.gui
setxkbmap -print > ~/.xkb/keymap/kbd.mac.term
line=$(cat ~/.xkb/keymap/kbd.mac.gui | grep -n 'xkb_symbols' | cut -f1 -d:)
sed -ie "${line}s/\"/+ctrl(swap_lwin_lctl)+ctrl(swap_rwin_rctl)+mac_gui(mac_levelssym)\"/2" ~/.xkb/keymap/kbd.mac.gui
sleep 1
line=$(cat ~/.xkb/keymap/kbd.mac.gui | grep -n 'xkb_types' | cut -f1 -d:)
sed -ie "${line}s/\"/+mac_gui(addmac_levels)\"/2" ~/.xkb/keymap/kbd.mac.gui
sleep 1
line=$(cat ~/.xkb/keymap/kbd.mac.term | grep -n 'xkb_symbols' | cut -f1 -d:)
sed -ie "${line}s/\"/+altwin(alt_super_win)+mac_term(mac_levelssym)\"/2" ~/.xkb/keymap/kbd.mac.term

View File

@@ -0,0 +1,15 @@
#!/bin/bash
mkdir -p ~/.xkb/{keymap,symbols,types}
cp ./.xkb/symbols/mac_gui ~/.xkb/symbols/mac_gui
cp ./.xkb/types/mac_gui ~/.xkb/types/mac_gui
setxkbmap -option
setxkbmap -print > ~/.xkb/keymap/kbd.mac.gui
setxkbmap -print > ~/.xkb/keymap/kbd.mac.term
line=$(cat ~/.xkb/keymap/kbd.mac.gui | grep -n 'xkb_symbols' | cut -f1 -d:)
sed -ie "${line}s/\"/+altwin(ctrl_alt_win)+mac_gui(mac_levelssym)\"/2" ~/.xkb/keymap/kbd.mac.gui
sleep 1
line=$(cat ~/.xkb/keymap/kbd.mac.gui | grep -n 'xkb_types' | cut -f1 -d:)
sed -ie "${line}s/\"/+mac_gui(addmac_levels)\"/2" ~/.xkb/keymap/kbd.mac.gui
sleep 1
line=$(cat ~/.xkb/keymap/kbd.mac.term | grep -n 'xkb_symbols' | cut -f1 -d:)
sed -ie "${line}s/\"/+altwin(swap_alt_win)+mac_term(mac_levelssym)\"/2" ~/.xkb/keymap/kbd.mac.term

View File

@@ -0,0 +1,9 @@
#!/bin/bash
systemctl --user stop keyswap
systemctl --user disable keyswap
rm -rf ~/.config/autostart/keyswap.sh
rm -rf ~/.config/xactive.sh
rm -rf ~/.xkb
sed -i '/xkb/d' ~/.Xsession

316
references/old-files/test.py Executable file
View File

@@ -0,0 +1,316 @@
# pip3 install pynput
# pip3 install --no-deps pynput
from pynput.keyboard import Key, Listener
import sys, subprocess
uitype=sys.argv[1]
apply_rules=sys.argv[2]
windows=sys.argv[3]
chromebook=sys.argv[4]
mac=sys.argv[5]
class color:
PURPLE = '\033[95m'
CYAN = '\033[96m'
DARKCYAN = '\033[36m'
BLUE = '\033[94m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
RED = '\033[91m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
END = '\033[0m'
def on_press(key):
print('{0} pressed'.format(key))
def on_release(key):
# print('{0} release'.format(key))
if key == Key.esc:
# Stop listener
return False
def is_ctrl_winchrome(key):
if key == Key.ctrl:
# print(str(key).replace("Key.", "").title() +' successfully mapped to physical Alt key.'.format(key))
print(color.GREEN + 'Success' + color.END + ' Alt is now Ctrl')
return False
elif key == Key.esc:
return False
else:
print('keymap failure, ' + str(key).replace("Key.", "").title() + ' may have been mapped to the physical Alt key.'.format(key))
return False
def is_ctrl_mac(key):
if key == Key.ctrl:
# print(str(key).replace("Key.", "").title() +' successfully mapped to physical Alt key.'.format(key))
print(color.GREEN + 'Success' + color.END + ' Command is now Ctrl')
return False
elif key == Key.esc:
return False
else:
print('keymap failure, ' + str(key).replace("Key.", "").title() + ' may have been mapped to the physical Command key.'.format(key))
return False
def is_ctrl_terminal(key):
if key == Key.ctrl:
# print(str(key).replace("Key.", "").title() +' successfully mapped to physical Ctrl key.'.format(key))
print(color.GREEN + 'Success' + color.END + ' Ctrl remains Ctrl,\nwhile in terminal apps.')
return False
elif key == Key.esc:
return False
else:
print('keymap failure, ' + str(key).replace("Key.", "").title() + ' may have been mapped to the physical Ctrl key.'.format(key))
return False
def is_alt_chromebook(key):
if key == Key.alt:
# print(str(key).replace("Key.", "").title() +' successfully mapped to the physical Ctrl key.'.format(key))
print(color.GREEN + 'Success' + color.END + ' Ctrl is now Alt')
return False
elif key == Key.esc:
return False
else:
print('keymap failure, ' + str(key).replace("Key.", "").title() + ' may have been mapped to the physical Ctrl key.'.format(key))
return False
def is_alt_windows(key):
if key == Key.alt:
# print(str(key).replace("Key.", "").title() +' successfully mapped to the physical Ctrl key.'.format(key))
print(color.GREEN + 'Success' + color.END + ' Win/Super is now Alt')
return False
elif key == Key.esc:
return False
else:
print('keymap failure, ' + str(key).replace("Key.", "").title() + ' may have been mapped to the physical Win/Super key.'.format(key))
return False
def is_alt_mac(key):
if key == Key.alt:
# print(str(key).replace("Key.", "").title() +' successfully mapped to the physical Ctrl key.'.format(key))
print(color.GREEN + 'Success' + color.END + ' Alt remains Alt')
return False
elif key == Key.esc:
return False
else:
print('keymap failure, ' + str(key).replace("Key.", "").title() + ' may have been mapped to the physical Alt key.'.format(key))
return False
def is_alt_chromebook_terminal(key):
if key == Key.alt:
# print(str(key).replace("Key.", "").title() +' successfully mapped to the physical Search key.'.format(key))
print(color.GREEN + 'Success' + color.END + ' Search is now Alt,\nwhile in terminals apps.')
return False
elif key == Key.esc:
return False
else:
print('keymap failure, ' + str(key).replace("Key.", "").title() + ' may have been mapped to the physical Search key.'.format(key))
return False
def is_super_winmac(key):
if key == Key.cmd:
# print('Super/Win successfully mapped to the physical Search key.'.format(key))
print(color.GREEN + 'Success' + color.END + ' Ctrl key is Super/Win')
return False
elif key == Key.esc:
return False
else:
print('keymap failure, ' + str(key).replace("Key.", "").title() + ' may have been mapped to the physical Ctrl key.'.format(key))
return False
def is_super_chromebook(key):
if key == Key.cmd:
# print('Super/Win successfully mapped to the physical Search key.'.format(key))
print(color.GREEN + 'Success' + color.END + ' Search key is Super/Win')
return False
elif key == Key.esc:
return False
else:
print('keymap failure, ' + str(key).replace("Key.", "").title() + ' may have been mapped to the physical Search key.'.format(key))
return False
def is_super_terminal(key):
if key == Key.cmd:
# print('Super/Win successfully mapped to the physical Alt key.'.format(key))
print(color.GREEN + 'Success' + color.END + ' Alt is now Super/Win,\nwhile in terminal apps.')
return False
elif key == Key.esc:
return False
else:
print('keymap failure, ' + str(key).replace("Key.", "").title() + ' may have been mapped to the physical Alt key.'.format(key))
return False
def is_super_mac_terminal(key):
if key == Key.cmd:
# print('Super/Win successfully mapped to the physical Alt key.'.format(key))
print(color.GREEN + 'Success' + color.END + ' Command is now Super/Win,\nwhile in terminal apps.')
return False
elif key == Key.esc:
return False
else:
print('keymap failure, ' + str(key).replace("Key.", "").title() + ' may have been mapped to the physical Command key.'.format(key))
return False
def chromebook_keys_gui():
print()
print(color.UNDERLINE + color.YELLOW + "Press the physical Alt" + color.END + " key to confirm the new keymapping to Ctrl..")
with Listener(
# on_press=on_press,
on_release=is_ctrl_winchrome) as listener:
listener.join()
print()
print(color.UNDERLINE + color.YELLOW + "Press the physical Ctrl" + color.END + " key to confirm the new keymapping to Alt..")
with Listener(
# on_press=on_press,
on_release=is_alt_chromebook) as listener:
listener.join()
print()
print(color.UNDERLINE + color.YELLOW + "Press the physical Search" + color.END + " key to confirm the new keymapping to Super/Win..")
with Listener(
# on_press=on_press,
on_release=is_super_chromebook) as listener:
listener.join()
def chromebook_keys_terminal():
print()
print(color.UNDERLINE + color.YELLOW + "Press the physical Alt" + color.END + " key to confirm the new keymapping to Super/Win..")
with Listener(
# on_press=on_press,
on_release=is_super_terminal) as listener:
listener.join()
print()
print(color.UNDERLINE + color.YELLOW + "Press the physical Ctrl" + color.END + " key to confirm the new keymapping to Ctrl..")
with Listener(
# on_press=on_press,
on_release=is_ctrl_terminal) as listener:
listener.join()
print()
print(color.UNDERLINE + color.YELLOW + "Press the physical Search" + color.END + " key to confirm the new keymapping to Alt..")
with Listener(
# on_press=on_press,
on_release=is_alt_chromebook_terminal) as listener:
listener.join()
def windows_keys_gui():
print()
print(color.UNDERLINE + color.YELLOW + "Press the physical Alt" + color.END + " key to confirm the new keymapping to Ctrl..")
with Listener(
# on_press=on_press,
on_release=is_ctrl_winchrome) as listener:
listener.join()
print()
print(color.UNDERLINE + color.YELLOW + "Press the physical Win/Super" + color.END + " key to confirm the new keymapping to Alt..")
with Listener(
# on_press=on_press,
on_release=is_alt_windows) as listener:
listener.join()
print()
print(color.UNDERLINE + color.YELLOW + "Press the physical Ctrl" + color.END + " key to confirm the new keymapping to Win/Super..")
with Listener(
# on_press=on_press,
on_release=is_super_winmac) as listener:
listener.join()
def windows_keys_terminal():
print()
print(color.UNDERLINE + color.YELLOW + "Press the physical Alt" + color.END + " key to confirm the new keymapping to Super/Win..")
with Listener(
# on_press=on_press,
on_release=is_super_terminal) as listener:
listener.join()
print()
print(color.UNDERLINE + color.YELLOW + "Press the physical Win/Super" + color.END + " key to confirm the new keymapping to Alt..")
with Listener(
# on_press=on_press,
on_release=is_alt_windows) as listener:
listener.join()
print()
print(color.UNDERLINE + color.YELLOW + "Press the physical Ctrl" + color.END + " key to confirm the new keymapping to Ctrl..")
with Listener(
# on_press=on_press,
on_release=is_ctrl_terminal) as listener:
listener.join()
def mac_keys_gui():
print()
print(color.UNDERLINE + color.YELLOW + "Press the physical Command" + color.END + " key to confirm the new keymapping to Ctrl..")
with Listener(
# on_press=on_press,
on_release=is_ctrl_mac) as listener:
listener.join()
print()
print(color.UNDERLINE + color.YELLOW + "Press the physical Alt" + color.END + " key to confirm it remains Alt..")
with Listener(
# on_press=on_press,
on_release=is_alt_mac) as listener:
listener.join()
print()
print(color.UNDERLINE + color.YELLOW + "Press the physical Ctrl" + color.END + " key to confirm the new keymapping to Win/Super..")
with Listener(
# on_press=on_press,
on_release=is_super_winmac) as listener:
listener.join()
def mac_keys_terminal():
print()
print(color.UNDERLINE + color.YELLOW + "Press the physical Command" + color.END + " key to confirm the new keymapping to Super/Win..")
with Listener(
# on_press=on_press,
on_release=is_super_mac_terminal) as listener:
listener.join()
print()
print(color.UNDERLINE + color.YELLOW + "Press the physical Alt" + color.END + " key to confirm it remains Alt..")
with Listener(
# on_press=on_press,
on_release=is_alt_mac) as listener:
listener.join()
print()
print(color.UNDERLINE + color.YELLOW + "Press the physical Ctrl" + color.END + " key to confirm it remains Ctrl..")
with Listener(
# on_press=on_press,
on_release=is_ctrl_terminal) as listener:
listener.join()
if uitype == 'gui':
if chromebook == '1':
if apply_rules == '1':
subprocess.check_output('setxkbmap -option;xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.chromebook.gui $DISPLAY', shell=True).decode('utf-8')
print()
print("Testing chromebook - GUI apps - Kinto keymapping...")
chromebook_keys_gui()
if windows == '1':
if apply_rules == '1':
subprocess.check_output('setxkbmap -option;xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.mac.gui $DISPLAY', shell=True).decode('utf-8')
print()
print ("Testing windows keyboard - GUI apps - Kinto keymapping...")
windows_keys_gui()
if mac == '1':
if apply_rules == '1':
subprocess.check_output('setxkbmap -option;xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.mac.gui $DISPLAY', shell=True).decode('utf-8')
print ("Testing mac keyboard - GUI apps - Kinto keymapping...")
mac_keys_gui()
if uitype == 'term':
if chromebook == '1':
if apply_rules == '1':
subprocess.check_output('setxkbmap -option;setxkbmap -option altwin:swap_lalt_lwin', shell=True).decode('utf-8')
print("Testing chromebook - terminal - Kinto keymapping...")
chromebook_keys_terminal()
if windows == '1':
if apply_rules == '1':
subprocess.check_output('setxkbmap -option;setxkbmap -option altwin:swap_alt_win', shell=True).decode('utf-8')
print ("Testing windows keyboard - terminal - Kinto keymapping...")
windows_keys_terminal()
if mac == '1':
if apply_rules == '1':
subprocess.check_output('setxkbmap -option;setxkbmap -option altwin:swap_alt_win', shell=True).decode('utf-8')
print ("Testing mac keyboard - terminal - Kinto keymapping...")
mac_keys_terminal()
if apply_rules == '1':
subprocess.run('setxkbmap -option', shell=True)