small cosmetics fixes

This commit is contained in:
yory8 2019-03-25 19:13:19 +01:00
parent 12fc2eb10f
commit 8742f901b8
3 changed files with 3 additions and 10 deletions

View file

@ -43,7 +43,6 @@ func filter(history []string, text string) []string {
}
func listen(history []string, histfile string, persist bool, max int) error {
for {
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
// consider doing this in the frontend, for sparing resources
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.
time.Sleep(250 * time.Millisecond)
}
}

View file

@ -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()
)
var (
histfile string
history []string
)
func main() {
app.HelpFlag.Short('h')
kingpin.MustParse(app.Parse(os.Args[1:]))
@ -34,8 +29,9 @@ func main() {
if err != nil {
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)
if err == nil {
if err := json.Unmarshal(b, &history); err != nil {

View file

@ -8,7 +8,6 @@ import (
)
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 {
history[i], history[j] = history[j], history[i]
@ -20,6 +19,7 @@ func selector(history []string, max int) error {
return nil
}
// serve selection to the OS
if err := exec.Command("wl-copy", selected).Run(); err != nil {
return err
}