diff options
author | NeodarZ <neodarz@neodarz.net> | 2018-01-15 00:42:42 +0100 |
---|---|---|
committer | NeodarZ <neodarz@neodarz.net> | 2018-01-15 00:42:42 +0100 |
commit | c801d5dfa5aa509786538564e052ef9d11f0feb8 (patch) | |
tree | 2b8b89aed03810302f1d60874590f43aa7ec5ae5 /scripts/.scripts | |
parent | a090e38b2e9e4e4b86d637936fb9b35add5cb581 (diff) | |
download | dotfiles_ascii-c801d5dfa5aa509786538564e052ef9d11f0feb8.tar.xz dotfiles_ascii-c801d5dfa5aa509786538564e052ef9d11f0feb8.zip |
add bepo scipt management for i3 workspace
Diffstat (limited to '')
-rwxr-xr-x | scripts/.scripts/i3removesupportof.py | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/scripts/.scripts/i3removesupportof.py b/scripts/.scripts/i3removesupportof.py new file mode 100755 index 0000000..6cbc877 --- /dev/null +++ b/scripts/.scripts/i3removesupportof.py @@ -0,0 +1,56 @@ +#/bin/python + +import re, sys, os + +key_to_rm=str(sys.argv[1]) +config_file=os.path.expanduser("~/.config/i3/config") + +oneline_conf_file = "" + +conf_file_input = open(config_file, 'r') + +for line in conf_file_input: + line = re.sub("^#{1}\.", "", line) + oneline_conf_file = oneline_conf_file + line + +conf_file_input.close() + + +# add key +block_conf_found = re.search(r"#{1}"+key_to_rm+".*#{1}"+key_to_rm+".", oneline_conf_file, re.DOTALL) + +if block_conf_found != None: + + block_conf_found_splited = block_conf_found.group(0).splitlines() + + oneline_final_data = "" + line_parsed=0 + comment_this_line=0 + end_key=0 + for line in block_conf_found_splited: + if re.search("^#{1}"+key_to_rm+"$", line): + comment_this_line=1 + elif re.search("^#{1}"+key_to_rm+".$", line): + end_key=1 + comment_this_line=0 + if comment_this_line == 1: + oneline_final_data = oneline_final_data + "#." + line + elif end_key == 1: + oneline_final_data = oneline_final_data + "#." + line + end_key = 0 + else: + oneline_final_data = oneline_final_data + line + if line_parsed != len(block_conf_found_splited)-1: + oneline_final_data = oneline_final_data + "\n" + line_parsed = line_parsed + 1 + + + oneline_new_conf_file = re.sub(r"#"+key_to_rm+".*#"+key_to_rm+".", oneline_final_data, oneline_conf_file, flags=re.DOTALL) + + confOutput = open(config_file, 'w') + + confOutput.write(oneline_new_conf_file) + + confOutput.close() +else: + print("Sorry the keymap '"+str(sys.argv[1])+"' is not in this conf file, use 'fr' or 'bepo'.\nBetween, this script is used to remove a keymap support for i3wm.\nUsage:\n "+sys.argv[0]+" fr") |