Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vannrr/rofi-api
A go library for using the rofi API.
https://github.com/vannrr/rofi-api
api go golang library rofi rofi-scripts
Last synced: about 1 month ago
JSON representation
A go library for using the rofi API.
- Host: GitHub
- URL: https://github.com/vannrr/rofi-api
- Owner: VannRR
- License: mit
- Created: 2024-09-21T22:25:25.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-10-16T01:50:17.000Z (3 months ago)
- Last Synced: 2024-10-17T15:32:15.343Z (3 months ago)
- Topics: api, go, golang, library, rofi, rofi-scripts
- Language: Go
- Homepage:
- Size: 28.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rofiapi
#### `import github.com/VannRR/rofi-api`
rofiapi, for use with https://github.com/davatorium/rofi also see man rofi-script
## Usage
A simple script would be:
```go
package mainimport (
"fmt"
"log"rofiapi "github.com/VannRR/rofi-api"
)// make sure the fields of the struct are public/capitalized
type data struct {
Number uint16
}func main() {
// can be simplified in this case to NewRofiApi(0)
api, err := rofiapi.NewRofiApi(data{Number: 0})
if err != nil {
log.Fatalf("Error: %v\n", err)
}selectedEntry, ok := api.GetSelectedEntry()
if !ok {
api.Entries = append(api.Entries, rofiapi.Entry{Text: "initial run"})
}if selectedEntry.Text == "quit" {
return
}someEntries := []rofiapi.Entry{
{Text: fmt.Sprintf("counter: %d", api.Data.Number)},
{Text: "quit"},
}
api.Entries = append(api.Entries, someEntries...)api.Data.Number += 1
//call last
err = api.Draw()
if err != nil {
log.Fatalf("Error: %v\n", err)
}
}
```
This shows three entries, initial run, counter and quit.
- initial run: only displayed when there is no input/entry from rofi
- counter: shows the value of data.number as it increments
- quit : when the quit entry is selected, rofi closes***For more info check `DOCS.md`.***
#### Notes
I recommend compiling your rofi script/go binary with `go build -ldflags="-w -s"` for a smaller size.