✨ Add option to linger after copy (might be useful under X11)
This commit is contained in:
parent
e3e64309b6
commit
82e8d971d8
20
main.go
20
main.go
|
@ -5,7 +5,9 @@ import (
|
|||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/app"
|
||||
|
@ -19,7 +21,8 @@ import (
|
|||
//go:embed data/gitmojis.json data/images
|
||||
var data embed.FS
|
||||
|
||||
var preferredTheme = flag.String("theme", "light", "Specifiy the theme to be used. dark/light")
|
||||
var preferredTheme = flag.String("theme", "light", "Specify the theme to be used. dark/light")
|
||||
var linger = flag.String("linger", "", "If specified, linger for the given duration (e.g. 10s) before actually closing.")
|
||||
|
||||
type Gitmoji struct {
|
||||
Emoji string
|
||||
|
@ -64,12 +67,23 @@ func main() {
|
|||
}
|
||||
|
||||
a := app.New()
|
||||
|
||||
switch *preferredTheme {
|
||||
case "dark":
|
||||
a.Settings().SetTheme(theme.DarkTheme())
|
||||
default:
|
||||
a.Settings().SetTheme(theme.LightTheme())
|
||||
}
|
||||
|
||||
var lingerDuration *time.Duration = nil
|
||||
if *linger != "" {
|
||||
if d, err := time.ParseDuration(*linger); err != nil {
|
||||
log.Fatalf("invalid linger time: %v\n", err)
|
||||
} else {
|
||||
lingerDuration = &d
|
||||
}
|
||||
}
|
||||
|
||||
w := a.NewWindow("Gitmoji Picker")
|
||||
w.CenterOnScreen()
|
||||
|
||||
|
@ -192,6 +206,10 @@ func main() {
|
|||
|
||||
if currentId > -1 {
|
||||
w.Clipboard().SetContent(currentEntries[currentId].Emoji)
|
||||
if lingerDuration != nil {
|
||||
w.Hide()
|
||||
time.Sleep(*lingerDuration)
|
||||
}
|
||||
w.Close()
|
||||
return true
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue