Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
fix: formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
NotAShelf committed Nov 4, 2022
1 parent 49d45b0 commit e77b204
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 24 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Hyprkeys

A simple application to quickly get your Hyprand keybinds with
much more to come.
A simple application to quickly get your Hyprland keybinds with
much more to come.

> ⚠️ Hyprkeys is currently in early development and is not ready for use. Not like it can
break anything, but you will have wasted your time.

In case you still want to use it, instructions are below:
*(Looking for testers and contributors, Go is not a language I often work with.)*

**(Looking for testers and contributors, Go is not a language I often work with.)**

## Installation & Usage

Expand All @@ -22,7 +23,7 @@ Alternatively, open this directory and run `go run .` to run without compiling.
- [x] Format keybinds better, maybe with a proper table
- [x] Remove the `+` in the keybinds that don't have modifiers
- [x] Add an extra column to mouse keybinds to match table titles
- [x] Optionally (--con_vars) parse variables and replace them with their actual value
- [x] Optionally (--variables) parse variables and replace them with their actual value
- [ ] Account for bind flags, that may be passed in any random order
- [ ] Figure out a regex to match the flags
- [ ] Account for line comments in rows
Expand Down
27 changes: 7 additions & 20 deletions hyprkeys.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,13 @@ import (
"bufio"
"fmt"
"os"
"regexp"
"strings"
)

// Read Hyprland configuration file and return lines that start with bind= and bindm=
// Hyprland configuration file is stored in $HOME/.config/hypr/hyprland.conf
// A keyboard bind looks like this: bind=MOD,KEY,exec,COMMAND
// A mouse bind looks like this: bindm=MOD,KEY,exec,COMMAND
// We want to return the keys like this:
// Keybind = | <kbd>SUPER + L</kbd> | firefox | , firefox
// and put them in a markdown table
func readHyprlandConfig() ([]string, []string, []string, map[string]string) {
// If --test is passed as an argument, read the test file
// TODO: If --test is passed as an argument, read the test file
//file, err := os.Open(os.Getenv("HOME") + "/.config/hypr/hyprland.conf")
file, err := os.Open("test/hyprland.conf") // testing config
if err != nil {
Expand All @@ -35,8 +30,13 @@ func readHyprlandConfig() ([]string, []string, []string, map[string]string) {
line := scanner.Text()
if strings.HasPrefix(line, "bind=") {
kbKeybinds = append(kbKeybinds, line)

} else if strings.HasPrefix(line, regexp.MustCompile(`^bind.*[lrme]*.*=`).String()) { // TODO: Fix this regex somehow
mKeybinds = append(mKeybinds, line)

} else if strings.HasPrefix(line, "bindm=") {
mKeybinds = append(mKeybinds, line)

} else if strings.HasPrefix(line, "$") {
// Probably not the best way to do this, but can't think of another occasion where a line would start with "$"
// and include "=", yet still not be a variable
Expand All @@ -58,19 +58,6 @@ func readHyprlandConfig() ([]string, []string, []string, map[string]string) {
return kbKeybinds, mKeybinds, variables, variableMap
}

// func parseVariables(variables []string) []string {
// var parsedVariables []string
// for _, variable := range variables {
// variable = strings.TrimPrefix(variable, "$")
// variableSlice := strings.SplitN(variable, "=", 2)
// variableSlice[0] = strings.TrimSpace(variableSlice[0])
// variableSlice[1] = strings.TrimSpace(variableSlice[1])
// parsedVariables = append(parsedVariables, variableSlice[0]+" = "+variableSlice[1])
// }

// return parsedVariables
// }

// Return each keybind as a markdown table row
// like this: | <kbd>SUPER + L</kbd> | firefox | , firefox
// we also account for no MOD key.
Expand Down

0 comments on commit e77b204

Please sign in to comment.