mirror of
https://gitlab.com/manzerbredes/i3-colors.git
synced 2025-04-07 00:56:24 +02:00
Allow i3 restart
This commit is contained in:
parent
4a753e5e3d
commit
1bb0ed2eb9
3 changed files with 23 additions and 10 deletions
9
TODO.org
9
TODO.org
|
@ -6,12 +6,15 @@
|
||||||
- [ ] Change src/theme.py name
|
- [ ] Change src/theme.py name
|
||||||
- [ ] Improve function/variables names
|
- [ ] Improve function/variables names
|
||||||
|
|
||||||
- YAML Theme Parser [0/1]:
|
- YAML Theme Parser [0/2]:
|
||||||
- [ ] Improve yaml theme loader reliability
|
- [ ] Improve yaml theme loader reliability
|
||||||
|
- [ ] Allow several metadata
|
||||||
|
|
||||||
- Theme applying algorithm [0/2]:
|
- Theme applying algorithm [0/3]:
|
||||||
- [ ] Improve efficiency
|
- [ ] Improve efficiency
|
||||||
- [ ] Assume that theme to apply is well formated (checked in YAML Theme Parser)
|
- [ ] Assume that theme to apply is well formated (checked in YAML Theme Parser)
|
||||||
|
- [ ] If there is no "colors" field in "bar" section, we still need to apply theme
|
||||||
|
|
||||||
- General [0/1]:
|
- General [1/2]:
|
||||||
- [ ] Improve user API
|
- [ ] Improve user API
|
||||||
|
- [X] Allow -r option (restart i3)
|
||||||
|
|
|
@ -1,15 +1,26 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
import parser, theme, os, argparse
|
import parser, theme, os, argparse, subprocess
|
||||||
|
|
||||||
|
|
||||||
args_parser = argparse.ArgumentParser(description='Process some integers.')
|
##### Utils Functions #####
|
||||||
args_parser.add_argument('theme_path', metavar='theme', type=str, nargs='?',
|
def log(title, content): print("\033[92m{}\033[00m: {}" .format(title,content))
|
||||||
help='YAML i3 theme path')
|
###########################
|
||||||
|
|
||||||
|
|
||||||
|
##### Parse Arguments #####
|
||||||
|
args_parser = argparse.ArgumentParser(description='I3 Window Manager Colors Themer.')
|
||||||
|
args_parser.add_argument('theme_path', type=str, nargs='?',
|
||||||
|
help='I3 YAML theme path.')
|
||||||
|
args_parser.add_argument('-r', '--restart' ,action='store_true', help='Restart i3 after applying theme.')
|
||||||
args = args_parser.parse_args()
|
args = args_parser.parse_args()
|
||||||
|
###########################
|
||||||
|
|
||||||
##### Apply Theme #####
|
##### Apply Theme #####
|
||||||
loaded_theme=theme.load(args.theme_path)
|
loaded_theme=theme.load(args.theme_path)
|
||||||
|
for meta_key,meta_value in loaded_theme["meta"].items():
|
||||||
|
log(meta_key.title(),meta_value)
|
||||||
parser.apply_theme(os.environ["HOME"]+"/.config/i3/config",loaded_theme)
|
parser.apply_theme(os.environ["HOME"]+"/.config/i3/config",loaded_theme)
|
||||||
|
if args.restart:
|
||||||
|
subprocess.Popen("i3-msg restart".split())
|
||||||
|
#######################
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,6 @@ def apply_to_config(tmp_config,theme):
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
def apply_theme(config_file,theme):
|
def apply_theme(config_file,theme):
|
||||||
print("Applying theme: "+theme["meta"]["description"])
|
|
||||||
tmp=extract_config(config_file)
|
tmp=extract_config(config_file)
|
||||||
apply_to_config(tmp,theme)
|
apply_to_config(tmp,theme)
|
||||||
shutil.move(tmp,config_file)
|
shutil.move(tmp,config_file)
|
||||||
|
|
Loading…
Add table
Reference in a new issue