enable setting max-items from cli
This commit is contained in:
parent
981a591acd
commit
96a10b4479
4 changed files with 5 additions and 8 deletions
|
@ -12,6 +12,4 @@ A basic clipboard manager for Wayland.
|
|||
|
||||
Install the binary in your path, then run it in your Sway session by adding `exec clipman -d` at the beginning of your config.
|
||||
|
||||
You should edit `main.go` directly to configure how many unique history items to preserve (default: 15).
|
||||
|
||||
To query the history and select items, run the binary as `clipman -s`. You can assign it to a keybinding: `bindsym $mod+h exec clipman -s`.
|
||||
|
|
2
demon.go
2
demon.go
|
@ -42,7 +42,7 @@ func filter(history []string, text string) []string {
|
|||
return history
|
||||
}
|
||||
|
||||
func listen(history []string, histfile string, persist bool) error {
|
||||
func listen(history []string, histfile string, persist bool, max int) error {
|
||||
|
||||
for {
|
||||
|
||||
|
|
7
main.go
7
main.go
|
@ -10,13 +10,12 @@ import (
|
|||
"gopkg.in/alecthomas/kingpin.v2"
|
||||
)
|
||||
|
||||
const max = 15
|
||||
|
||||
var (
|
||||
app = kingpin.New("clipman", "A clipboard manager for Wayland")
|
||||
asDemon = app.Flag("demon", "Run as a demon to record clipboard events").Short('d').Default("false").Bool()
|
||||
asSelector = app.Flag("select", "Select an item from clipboard history").Short('s').Default("false").Bool()
|
||||
noPersist = app.Flag("no-persist", "Don't persist a copy buffer after a program exits").Short('P').Default("false").Bool()
|
||||
max = app.Flag("max-items", "How many copy items to store in history").Default("15").Int()
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -46,11 +45,11 @@ func main() {
|
|||
|
||||
if *asDemon {
|
||||
persist := !*noPersist
|
||||
if err := listen(history, histfile, persist); err != nil {
|
||||
if err := listen(history, histfile, persist, *max); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
} else if *asSelector {
|
||||
if err := selector(history); err != nil {
|
||||
if err := selector(history, *max); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
func selector(history []string) error {
|
||||
func selector(history []string, max int) error {
|
||||
|
||||
// reverse the history
|
||||
for i, j := 0, len(history)-1; i < j; i, j = i+1, j-1 {
|
||||
|
|
Loading…
Reference in a new issue