Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 76 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,82 @@ mimic the way i3wm handles the scratchpad.

# Installation

## Go install

Run `go install github.com/soderluk/nirimgr@latest` to install nirimgr.

## From GitHub Releases

Get the latest release from the [Releases page](https://github.com/soderluk/nirimgr/releases/).

Choose your arch and download the tarball.

If you want to verify the download, also get the `nirimgr_x.x.x_checksums.txt` file.

To verify the download run `sha256sum -c [checksums.txt]`

```bash
$ sha256sum -c nirimgr_x.x.x_checksums.txt

sha256sum: nirimgr_x.x.x_darwin_amd64.tar.gz: No such file or directory
nirimgr_x.x.x_darwin_amd64.tar.gz: FAILED open or read
sha256sum: nirimgr_x.x.x_darwin_arm64.tar.gz: No such file or directory
nirimgr_x.x.x_darwin_arm64.tar.gz: FAILED open or read
nirimgr_x.x.x_linux_amd64.tar.gz: OK
sha256sum: WARNING: 2 listed files could not be read
```

If you only downloaded one tarball, you'll get 2 failures on the checks. If you have 3 failed checks,
please make sure you downloaded the tarball from https://github.com/soderluk/nirimgr/releases/.

If things are still failing, please open an [issue](https://github.com/soderluk/nirimgr/issues/new).

After verification succeeds, unzip the tarball somewhere, e.g. ~/Downloads/nirimgr.

```bash
tar xf nirimgr_x.x.x_linux_amd64.tar.gz --directory=~/Downloads/nirimgr/
```

The tarball includes the following files:

- CHANGELOG.md: The changelog for this version.
- LICENSE: The license file of the repository.
- nirimgr: The executable file.
- README.md: This readme.

Move the `nirimgr` executable somewhere in your `PATH`, e.g. `/usr/local/bin`, or `~/bin`.

Verify the version after installation:

`nirimgr version`

```bash
$ nirimgr version

┌──────────────┬────────────────────────────────────────────┐
│ NIRIMGR │ │
├──────────────┼────────────────────────────────────────────┤
│ Version │ 0.1.2 │
│ Commit │ a86e7ad8bbea61b56ab8a2ee7eeea1e6aa30bfe9 │
│ Build Date │ 2025-07-24T08:24:50Z │
│ ---------- │ ---------- │
│ Build Info │ │
│ ---------- │ ---------- │
│ Go version │ go1.23.5 │
│ -buildmode │ exe │
│ -compiler │ gc │
│ -trimpath │ true │
│ CGO_ENABLED │ 0 │
│ CGO_CFLAGS │ │
│ CGO_CPPFLAGS │ │
│ CGO_CXXFLAGS │ │
│ CGO_LDFLAGS │ │
│ GOARCH │ amd64 │
│ GOOS │ linux │
│ GOAMD64 │ v1 │
└──────────────┴────────────────────────────────────────────┘
```

# Configuration

The configuration file for nirimgr should be put in ~/.config/nirimgr/config.json
Expand Down Expand Up @@ -108,14 +182,15 @@ Please feel free to open a PR if you have other thoughts that we could do with n

# Usage

To use nirimgr, it provides two CLI-commands:
To use nirimgr, it provides the following CLI-commands:

- `events`: The events command starts listening on the niri event-stream. `nirimgr events`
- `scratch`: The scratch command moves a window to the scratchpad workspace, or shows the window (moves the window
to the currently active workspace) from the scratchpad workspace. This command should be configured
as a keybind in niri configuration. `nirimgr scratch [move|show]`
- `list`: The list command will list all the available actions or events, so you don't need to remember them all.
`nirimgr list [actions|events]`
- `version`: The version command prints the nirimgr version information. `nirimgr version`

To use the scratchpad with Niri, you need to have a named workspace `scratchpad`, or if you want to configure it,
set the scratchpadWorkspace configuration option to something else `"scratchpadWorkspace": "scratch"`.
Expand Down
49 changes: 32 additions & 17 deletions cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ package cmd

import (
"fmt"
"os"
"runtime"
"runtime/debug"
"strings"

"github.com/olekukonko/tablewriter"
"github.com/soderluk/nirimgr/config"
"github.com/spf13/cobra"
)
Expand All @@ -15,26 +18,38 @@ var versionCmd = &cobra.Command{
Short: "Print version",
Long: "Prints the version number and build information about nirimgr",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("nirimgr " + buildInfo())
table := tablewriter.NewTable(os.Stdout)
table.Header([]string{"nirimgr", ""})
c := 10
info := [][]string{
{"Version", config.Version},
{"Commit", config.CommitSHA},
{"Build Date", config.BuildDate},
{r("-", c), r("-", c)},
{"Build Info", ""},
{r("-", c), r("-", c)},
{"Go version", runtime.Version()},
}
bi, _ := debug.ReadBuildInfo()
for _, s := range bi.Settings {
info = append(info, []string{s.Key, s.Value})
}
for _, data := range info {
if err := table.Append(data[0], data[1]); err != nil {
fmt.Printf("Could not append %s to info\n", data[0])
}
}
if err := table.Render(); err != nil {
fmt.Println("Could not render table.")
}
},
}

func init() {
rootCmd.AddCommand(versionCmd)
// r returns the repeated string s, count c times.
func r(s string, c int) string {
return strings.Repeat(s, c)
}

// buildInfo returns the build information about nirimgr
func buildInfo() string {
info := fmt.Sprintf("\nVersion:\t%s\nCommit:\t%s\nGo Version:\t%s\nBuild Date:\t%s\nBuild info: \n",
config.Version,
config.CommitSHA,
runtime.Version(),
config.BuildDate,
)
bi, _ := debug.ReadBuildInfo()
for _, setting := range bi.Settings {
info += fmt.Sprintf("%s:\t%s\n", setting.Key, setting.Value)
}

return info
func init() {
rootCmd.AddCommand(versionCmd)
}
55 changes: 55 additions & 0 deletions examples/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"scratchpadWorkspace": "scratchpad",
"logLevel": "DEBUG",
"rules": [
{
"match": [
{
"title": "Bitwarden",
"appId": "zen"
}
],
"actions": {
"MoveWindowToFloating": {},
"SetWindowWidth": {
"change": {
"SetFixed": 400
}
},
"SetWindowHeight": {
"change": {
"SetFixed": 600
}
}
}
},
{
"match": [
{
"appId": "org.gnome.Calculator"
}
],
"actions": {
"MoveWindowToFloating": {},
"MoveFloatingWindow": {
"x": {
"SetFixed": 800
},
"y": {
"SetFixed": 200
}
},
"SetWindowWidth": {
"change": {
"SetFixed": 50
}
},
"SetWindowHeight": {
"change": {
"SetFixed": 50
}
}
}
}
]
}