forked from Shinonome/dots-hyprland
Keybind path (#601)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import re
|
||||
import os
|
||||
from os.path import expandvars as os_expandvars
|
||||
from typing import Dict, List
|
||||
|
||||
@@ -35,7 +36,9 @@ class Section(dict):
|
||||
|
||||
|
||||
def read_content(path: str) -> str:
|
||||
with open(os_expandvars(path), "r") as file:
|
||||
if (not os.access(os.path.expanduser(os.path.expandvars(path)), os.R_OK)):
|
||||
return ("error")
|
||||
with open(os.path.expanduser(os.path.expandvars(path)), "r") as file:
|
||||
return file.read()
|
||||
|
||||
|
||||
@@ -207,6 +210,8 @@ def get_binds_recursive(current_content, scope):
|
||||
def parse_keys(path: str) -> Dict[str, List[KeyBinding]]:
|
||||
global content_lines
|
||||
content_lines = read_content(path).splitlines()
|
||||
if content_lines[0] == "error":
|
||||
return "error"
|
||||
return get_binds_recursive(Section([], [], ""), 0)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user