aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Kiryukhin <a.kiryukhin@mail.ru>2021-12-13 15:39:41 +0300
committerAlexander Kiryukhin <a.kiryukhin@mail.ru>2021-12-13 15:43:34 +0300
commitcc47f2e55654b459f20520b3c4221473903cbddc (patch)
treea5ece0447f228008a4ccd88a1bd21c8ce515ee84
parent58160f5a65978db90dcbac85d76ad7e960cfa6ff (diff)
initial
-rw-r--r--.goreleaser.yml49
-rw-r--r--README.md27
-rw-r--r--go.mod15
-rw-r--r--go.sum17
-rw-r--r--main.go68
5 files changed, 176 insertions, 0 deletions
diff --git a/.goreleaser.yml b/.goreleaser.yml
new file mode 100644
index 0000000..1c010e3
--- /dev/null
+++ b/.goreleaser.yml
@@ -0,0 +1,49 @@
+# This is an example .goreleaser.yml file with some sensible defaults.
+# Make sure to check the documentation at https://goreleaser.com
+before:
+ hooks:
+ # You may remove this if you don't use go modules.
+ - go mod tidy
+ # you may remove this if you don't need go generate
+ - go generate ./...
+builds:
+ - env:
+ - CGO_ENABLED=0
+ goos:
+ - linux
+ - windows
+ - darwin
+archives:
+ - replacements:
+ darwin: Darwin
+ linux: Linux
+ windows: Windows
+ 386: i386
+ amd64: x86_64
+checksum:
+ name_template: 'checksums.txt'
+snapshot:
+ name_template: "{{ incpatch .Version }}-next"
+changelog:
+ sort: asc
+ filters:
+ exclude:
+ - '^docs:'
+ - '^test:'
+brews:
+ -
+ name: pomodoro
+ goarm: 6
+ tap:
+ owner: neonxp
+ name: homebrew-tap
+ branch: master
+ url_template: "http://github.com/neonxp/pomodoro/releases/download/{{ .Tag }}/{{ .ArtifactName }}"
+ commit_author:
+ name: NeonXP
+ email: i@neonxp.ru
+ commit_msg_template: "Brew formula update for {{ .ProjectName }} version {{ .Tag }}"
+ folder: Formula
+ homepage: "https://neonxp.ru/pomodoro/"
+ description: "Pomodoro timer for nerds"
+ license: "GPL-3.0-or-later" \ No newline at end of file
diff --git a/README.md b/README.md
index b1855c3..b6624e3 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,29 @@
# pomodoro
Pomodoro timer for nerds
+
+## Installation
+
+### Binaries
+
+Grab binaries for different OS from https://github.com/neonxp/pomodoro/releases
+
+### Homebrew
+
+```
+brew install neonxp/tap/pomodoro
+```
+
+### With golang
+```
+go install github.com/neonxp/pomodoro@latest
+```
+
+## Usage
+
+Just run
+
+```shell
+pomodoro
+```
+
+to stop - press Ctrl+C or kill process \ No newline at end of file
diff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..959702f
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,15 @@
+module github.com/neonxp/pomodoro
+
+go 1.17
+
+require github.com/gen2brain/beeep v0.0.0-20210529141713-5586760f0cc1
+
+require (
+ github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4 // indirect
+ github.com/godbus/dbus/v5 v5.0.3 // indirect
+ github.com/gopherjs/gopherjs v0.0.0-20180825215210-0210a2f0f73c // indirect
+ github.com/gopherjs/gopherwasm v1.1.0 // indirect
+ github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect
+ github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af // indirect
+ golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9 // indirect
+)
diff --git a/go.sum b/go.sum
new file mode 100644
index 0000000..a8dbbd5
--- /dev/null
+++ b/go.sum
@@ -0,0 +1,17 @@
+github.com/gen2brain/beeep v0.0.0-20210529141713-5586760f0cc1 h1:Xh9mvwEmhbdXlRSsgn+N0zj/NqnKvpeqL08oKDHln2s=
+github.com/gen2brain/beeep v0.0.0-20210529141713-5586760f0cc1/go.mod h1:ElSskYZe3oM8kThaHGJ+kiN2yyUMVXMZ7WxF9QqLDS8=
+github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4 h1:qZNfIGkIANxGv/OqtnntR4DfOY2+BgwR60cAcu/i3SE=
+github.com/go-toast/toast v0.0.0-20190211030409-01e6764cf0a4/go.mod h1:kW3HQ4UdaAyrUCSSDR4xUzBKW6O2iA4uHhk7AtyYp10=
+github.com/godbus/dbus/v5 v5.0.3 h1:ZqHaoEF7TBzh4jzPmqVhE/5A1z9of6orkAe5uHoAeME=
+github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
+github.com/gopherjs/gopherjs v0.0.0-20180825215210-0210a2f0f73c h1:16eHWuMGvCjSfgRJKqIzapE78onvvTbdi1rMkU00lZw=
+github.com/gopherjs/gopherjs v0.0.0-20180825215210-0210a2f0f73c/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
+github.com/gopherjs/gopherwasm v1.1.0 h1:fA2uLoctU5+T3OhOn2vYP0DVT6pxc7xhTlBB1paATqQ=
+github.com/gopherjs/gopherwasm v1.1.0/go.mod h1:SkZ8z7CWBz5VXbhJel8TxCmAcsQqzgWGR/8nMhyhZSI=
+github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ=
+github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U=
+github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af h1:6yITBqGTE2lEeTPG04SN9W+iWHCRyHqlVYILiSXziwk=
+github.com/tadvi/systray v0.0.0-20190226123456-11a2b8fa57af/go.mod h1:4F09kP5F+am0jAwlQLddpoMDM+iewkxxt6nxUQ5nq5o=
+golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9 h1:YTzHMGlqJu67/uEo1lBv0n3wBXhXNeUbB1XfN2vmTm0=
+golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..b8e6914
--- /dev/null
+++ b/main.go
@@ -0,0 +1,68 @@
+package main
+
+import (
+ "fmt"
+ "time"
+)
+
+type state int
+
+const (
+ Working state = iota
+ Break
+ LongBreak
+)
+
+var (
+ currentState = Working
+ currentDuration = 25 * 60
+ pomodoros = 1
+)
+
+func main() {
+ for {
+ clearline()
+ switch currentState {
+ case Working:
+ fmt.Printf("🍅 #%d Working (%s)", pomodoros, secondsToMinutes(currentDuration))
+ case Break:
+ fmt.Printf("☕️ #%d Break (%s)", pomodoros, secondsToMinutes(currentDuration))
+ case LongBreak:
+ fmt.Printf("☕️ #%d Long break (%s)", pomodoros, secondsToMinutes(currentDuration))
+ }
+ currentDuration--
+ if currentDuration < 0 {
+ switch currentState {
+ case Working:
+ if pomodoros%4 == 0 {
+ currentState = LongBreak
+ currentDuration = 15 * 60
+ } else {
+ currentState = Break
+ currentDuration = 5 * 60
+ }
+ case Break, LongBreak:
+ currentState = Working
+ currentDuration = 25 * 60
+ pomodoros++
+ }
+ bell()
+ }
+ <-time.After(1 * time.Second)
+ }
+}
+
+func bell() {
+ fmt.Print("\a")
+}
+
+func clearline() {
+ fmt.Print("\x1b[2K\r")
+}
+
+func secondsToMinutes(inSeconds int) string {
+ minutes := inSeconds / 60
+ seconds := inSeconds % 60
+ str := fmt.Sprintf("%02d:%02d", minutes, seconds)
+ return str
+}