mirror of
https://github.com/end-4/dots-hyprland.git
synced 2026-06-05 23:09:26 -05:00
Keybind path (#601)
This commit is contained in:
@@ -56,6 +56,11 @@ let configOptions = {
|
||||
'default': "auto",
|
||||
},
|
||||
},
|
||||
'cheatsheet': {
|
||||
'keybinds': {
|
||||
'configPath': "" // Path to hyprland keybind config file. Leave empty for default (~/.config/hypr/hyprland/keybinds.conf)
|
||||
}
|
||||
},
|
||||
'gaming': {
|
||||
'crosshair': {
|
||||
'size': 20,
|
||||
|
||||
@@ -5,13 +5,22 @@ import Widget from "resource:///com/github/Aylur/ags/widget.js";
|
||||
import { IconTabContainer } from "../.commonwidgets/tabcontainer.js";
|
||||
const { Box, Label, Scrollable } = Widget;
|
||||
|
||||
const HYPRLAND_KEYBIND_CONFIG_FILE = `${GLib.get_user_config_dir()}/hypr/hyprland/keybinds.conf`;
|
||||
const HYPRLAND_KEYBIND_CONFIG_FILE = userOptions.cheatsheet.keybinds.configPath ?
|
||||
userOptions.cheatsheet.keybinds.configPath : `${GLib.get_user_config_dir()}/hypr/hyprland/keybinds.conf`;
|
||||
const KEYBIND_SECTIONS_PER_PAGE = 3;
|
||||
const keybindList = JSON.parse(
|
||||
Utils.exec(
|
||||
`${App.configDir}/scripts/hyprland/get_keybinds.py --path ${HYPRLAND_KEYBIND_CONFIG_FILE}`,
|
||||
),
|
||||
);
|
||||
const getKeybindList = () => {
|
||||
let data = Utils.exec(`${App.configDir}/scripts/hyprland/get_keybinds.py --path ${HYPRLAND_KEYBIND_CONFIG_FILE}`);
|
||||
if (data == "\"error\"") {
|
||||
Utils.timeout(2000, () => Utils.execAsync(['notify-send',
|
||||
'Update path to keybinds',
|
||||
'Keybinds hyprland config file not found. Check your user options.',
|
||||
'-a', 'ags',
|
||||
]).catch(print))
|
||||
return { children: [] };
|
||||
}
|
||||
return JSON.parse(data);
|
||||
};
|
||||
const keybindList = getKeybindList();
|
||||
|
||||
const keySubstitutions = {
|
||||
"Super": "",
|
||||
|
||||
@@ -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