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

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
NotAShelf authored Nov 20, 2022
2 parents cef60e6 + 4ff1c51 commit f5a7f4b
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 19 deletions.
9 changes: 2 additions & 7 deletions .github/pre-releaser.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# Go Build & Release CI

# This is a basic workflow to help you get started with Actions

name: Go Build & Release CI

# Controls when the action will run. Triggers the workflow on push or pull request
Expand All @@ -16,17 +13,15 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
check-latest: true
cache: true
- run: go run . --verbose
- run: go run . --markdown
- run: go run . --variables

# Build the binary with go build
- name: Build the binary
run: go build -o Hyprkeys

# Publish the binary to Github Releases

38 changes: 38 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Go linting using Revive (https://revive.run)
name: Lint
on:
workflow_dispatch:
pull_request:
branches: [ main ]
push:
paths:
- '**.go'
- 'revive.toml'
- '.github/workflows/linter.yml'


jobs:
lint:
name: Revive
runs-on: ubuntu-latest
environment: production

defaults:
run:
shell: bash

steps:

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: '1.19'

- name: Checkout
uses: actions/checkout@v3

- name: Run Revive Action by pulling pre-built image
uses: docker://morphy/revive-action:v2
with:
formatter: friendly

5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*.dll
*.so
*.dylib
hyprkeys
Hyprkeys

# Test binary, built with `go test -c`
*.test
Expand All @@ -16,4 +16,5 @@ hyprkeys
# vendor/

# VScode settings
.vscode/
.vscode/

14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Hyprkeys

A simple application to quickly get your Hyprland keybinds with
much more to come.
A simple, and relatively fast application that returns your Hyprland keys.

*No, not just keybinds. We now return config sections as well*


> ⚠️ 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.
Expand Down Expand Up @@ -41,6 +43,14 @@ Alternatively, open this directory and run `go run .` to run without compiling.
- [ ] Add a way to change keybinds with Hyprkeys after reading them (???)
- [ ] Packaging for AUR and maybe other distros (why would anyone want that)


### Current TODOs

- [ ] (hyprkeys.go) Trim "bind = " from keybinds before printing in markdown
- [ ] (hyprkeys.go) Switch regex mechanism
- [x] (hyprkeys.go) `--help flag`
Search for `TODO` in the code for more information.

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.
Expand Down
36 changes: 29 additions & 7 deletions hyprkeys.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bufio"
"encoding/json"
"fmt"
"io/ioutil"
"io/ioutil" // io/ioutil is deprecated, use io and os packages instead
"os"
"regexp"
"strings"
Expand All @@ -14,11 +14,21 @@ import (

// Read Hyprland configuration file and return lines that start with bind= and bindm=
func readHyprlandConfig() ([]string, []string, []string, map[string]string) {
// 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 --test flag is passed, read from test file
// otherwise read from ~/.config/hypr/hyprland.conf
var configPath string
if len(os.Args) > 1 && os.Args[1] == "--test" {
configPath = "test/hyprland.conf"
} else {
configPath = os.Getenv("HOME") + "/.config/hypr/hyprland.conf"
}

// Open the file
file, err := os.Open(configPath)
if err != nil {
panic(err)
fmt.Println("Error opening file:", err)
os.Exit(1)
}
defer file.Close()

Expand Down Expand Up @@ -127,7 +137,19 @@ func keybindsToMarkdown(kbKeybinds, mKeybinds []string) []string {
func main() {
kbKeybinds, mKeybinds, variables, variableMap := readHyprlandConfig()

if len(os.Args) > 1 {
// If the first argument is empty, show the help message
if len(os.Args) == 1 {
fmt.Println("Usage: hyprkeys [OPTIONS]")
fmt.Println("Generate a markdown table of keybinds from a Hyprland configuration file.")
fmt.Println("If no file is specified, the default configuration file is used.")
fmt.Println("Options:")
fmt.Println(" -h, --help\t\tShow this help message")
fmt.Println(" -t, --test\t\tUse the test configuration file")
fmt.Println(" -m, --markdown\t\tPrint the binds as a markdown table")
fmt.Println(" -v, --verbose\t\tPrint text as is, without making it pretty")
fmt.Println(" -V, --version\t\tShow the version number")
} else if len(os.Args) > 1 {
// Print args

// If --verbose is passed as an argument, print the keybinds
// to the terminal
Expand Down Expand Up @@ -172,7 +194,7 @@ func main() {
}

if os.Args[1] == "--blocks" {
file, err := ioutil.ReadFile("test/hyprland.conf")
file, err := ioutil.ReadFile("test/hyprland.conf") // TODO: make this use configPath
if err != nil {
panic(err)
}
Expand Down
8 changes: 8 additions & 0 deletions util/cli/flags.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package flags

// TODO
// If any flags are passed, store all of them in a map
// We will then check this variable to see which flags
// were passed, then maybe prevent some flags from being
// passed together
// TODO
2 changes: 1 addition & 1 deletion util/properties/properties.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ type S_touchpad struct {
S_disable_while_typing bool
S_clickfinger_behavior bool
S_middle_button_emulation bool
S_tap_to_click bool //say vaxry to rename this shit to use _
S_tap_to_click bool //say vaxry to rename this shit to use underscores instead of dashes
S_drag_lock bool
S_scroll_factor float64
S_transform int64
Expand Down

0 comments on commit f5a7f4b

Please sign in to comment.