File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55package keybinding
66
77import (
8+ "crypto/sha256"
9+ "encoding/hex"
810 "os"
911 "os/exec"
10- "path"
1112 "path/filepath"
1213 "strings"
1314 "time"
@@ -1139,10 +1140,17 @@ func (m *Manager) execCmd(cmd string, viaStartdde bool) error {
11391140
11401141 if m .useNewAppManager {
11411142 desktopExt := ".desktop"
1142- name := strings .TrimSuffix (filepath .Base (cmd ), path .Ext (cmd ))
1143+ sha256Hasher := sha256 .New ()
1144+ _ , err := sha256Hasher .Write ([]byte (cmd ))
1145+ if err != nil {
1146+ logger .Warning ("generate sha256 hash failed with error: " , err )
1147+ return err
1148+ }
1149+ desktopPre := sha256Hasher .Sum (nil )
1150+ name := hex .EncodeToString (desktopPre )
11431151 desktopFileName := "daemon-keybinding-" + name + desktopExt
11441152
1145- _ , err : = os .Stat (basedir .GetUserDataDir () + "/applications/" + desktopFileName )
1153+ _ , err = os .Stat (basedir .GetUserDataDir () + "/applications/" + desktopFileName )
11461154 // 如果对应命令的desktop文件不存在,需要新建desktop文件
11471155 if os .IsNotExist (err ) {
11481156 desktopInfoMap := map [string ]dbus.Variant {
You can’t perform that action at this time.
0 commit comments