Skip to content

Commit

Permalink
Auto start support (tested on Linux)
Browse files Browse the repository at this point in the history
  • Loading branch information
gertjaap committed Jul 22, 2019
1 parent 796e8ac commit 5b143e7
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 2 deletions.
14 changes: 12 additions & 2 deletions frontend/src/components/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
<p style="text-align: left">
<input type="checkbox" v-model="debugging">Enable debugging<br/>
<span class="subtext">Include the miner's console output in the debug log. Can grow your logs quite large</span>
</p>
<p style="text-align: left">
<input type="checkbox" v-model="autoStart">Auto start<br/>
<span class="subtext">Start the One-Click Miner when you log in your computer</span>
</p>
<p style="text-align: left">
<input type="checkbox" v-model="closedSourceMiner">Use closed-source miners<br/>
Expand Down Expand Up @@ -32,12 +36,16 @@ export default {
return {
closedSourceMiner: false,
debugging: false,
autoStart: false,
};
},
created() {
var self = this;
window.backend.MinerCore.GetClosedSource().then(result => {
self.closedSourceMiner = result
});
window.backend.MinerCore.GetAutoStart().then(result => {
self.autoStart = result
});
window.backend.MinerCore.GetDebugging().then(result => {
self.debugging = result
Expand All @@ -48,7 +56,9 @@ export default {
var self = this;
window.backend.MinerCore.SetClosedSource(this.closedSourceMiner).then(result => {
window.backend.MinerCore.SetDebugging(self.debugging).then(result => {
self.$emit('committed');
window.backend.MinerCore.SetAutoStart(self.autoStart).then(result => {
self.$emit('committed');
});
});
});
}
Expand All @@ -73,7 +83,7 @@ export default {
}
span.subtext {
opacity: 0.6;
font-size: 10pt;
font-size: 8pt;
}

</style>
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/vertcoin-project/one-click-miner-vnext
go 1.12

require (
github.com/ProtonMail/go-autostart v0.0.0-20181114175602-c5272053443a
github.com/btcsuite/btcd v0.0.0-20190614013741-962a206e94e9
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d
github.com/btcsuite/fastsha256 v0.0.0-20160815193821-637e65642941
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
github.com/NebulousLabs/go-UpnP v0.0.0-20181203152547-b32978b8ccbf/go.mod h1:T0vQBt4b6iPDbP21SrsJ6e3E3gbPa9LAhWDZB6pFRcg=
github.com/Netflix/go-expect v0.0.0-20180615182759-c93bf25de8e8/go.mod h1:oX5x61PbNXchhh0oikYAH+4Pcfw5LKv21+Jnpr6r6Pc=
github.com/ProtonMail/go-autostart v0.0.0-20181114175602-c5272053443a h1:fXK2KsfnkBV9Nh+9SKzHchYjuE9s0vI20JG1mbtEAcc=
github.com/ProtonMail/go-autostart v0.0.0-20181114175602-c5272053443a/go.mod h1:oTGdE7/DlWIr23G0IKW3OXK9wZ5Hw1GGiaJFccTvZi4=
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
github.com/aead/skein v0.0.0-20160722084837-9365ae6e95d2/go.mod h1:4JBZEId5BaLqvA2DGU53phvwkn2WpeLhNSF79/uKBPs=
github.com/awalterschulze/gographviz v0.0.0-20190221210632-1e9ccb565bca/go.mod h1:GEV5wmg4YquNw7v1kkyoX9etIk8yVmXj+AkDHuuETHs=
Expand Down
8 changes: 8 additions & 0 deletions mining/mining.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,14 @@ func (m *MinerCore) SetDebugging(newDebugging bool) {
m.setSetting("debugging", newDebugging)
}

func (m *MinerCore) GetAutoStart() bool {
return util.GetAutoStart()
}

func (m *MinerCore) SetAutoStart(newAutoStart bool) {
util.SetAutoStart(newAutoStart)
}

func (m *MinerCore) GetVersion() string {
return tracking.GetVersion()
}
Expand Down
40 changes: 40 additions & 0 deletions util/autostart.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package util

import (
"os"
"path/filepath"

"github.com/ProtonMail/go-autostart"
)

var app *autostart.App

func init() {
fullPath, _ := filepath.Abs(os.Args[0])

app = &autostart.App{
Name: "vertcoin-ocm",
DisplayName: "Vertcoin One-Click miner",
Exec: []string{fullPath},
}
}

func GetAutoStart() bool {
return app.IsEnabled()
}

func SetAutoStart(autoStart bool) string {
if autoStart {
err := app.Enable()
if err != nil {
return err.Error()
}
} else {
err := app.Disable()
if err != nil {
return err.Error()
}
}

return ""
}

0 comments on commit 5b143e7

Please sign in to comment.