Skip to content

Commit

Permalink
New feature: set process priority on startup (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
tzerk committed Mar 19, 2017
1 parent 1146a2c commit 28fd458
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
5 changes: 4 additions & 1 deletion config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ stayalive: false
process: BlackDesert64.exe
timebetweenchecksins: 60
faillimit: 2
shutdownondc: false

# These settings require the .exe to be run with admin rights!
killondc: true
shutdownondc: false
killcoherentui: false

# Set the process priority. Allowed values are: idle, below normal, normal, above normal, high priority, realtime
# Also requires admin rights!
processpriority: normal
7 changes: 6 additions & 1 deletion lib/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type Config struct {
KillOnDC bool
ShutdownOnDC bool
KillCoherentUI bool
ProcessPriority string
}

func Read_Settings(ex string) (config Config, err error) {
Expand Down Expand Up @@ -63,7 +64,11 @@ func Read_Settings(ex string) (config Config, err error) {
"# These settings require the .exe to be run with admin rights! \r\n" +
"killondc: true\r\n" +
"shutdownondc: false\r\n" +
"killcoherentui: false"
"killcoherentui: false\r\n" +
"\r\n" +
"# Set the process priority. Allowed values are: idle, below normal, normal, above normal, high priority, realtime\r\n" +
"# Also requires admin rights!\r\n" +
"processpriority: normal"
ioutil.WriteFile("config.yml", []byte(defconf), os.FileMode(int(0777)))
panic(err)
}
Expand Down
6 changes: 6 additions & 0 deletions lib/watchdog.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ func Watchdog(
label_Update *ui.Label,
pb *ui.ProgressBar) {

// SET Process Priority
if (config.ProcessPriority != "normal") {
exec.Command("cmd", "/C", "wmic", "process", "where", "name='" + config.Process + "'", "CALL", "setpriority", config.ProcessPriority).Run()
}

// KILL CoherentUI_Host.exe
if config.KillCoherentUI {
err := killCoherentUI()
Expand Down Expand Up @@ -73,6 +78,7 @@ func Watchdog(
log.Println(err)
}


// Kill the process
err = proc.Kill()
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func main() {
box_settings.Append(ui.NewLabel("Kill process after disconnect: " + strconv.FormatBool(config.KillOnDC)), false)
box_settings.Append(ui.NewLabel("Shutdown PC after disconnect: " + strconv.FormatBool(config.ShutdownOnDC) ), false)
box_settings.Append(ui.NewLabel("Kill CoherenUI_Host.exe: " + strconv.FormatBool(config.KillCoherentUI)), false)
box_settings.Append(ui.NewLabel("Process Priority: " + config.ProcessPriority), false)

// Append UI elements for about tab
box_about.Append(ui.NewLabel("Version " + VERSION), false)
Expand Down

0 comments on commit 28fd458

Please sign in to comment.