small cosmetics fixes
This commit is contained in:
parent
12fc2eb10f
commit
8742f901b8
3 changed files with 3 additions and 10 deletions
3
demon.go
3
demon.go
|
@ -43,7 +43,6 @@ func filter(history []string, text string) []string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func listen(history []string, histfile string, persist bool, max int) error {
|
func listen(history []string, histfile string, persist bool, max int) error {
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
|
||||||
t, err := exec.Command("wl-paste", []string{"-n", "-t", "text"}...).Output()
|
t, err := exec.Command("wl-paste", []string{"-n", "-t", "text"}...).Output()
|
||||||
|
@ -72,7 +71,6 @@ func listen(history []string, histfile string, persist bool, max int) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove duplicates
|
// remove duplicates
|
||||||
// consider doing this in the frontend, for sparing resources
|
|
||||||
history = filter(history, text)
|
history = filter(history, text)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -98,5 +96,4 @@ func listen(history []string, histfile string, persist bool, max int) error {
|
||||||
// also because if we copied once, we might copy soon after.
|
// also because if we copied once, we might copy soon after.
|
||||||
time.Sleep(250 * time.Millisecond)
|
time.Sleep(250 * time.Millisecond)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
8
main.go
8
main.go
|
@ -18,11 +18,6 @@ var (
|
||||||
max = app.Flag("max-items", "items to store in history (with -d) or display before scrolling (with -s)").Default("15").Int()
|
max = app.Flag("max-items", "items to store in history (with -d) or display before scrolling (with -s)").Default("15").Int()
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
histfile string
|
|
||||||
history []string
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
app.HelpFlag.Short('h')
|
app.HelpFlag.Short('h')
|
||||||
kingpin.MustParse(app.Parse(os.Args[1:]))
|
kingpin.MustParse(app.Parse(os.Args[1:]))
|
||||||
|
@ -34,8 +29,9 @@ func main() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
histfile = path.Join(h, ".local/share/clipman.json")
|
histfile := path.Join(h, ".local/share/clipman.json")
|
||||||
|
|
||||||
|
var history []string
|
||||||
b, err := ioutil.ReadFile(histfile)
|
b, err := ioutil.ReadFile(histfile)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if err := json.Unmarshal(b, &history); err != nil {
|
if err := json.Unmarshal(b, &history); err != nil {
|
||||||
|
|
|
@ -8,7 +8,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func selector(history []string, max int) error {
|
func selector(history []string, max int) error {
|
||||||
|
|
||||||
// reverse the history
|
// reverse the history
|
||||||
for i, j := 0, len(history)-1; i < j; i, j = i+1, j-1 {
|
for i, j := 0, len(history)-1; i < j; i, j = i+1, j-1 {
|
||||||
history[i], history[j] = history[j], history[i]
|
history[i], history[j] = history[j], history[i]
|
||||||
|
@ -20,6 +19,7 @@ func selector(history []string, max int) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// serve selection to the OS
|
||||||
if err := exec.Command("wl-copy", selected).Run(); err != nil {
|
if err := exec.Command("wl-copy", selected).Run(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue