- Updated all setup files for kintox11

This commit is contained in:
Ben Reaves
2020-02-02 21:27:38 -06:00
parent 4c95a9d2eb
commit 536e528196
8 changed files with 161 additions and 119 deletions

View File

@@ -1,4 +1,9 @@
{"defaults":[{ {"defaultapps":[{
"name":"term",
"appnames":[ "Gnome-terminal","konsole","io.elementary.terminal","terminator","sakura","guake","tilda","xterm","eterm" ]
}],
"defaulttypes":["windows","mac","chromebook"],
"defaults":[{
"id": 1, "id": 1,
"name":"Windows", "name":"Windows",
"type":"windows", "type":"windows",

View File

@@ -5,7 +5,7 @@ mkdir -p ~/.config/systemd/user
mkdir -p ~/.config/autostart mkdir -p ~/.config/autostart
cp ./system-config/keyswap.service ~/.config/systemd/user/keyswap.service cp ./system-config/keyswap.service ~/.config/systemd/user/keyswap.service
cp ./system-config/keyswap.sh ~/.config/autostart/keyswap.sh cp ./system-config/keyswap.sh ~/.config/autostart/keyswap.sh
cp ./kintox11/binary/kintox11_ubuntu19-10 ~/.config/kinto/kintox11 cp ./kintox11/binary/kintox11 ~/.config/kinto/kintox11
sed -i "s/{username}/`whoami`/g" ~/.config/systemd/user/keyswap.service sed -i "s/{username}/`whoami`/g" ~/.config/systemd/user/keyswap.service
sed -i "s/ExecStart=/ExecStart=${swapcmd}/g" ~/.config/systemd/user/keyswap.service sed -i "s/ExecStart=/ExecStart=${swapcmd}/g" ~/.config/systemd/user/keyswap.service
systemctl --user enable keyswap systemctl --user enable keyswap

View File

@@ -120,7 +120,8 @@ int main(void){
struct json_object *parsed_json, *config, *config_obj, struct json_object *parsed_json, *config, *config_obj,
*config_obj_name, *config_obj_run, *config_obj_de, *config_obj_name, *config_obj_run, *config_obj_de,
*config_obj_appnames, *appnames_obj, *init, *de, *config_obj_appnames, *appnames_obj, *init, *de,
*de_obj, *de_obj_id, *de_obj_active, *de_obj_run; *de_obj, *de_obj_id, *de_obj_active, *de_obj_run,
*de_obj_runterm,*de_obj_rungui;
int arraylen; int arraylen;
int appnames_len, init_len, de_len, config_de_len; int appnames_len, init_len, de_len, config_de_len;
@@ -149,6 +150,8 @@ int main(void){
int de_id_array[de_len]; int de_id_array[de_len];
Bool de_active_array[de_len]; Bool de_active_array[de_len];
const char *de_run_array[de_len]; const char *de_run_array[de_len];
const char *de_runterm_array[de_len];
const char *de_rungui_array[de_len];
// Grab all de variable info needed // Grab all de variable info needed
for (i = 0; i < de_len; i++) { for (i = 0; i < de_len; i++) {
@@ -159,6 +162,10 @@ int main(void){
de_active_array[i] = json_object_get_int(de_obj_active); de_active_array[i] = json_object_get_int(de_obj_active);
de_obj_run = json_object_object_get(de_obj, "run"); de_obj_run = json_object_object_get(de_obj, "run");
de_run_array[i] = json_object_get_string(de_obj_run); de_run_array[i] = json_object_get_string(de_obj_run);
de_obj_runterm = json_object_object_get(de_obj, "run_term");
de_runterm_array[i] = json_object_get_string(de_obj_runterm);
de_obj_rungui = json_object_object_get(de_obj, "run_gui");
de_rungui_array[i] = json_object_get_string(de_obj_rungui);
// printf("de_run_array[%ld]: %s\n",i,de_run_array[i]); // printf("de_run_array[%ld]: %s\n",i,de_run_array[i]);
} }
// de ends // de ends
@@ -278,7 +285,7 @@ int main(void){
if(config_de_array[i][r] != -1){ if(config_de_array[i][r] != -1){
int de_id_idx = in_int(de_id_array, de_len, config_de_array[i][r]); int de_id_idx = in_int(de_id_array, de_len, config_de_array[i][r]);
// printf("Running de command: %s\n",de_run_array[de_id_idx]); // printf("Running de command: %s\n",de_run_array[de_id_idx]);
system(de_run_array[de_id_idx]); system(de_runterm_array[de_id_idx]);
} }
} }
remap_bool = 0; remap_bool = 0;
@@ -304,7 +311,7 @@ int main(void){
if(config_de_array[gui_idx][r] != -1){ if(config_de_array[gui_idx][r] != -1){
int de_id_idx = in_int(de_id_array, de_len, config_de_array[gui_idx][r]); int de_id_idx = in_int(de_id_array, de_len, config_de_array[gui_idx][r]);
// printf("Running de command: %s\n",de_run_array[de_id_idx]); // printf("Running de command: %s\n",de_run_array[de_id_idx]);
system(de_run_array[de_id_idx]); system(de_rungui_array[de_id_idx]);
} }
} }
// printf("3rd elseif %s i:%ld n:%ld %s\n",name_array[i],i,n,appnames_array[i][n]); // printf("3rd elseif %s i:%ld n:%ld %s\n",name_array[i],i,n,appnames_array[i][n]);

View File

@@ -50,23 +50,6 @@ class bcolors:
CBEIGEBG2 = '\033[106m' CBEIGEBG2 = '\033[106m'
CWHITEBG2 = '\033[107m' CWHITEBG2 = '\033[107m'
def cmdline(command):
process = Popen(
args=command,
stdout=PIPE,
shell=True
)
return process.communicate()[0]
def copytree(src, dst, symlinks=False, ignore=None):
for item in os.listdir(src):
s = os.path.join(src, item)
d = os.path.join(dst, item)
if os.path.isdir(s):
shutil.copytree(s, d, symlinks, ignore)
else:
shutil.copy2(s, d)
def yn_choice(message, default='y'): def yn_choice(message, default='y'):
choices = 'Y/n' if default.lower() in ('y', 'yes') else 'y/N' choices = 'Y/n' if default.lower() in ('y', 'yes') else 'y/N'
choice = input("%s (%s) " % (message, choices)) choice = input("%s (%s) " % (message, choices))

144
setup.py Normal file → Executable file
View File

@@ -1,40 +1,61 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import json, time, os
import json
import os
from subprocess import PIPE, Popen
from shutil import copyfile from shutil import copyfile
from subprocess import PIPE, Popen
from prekinto import * from prekinto import *
print("\nKinto - Type in Linux like it's a Mac.\n") homedir = os.path.expanduser("~")
def cmdline(command):
process = Popen(
args=command,
stdout=PIPE,
universal_newlines=True,
shell=True
)
return process.communicate()[0]
try: try:
f = open("default.json") f = open("defaults.json")
except IOError: except IOError:
print("default.json file is missing. Will exit.\n") print("defaults.json file is missing. Will exit.\n")
exit() exit()
f.close() f.close()
try: try:
f = open("kinto.json") f = open("user_config.json")
rewrite = yn_choice("kinto.json already exists. Do you want to overwrite it with a new config?") except IOError:
print("user_config.json file is missing. Will exit.\n")
exit()
f.close()
if os.path.isdir(homedir + "/.config/kinto") == False:
os.mkdir(homedir + "/.config/kinto")
time.sleep(0.5)
try:
f = open(homedir + "/.config/kinto/user_config.json")
rewrite = yn_choice("~/.config/kinto/user_config.json already exists. Do you want to overwrite it with a new config?")
print("") print("")
if(rewrite): if(rewrite):
copyfile("default.json", "kinto.json") copyfile("user_config.json", homedir + "/.config/kinto/user_config.json")
else: else:
exit() exit()
except IOError: except IOError:
pass pass
copyfile("default.json", "kinto.json") copyfile("user_config.json", homedir + "/.config/kinto/user_config.json")
finally: finally:
f.close() f.close()
with open('kinto.json') as json_file: with open('defaults.json') as json_file:
data = json.load(json_file) data = json.load(json_file)
color_arr = [bcolors.CBLUE,bcolors.CRED,bcolors.CGREEN]
print("\nKinto - Type in Linux like it's a Mac.\n")
for index, item in enumerate(data['defaulttypes']): for index, item in enumerate(data['defaulttypes']):
ossym = "" ossym = ""
color_arr = [bcolors.CBLUE,bcolors.CRED,bcolors.CGREEN]
if item == "windows": if item == "windows":
ossym = u'\u2756' ossym = u'\u2756'
elif item == "mac": elif item == "mac":
@@ -45,20 +66,16 @@ with open('kinto.json') as json_file:
default = 0 default = 0
while not int(default) in range(1,len(data['defaulttypes'])+1): while not int(default) in range(1,len(data['defaulttypes'])+1):
default = int(input(bcolors.CYELLOW + "Please enter your keyboard type (1 - " + str(len(data['defaulttypes'])) + ") : " + bcolors.ENDC)) default = int(input(bcolors.CYELLOW + "\nPlease enter your keyboard type (1 - " + str(len(data['defaulttypes'])) + ") : " + bcolors.ENDC))
print("") print("")
# print(data['defaulttypes'][default-1])
keyboardconfigs = [obj for obj in data['defaults'] if(obj['type'] == data['defaulttypes'][default-1])] keyboardconfigs = [obj for obj in data['defaults'] if(obj['type'] == data['defaulttypes'][default-1])]
# print(len(keyboardconfigs))
# for k in keyboardconfigs: # for k in keyboardconfigs:
for index, k in enumerate(keyboardconfigs): for index, k in enumerate(keyboardconfigs):
print(color_arr[default-1] + bcolors.BOLD + str(index+1) + '. ' + k['name'] + bcolors.ENDC) print(color_arr[default-1] + bcolors.BOLD + str(index+1) + '. ' + k['name'] + bcolors.ENDC)
print(bcolors.CYELLOW + 'Description: ' + k['description'] + bcolors.ENDC) print(bcolors.CYELLOW + 'Description: ' + k['description'] + bcolors.ENDC)
# print(keyboardconfigs[0]['id'])
# print(keyboardconfigs[len(keyboardconfigs)-1]['id'])
print("") print("")
defaultkb = 0 defaultkb = 0
while not int(defaultkb) in range(1,len(keyboardconfigs)+1): while not int(defaultkb) in range(1,len(keyboardconfigs)+1):
@@ -70,46 +87,79 @@ with open('kinto.json') as json_file:
print(keyboardconfigs[defaultkb-1]['hack'].replace(";", "\n") + "\n") print(keyboardconfigs[defaultkb-1]['hack'].replace(";", "\n") + "\n")
runhack = yn_choice(bcolors.CYELLOW + "Would you like to run it now? (Will require sudo privileges. Will exit on No.)" + bcolors.ENDC) runhack = yn_choice(bcolors.CYELLOW + "Would you like to run it now? (Will require sudo privileges. Will exit on No.)" + bcolors.ENDC)
if(runhack): if(runhack):
# keyboardconfigs[defaultkb-1]['hack'] os.system(keyboardconfigs[defaultkb-1]['hack'])
os.system('sudo hostname')
# else:
# exit()
# Setup the selected keyboards config # Setup the selected keyboards config
copytree("./.xkb/","~/.xkb/") os.system("cp -rf ./.xkb ~/.xkb")
if os.path.isdir(homedir + "/.xkb/keymap") == False:
os.mkdir(homedir + "/.xkb/keymap")
time.sleep(0.5)
os.system('setxkbmap -option') os.system('setxkbmap -option')
os.system('setxkbmap -print > ~/.xkb/keymap/kbd.mac.gui') os.system('setxkbmap -print > ~/.xkb/keymap/kbd.mac.gui')
os.system('setxkbmap -print > ~/.xkb/keymap/kbd.mac.term') os.system('setxkbmap -print > ~/.xkb/keymap/kbd.mac.term')
winmac = ["Windows","Mac - hid driver"] time.sleep(0.5)
if keyboardconfigs[defaultkb-1]['name'] in winmac:
symbols_gui_line = cmdline("cat ~/.xkb/keymap/kbd.mac.gui | grep -n 'xkb_symbols' | cut -f1 -d:").strip()
types_gui_line = cmdline("cat ~/.xkb/keymap/kbd.mac.gui | grep -n 'xkb_types' | cut -f1 -d:").strip()
symbols_term_line = cmdline("cat ~/.xkb/keymap/kbd.mac.term | grep -n 'xkb_symbols' | cut -f1 -d:").strip()
cmdline('sed -i '' -e "' + symbols_gui_line + 's/\\"/' + keyboardconfigs[defaultkb-1]['xkb_symbols_gui'] + '\\"/2" ~/.xkb/keymap/kbd.mac.gui')
cmdline('sed -i '' -e "' + types_gui_line + 's/\\"/' + keyboardconfigs[defaultkb-1]['xkb_types_gui'] + '\\"/2" ~/.xkb/keymap/kbd.mac.gui')
cmdline('sed -i '' -e "' + symbols_term_line + 's/\\"/' + keyboardconfigs[defaultkb-1]['xkb_symbols_term'] + '\\"/2" ~/.xkb/keymap/kbd.mac.term')
# line=$(cat ~/.xkb/keymap/kbd.mac.gui | grep -n 'xkb_symbols' | cut -f1 -d:) user_file = homedir + '/.config/kinto/user_config.json'
# sed -ie "${line}s/\"/+altwin(ctrl_alt_win)+mac_gui(mac_levelssym)\"/2" ~/.xkb/keymap/kbd.mac.gui with open(user_file, 'r') as f:
# sleep 1 user_config = json.load(f)
# 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
onetime = yn_choice("One time initialization tweaks are available. Would you like to view them?")
print("")
if(onetime):
intents = [obj for obj in user_config['de'] if(obj['intent'] == "init")]
# Tweaks available for initialization (on boot) for index, k in enumerate(intents):
print(color_arr[default-1] + bcolors.BOLD + str(index+1) + '. ' + k['name'] + bcolors.ENDC)
print(bcolors.CYELLOW + 'Description: ' + k['description'] + bcolors.ENDC)
print(bcolors.CYELLOW + 'run: ' + k['run'].replace(";", "\n") + bcolors.ENDC + '\n')
# Tweaks available while in gui keymap mode print(bcolors.CYELLOW + "Please enter your init tweak(s) (eg 1 or 1 2 3 - leave blank to skip): " + bcolors.ENDC)
defaultinit = [int(i) for i in input().split()]
if len(defaultinit) != 0:
user_config['init'] = defaultinit
# Tweaks available while in terminal keymap mode print("\nDynamic shortcut tweaks\n")
intents = [obj for obj in user_config['de'] if(obj['intent'] == "gui_term")]
# "id": 2, for index, k in enumerate(intents):
# "name":"Mac - hid driver", print(color_arr[default-1] + bcolors.BOLD + str(index+1) + '. ' + k['name'] + bcolors.ENDC)
# "active": false, print(bcolors.CYELLOW + 'Description: ' + k['description'] + bcolors.ENDC)
# "description":"Standard Mac Keyboards with Apple driver", print(bcolors.CYELLOW + 'run in gui mode: ' + k['run_gui'].replace(";", "\n") + bcolors.ENDC)
# "gui":"setxkbmap -option;xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.mac.gui $DISPLAY", print(bcolors.CYELLOW + 'run in terminal mode: ' + k['run_term'].replace(";", "\n") + bcolors.ENDC + '\n')
# "term":"setxkbmap -option;xkbcomp -w0 -I$HOME/.xkb ~/.xkb/keymap/kbd.mac.term $DISPLAY",
# "xkb_symbols_gui":"+altwin(ctrl_alt_win)+mac_gui(mac_levelssym)",
# "xkb_symbols_term":"+altwin(swap_alt_win)+mac_term(mac_levelssym)",
# "xkb_types_gui":"+mac_gui(addmac_levels)",
# "xkb_types_term":"",
# "hack": "echo '1' | sudo tee -a /sys/module/hid_apple/parameters/swap_opt_cmd;echo 'options hid_apple swap_opt_cmd=1' | sudo tee -a /etc/modprobe.d/hid_apple.conf;sudo update-initramfs -u -k all"
print(bcolors.CYELLOW + "Please enter your dynamic shortcut tweak(s) (eg 1 or 1 2 3 - leave blank to skip): " + bcolors.ENDC)
defaultde = [int(i) for i in input().split()]
if len(defaultde) != 0:
# gui
user_config['config'][0]['de'] = defaultde
# term
user_config['config'][1]['de'] = defaultde
for d in defaultde:
user_config['de'][d-1]['active'] = True
user_config['config'][0]['run'] = keyboardconfigs[defaultkb-1]['gui']
user_config['config'][1]['run'] = keyboardconfigs[defaultkb-1]['term']
os.remove(user_file)
with open(user_file, 'w') as f:
json.dump(user_config, f, indent=4)
print("Saved configuration to ~/.config/kinto/user_config.json\n")
print("Now running keyswap_service.sh to setup the keyswap service...")
print("Keyswap will be configured to run on user login\n")
print("You may start, stop, restart or view the status of the service with following commands\n")
print("systemctl --user start keyswap")
print("systemctl --user stop keyswap")
print("systemctl --user restart keyswap")
print("systemctl --user status keyswap")
os.system("./keyswap_service.sh")

View File

@@ -11,41 +11,38 @@
"appnames":[ "Gnome-terminal","konsole","io.elementary.terminal","terminator","sakura","guake","tilda","xterm","eterm" ] "appnames":[ "Gnome-terminal","konsole","io.elementary.terminal","terminator","sakura","guake","tilda","xterm","eterm" ]
}], }],
"init": [], "init": [],
"defaultapps":[{
"name":"term",
"appnames":[ "Gnome-terminal","konsole","io.elementary.terminal","terminator","sakura","guake","tilda","xterm","eterm" ]
}],
"detypes":["gnome2","gnome3","kde4","kde5","xfce","i3wm"], "detypes":["gnome2","gnome3","kde4","kde5","xfce","i3wm"],
"de":[{ "de":[{
"id": 1, "id": 1,
"type": ["gnome3"], "type": ["gnome3"],
"active": false, "active": false,
"intent":"init",
"name":"gnome-init", "name":"gnome-init",
"description":"Gnome - Remove Superkey Overlay keybinding to Activities Overview", "description":"Gnome - Remove Superkey Overlay keybinding to Activities Overview",
"run":"gsettings set org.gnome.mutter overlay-key ''" "run":"gsettings set org.gnome.mutter overlay-key ''",
"run_term":"",
"run_gui":""
}, },
{ {
"id": 2, "id": 2,
"type": ["gnome3"], "type": ["gnome3"],
"active": false, "active": false,
"name":"gnome-term", "intent":"gui_term",
"description":"Gnome - Terminal - Superkey+Space opens Activities Overview", "name":"Gnome Activities Overview",
"run":"gsettings set org.gnome.desktop.wm.keybindings panel-main-menu \"['<Control><Shift>Space']\"" "description":"Cmd+Space activates Activities Overview",
"run":"",
"run_term":"gsettings set org.gnome.desktop.wm.keybindings panel-main-menu \"['<Control><Shift>Space']\"",
"run_gui":"gsettings set org.gnome.desktop.wm.keybindings panel-main-menu \"['<Ctrl>Space']\""
}, },
{ {
"id": 3, "id": 3,
"type": ["gnome3"],
"active": false,
"name":"gnome-gui",
"description":"Gnome - GUI - Ctrl+Space opens Activities Overview",
"run":"gsettings set org.gnome.desktop.wm.keybindings panel-main-menu \"['<Ctrl>Space']\""
},
{
"id": 4,
"type": ["kde5"], "type": ["kde5"],
"active": false, "active": false,
"intent":"init",
"name":"kde-init", "name":"kde-init",
"description":"KDE Plasma 5 - Removes Superkey Overlay from the Launcher Menu", "description":"KDE Plasma 5 - Removes Superkey Overlay from the Launcher Menu",
"run":"gsettings set org.gnome.mutter overlay-key '';kwriteconfig5 --file ~/.config/kwinrc --group ModifierOnlyShortcuts --key Meta \"\";qdbus org.kde.KWin /KWin reconfigure" "run":"kwriteconfig5 --file ~/.config/kwinrc --group ModifierOnlyShortcuts --key Meta \"\";qdbus org.kde.KWin /KWin reconfigure",
"run_term":"",
"run_gui":""
}] }]
} }