Skip to content

Commit

Permalink
Revert "fix: keybinding cmd split error"
Browse files Browse the repository at this point in the history
wrong fix

This reverts commit b6a01e5.
  • Loading branch information
Decodetalkers committed Jan 26, 2024
1 parent 44049c1 commit 10e836e
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
dde-daemon (6.0.34) unstable; urgency=medium

* revert fix for keybinding for linglong

-- chenhongtao <chenhongtao@deepin.org> Fri, 26 Jan 2024 16:31:11 +0800

dde-daemon (6.0.33) unstable; urgency=medium

* fix: keybinding cmd split error
Expand Down
24 changes: 12 additions & 12 deletions keybinding/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
package keybinding

import (
"fmt"
"os"
"os/exec"
"path"
"path/filepath"
"strings"
"time"
Expand Down Expand Up @@ -554,7 +554,7 @@ func (m *Manager) listenGlobalAccel(sessionBus *dbus.Conn) error {
logger.Warning(err)
}
} else {
err := m.execCmd(m.shortcutCmd, true)
err := m.execCmd("",m.shortcutCmd, true)
if err != nil {
logger.Warning(err)
}
Expand Down Expand Up @@ -729,14 +729,14 @@ func (m *Manager) handleKeyEventByWayland(changKey string) {
case powerActionShowUI:
cmd := "dde-shutdown"
go func() {
err := m.execCmd(cmd, false)
err := m.execCmd("",cmd, false)
if err != nil {
logger.Warning("execCmd error:", err)
}
}()
}
} else if action.Type == shortcuts.ActionTypeShowControlCenter {
err := m.execCmd("dbus-send --session --dest=org.deepin.dde.ControlCenter1 --print-reply /org/deepin/dde/ControlCenter1 org.deepin.dde.ControlCenter1.Show",
err := m.execCmd("","dbus-send --session --dest=org.deepin.dde.ControlCenter1 --print-reply /org/deepin/dde/ControlCenter1 org.deepin.dde.ControlCenter1.Show",
false)
if err != nil {
logger.Warning("failed to show control center:", err)
Expand Down Expand Up @@ -1124,7 +1124,7 @@ func checkProRunning(serverName string) bool {
return pid != ""
}

func (m *Manager) execCmd(cmd string, viaStartdde bool) error {
func (m *Manager) execCmd(customName string, cmd string, viaStartdde bool) error {
if cmd == "" {
logger.Debug("cmd is empty")
return nil
Expand All @@ -1135,18 +1135,18 @@ func (m *Manager) execCmd(cmd string, viaStartdde bool) error {
return exec.Command("/bin/sh", "-c", cmd).Run()
}

logger.Info(customName)

logger.Debug("exec run cmd:", cmd)

if m.useNewAppManager {
desktopExt := ".desktop"
splitStr := strings.Split(cmd, " ")
if len(splitStr) == 0 {
err := fmt.Errorf("invalid command: %s", splitStr)
return err
name := ""
if customName != "" {
name = "Custom-" + customName;
} else {
name = strings.TrimSuffix(filepath.Base(cmd), path.Ext(cmd))
}

name := splitStr[len(splitStr)-1]

desktopFileName := "daemon-keybinding-" + name + desktopExt

_, err := os.Stat(basedir.GetUserDataDir() + "/applications/" + desktopFileName)
Expand Down
5 changes: 3 additions & 2 deletions keybinding/manager_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func (m *Manager) initHandlers() {
m.lastExecCmdTime = now
}

shortCutName := ev.Shortcut.GetName();
action := ev.Shortcut.GetAction()
arg, ok := action.Arg.(*ActionExecCmdArg)
if !ok {
Expand All @@ -61,7 +62,7 @@ func (m *Manager) initHandlers() {
}

go func() {
err := m.execCmd(arg.Cmd, true)
err := m.execCmd(shortCutName,arg.Cmd, true)
if err != nil {
logger.Warning("execCmd error:", arg.Cmd, err)
}
Expand Down Expand Up @@ -173,7 +174,7 @@ func (m *Manager) initHandlers() {
}

m.handlers[ActionTypeShowControlCenter] = func(ev *KeyEvent) {
err := m.execCmd("dbus-send --session --dest=org.deepin.dde.ControlCenter1 --print-reply /org/deepin/dde/ControlCenter1 org.deepin.dde.ControlCenter1.Show",
err := m.execCmd("","dbus-send --session --dest=org.deepin.dde.ControlCenter1 --print-reply /org/deepin/dde/ControlCenter1 org.deepin.dde.ControlCenter1.Show",
false)
if err != nil {
logger.Warning("failed to show control center:", err)
Expand Down
4 changes: 2 additions & 2 deletions keybinding/special_keycode.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func (m *Manager) handleMicMute() {
// 打开控制中心
func (m *Manager) handleOpenControlCenter() {
cmd := "dbus-send --session --dest=org.deepin.dde.ControlCenter1 --print-reply /org/deepin/dde/ControlCenter1 org.deepin.dde.ControlCenter1.Show"
m.execCmd(cmd, false)
m.execCmd("",cmd, false)
}

// 锁屏
Expand Down Expand Up @@ -283,7 +283,7 @@ func (m *Manager) handlePower() {
logger.Warning("sessionManager get locked error:", err)
}
if !locked {
err = m.execCmd(cmd, false)
err = m.execCmd("",cmd, false)
if err != nil {
logger.Warning("execCmd error:", err)
}
Expand Down

0 comments on commit 10e836e

Please sign in to comment.