Merge pull request #4 from prashantgupta24/app

Making the app folder
This commit is contained in:
Prashant Gupta 2019-03-27 18:26:47 -07:00 committed by GitHub
commit 7cf54ae179
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 1532 additions and 11 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
vendor/
bin/

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 Prashant Gupta
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,5 +1,29 @@
all: open
build: clean
mkdir -p -v ./bin/amm.app/Contents/Resources
mkdir -p -v ./bin/amm.app/Contents/MacOS
cp ./appInfo/*.plist ./bin/amm.app/Contents/Info.plist
cp ./appInfo/*.icns ./bin/amm.app/Contents/Resources/icon.icns
go build -o ./bin/amm.app/Contents/MacOS/amm cmd/main.go
open: build
open ./bin
clean:
rm -rf ./bin
start:
go run cmd/main.go
test:
go test -v -race -failfast ./...
vet:
go vet $(shell glide nv)
lint:
go list ./... | grep -v vendor | xargs -L1 golint -set_exit_status
.PHONY: build
.PHONY: clean

1
README.md Normal file
View File

@ -0,0 +1 @@
## Presenting the minimalistic Automatic-Mouse-Mover(AMM) app!

16
appInfo/Info.plist Normal file
View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleExecutable</key>
<string>amm</string>
<key>CFBundleIconFile</key>
<string>icon.icns</string>
<key>CFBundleIdentifier</key>
<string>com.pg.amm</string>
<key>NSHighResolutionCapable</key>
<true/>
<key>LSUIElement</key>
<true/>
</dict>
</plist>

BIN
appInfo/icon.icns Normal file

Binary file not shown.

1456
assets/icon/trayIcon.go Normal file

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,7 @@ import (
"fmt"
"github.com/getlantern/systray"
"github.com/getlantern/systray/example/icon"
"github.com/prashantgupta24/automatic-mouse-mover/assets/icon"
"github.com/prashantgupta24/automatic-mouse-mover/pkg/mousemover"
)
@ -15,7 +15,6 @@ func main() {
func onReady() {
go func() {
systray.SetIcon(icon.Data)
systray.SetTitle("AMM")
ammStart := systray.AddMenuItem("Start", "start the app")
ammStop := systray.AddMenuItem("Stop", "stop the app")
systray.AddSeparator()

View File

@ -9,9 +9,10 @@ import (
"github.com/prashantgupta24/activity-tracker/pkg/tracker"
)
var instance *mouseMover
var instance *MouseMover
type mouseMover struct {
//MouseMover is the main struct for the app
type MouseMover struct {
quit chan struct{}
isRunning bool
}
@ -20,7 +21,8 @@ const (
timeout = 100 //ms
)
func (m *mouseMover) Start() {
//Start the main app
func (m *MouseMover) Start() {
m.quit = make(chan struct{})
frequency := 5 //value always in seconds
@ -31,7 +33,7 @@ func (m *mouseMover) Start() {
heartbeatCh := activityTracker.Start()
go func(m *mouseMover) {
go func(m *MouseMover) {
m.isRunning = true
movePixel := 10
for {
@ -70,7 +72,8 @@ func moveMouse(movePixel int, commCh chan bool) {
commCh <- true
}
func (m *mouseMover) Quit() {
//Quit the app
func (m *MouseMover) Quit() {
//making it idempotent
if m != nil && m.isRunning {
m.quit <- struct{}{}
@ -78,9 +81,9 @@ func (m *mouseMover) Quit() {
}
//GetInstance gets the singleton instance for mouse mover app
func GetInstance() *mouseMover {
func GetInstance() *MouseMover {
if instance == nil {
instance = &mouseMover{}
instance = &MouseMover{}
}
return instance
}