]> 127.0.0.1 Git - part/.git/commitdiff
fix v0.7.0
authorqydysky <qydysky@foxmail.com>
Sun, 8 May 2022 03:01:48 +0000 (11:01 +0800)
committerqydysky <qydysky@foxmail.com>
Sun, 8 May 2022 03:01:48 +0000 (11:01 +0800)
Sys.go
linuxwin/linux.go

diff --git a/Sys.go b/Sys.go
index 2fb76aa5303f2233d982c7ab0528ad17eac72ef9..92117cc60717db8c1b030423889e71fd36440375 100644 (file)
--- a/Sys.go
+++ b/Sys.go
@@ -187,9 +187,5 @@ func (this *sys) GetCpuPercent() (float64, error) {
 }
 
 func (this *sys) PreventSleep() (stop *signal.Signal) {
-       if !this.GetSys("windows") {
-               return
-       }
-
        return Ppart.PreventSleep()
 }
index 18745d9da194ee7f75bcd4c599efc119aed16b13..9f21e9fb24f1d600751121ed942b2f648fa1dc9d 100755 (executable)
@@ -1,66 +1,88 @@
+//go:build linux
 // +build linux
 
 package Ppart
 
 import (
-    "os"
-    "os/exec"
-    "strings"
-    "strconv"
-    "path/filepath"
+       "os"
+       "os/exec"
+       "path/filepath"
+       "strconv"
+       "strings"
+
+       signal "github.com/qydysky/part/signal"
 )
 
-func PCheck(pros []string) []int{
-       res:=[]int{}
-    _pros:=[][]byte{}
+func PCheck(pros []string) []int {
+       res := []int{}
+       _pros := [][]byte{}
 
-    for _,v:= range pros{
-        if v=="" {return res}
-        _pros=append(_pros,[]byte(v))
-        res=append(res,0)
-    }
+       for _, v := range pros {
+               if v == "" {
+                       return res
+               }
+               _pros = append(_pros, []byte(v))
+               res = append(res, 0)
+       }
 
-    for j,i :=range _pros{
-        cmd := exec.Command("pgrep","-c",string(i))
-        output, _ := cmd.Output()
-        outputt:=strings.Replace(string(output), "\n", "", -1)
-        res[j],_=strconv.Atoi(outputt)
-    }
-    return res
+       for j, i := range _pros {
+               cmd := exec.Command("pgrep", "-c", string(i))
+               output, _ := cmd.Output()
+               outputt := strings.Replace(string(output), "\n", "", -1)
+               res[j], _ = strconv.Atoi(outputt)
+       }
+       return res
 }
 
-func PStartf(pro []*exec.Cmd){
-    for i := range pro {
-        pro[i].Start()
-    }
+func PStartf(pro []*exec.Cmd) {
+       for i := range pro {
+               pro[i].Start()
+       }
 }
 
-func PRun(hide bool,prog string,cmd ...string) error {
-    p:=exec.Command(prog,cmd...)
-    if hide {}
-    e:=p.Run()
-    return e
+func PRun(hide bool, prog string, cmd ...string) error {
+       p := exec.Command(prog, cmd...)
+       if hide {
+       }
+       e := p.Run()
+       return e
 }
 
-func Cdir()string{
-    dir, _ := os.Executable()
-    exPath := filepath.Dir(dir)
-    return exPath
+func Cdir() string {
+       dir, _ := os.Executable()
+       exPath := filepath.Dir(dir)
+       return exPath
 }
 
 func PProxy(s, pacUrl string) error {
-    if s=="off" {
-        if e:=PRun(true,"gsettings","set","org.gnome.system.proxy","mode","none");e!=nil{return e}
-        if e:=PRun(true,"kwriteconfig5","--file","kioslaverc","--group","Proxy Settings","--key","ProxyType","0");e!=nil{return e}
-    }else{
-        if e:=PRun(true,"gsettings","set","org.gnome.system.proxy","autoconfig-url",pacUrl);e!=nil{return e}
-        if e:=PRun(true,"gsettings","set","org.gnome.system.proxy","mode","auto");e!=nil{return e}
-        if e:=PRun(true,"kwriteconfig5","--file","kioslaverc","--group","Proxy Settings","--key","ProxyType","2");e!=nil{return e}
-        if e:=PRun(true,"kwriteconfig5","--file","kioslaverc","--group","Proxy Settings","--key","Proxy Config Script",pacUrl);e!=nil{return e}
-    }
-    return nil
+       if s == "off" {
+               if e := PRun(true, "gsettings", "set", "org.gnome.system.proxy", "mode", "none"); e != nil {
+                       return e
+               }
+               if e := PRun(true, "kwriteconfig5", "--file", "kioslaverc", "--group", "Proxy Settings", "--key", "ProxyType", "0"); e != nil {
+                       return e
+               }
+       } else {
+               if e := PRun(true, "gsettings", "set", "org.gnome.system.proxy", "autoconfig-url", pacUrl); e != nil {
+                       return e
+               }
+               if e := PRun(true, "gsettings", "set", "org.gnome.system.proxy", "mode", "auto"); e != nil {
+                       return e
+               }
+               if e := PRun(true, "kwriteconfig5", "--file", "kioslaverc", "--group", "Proxy Settings", "--key", "ProxyType", "2"); e != nil {
+                       return e
+               }
+               if e := PRun(true, "kwriteconfig5", "--file", "kioslaverc", "--group", "Proxy Settings", "--key", "Proxy Config Script", pacUrl); e != nil {
+                       return e
+               }
+       }
+       return nil
+}
+
+func FileMove(src, trg string) error {
+       return os.Rename(src, trg)
 }
 
-func FileMove(src,trg string) error {
-    return os.Rename(src,trg)
-}
\ No newline at end of file
+func PreventSleep() (stop *signal.Signal) {
+       return nil
+}