mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-20 04:33:57 +00:00
324 lines
14 KiB
Diff
324 lines
14 KiB
Diff
From 12a5ccce245f82c334e78d48354e55311c15fb0c Mon Sep 17 00:00:00 2001
|
|
From: rewine <lhongxu@outlook.com>
|
|
Date: Wed, 5 Apr 2023 23:51:58 +0800
|
|
Subject: [PATCH 4/4] aviod-use-hardcode-path
|
|
|
|
---
|
|
accounts/user.go | 2 +-
|
|
accounts/user_chpwd_union_id.go | 9 ++++-----
|
|
bin/backlight_helper/ddcci/ddcci.go | 20 +++++--------------
|
|
bin/dde-authority/fprint_transaction.go | 2 +-
|
|
inputdevices/keyboard.go | 5 +++--
|
|
keybinding/shortcuts/system_shortcut.go | 6 +++---
|
|
keybinding/special_keycode.go | 2 +-
|
|
keybinding/utils.go | 2 +-
|
|
launcher/manager_ifc.go | 2 +-
|
|
.../dde-daemon/keybinding/system_actions.json | 4 ++--
|
|
misc/etc/acpi/powerbtn.sh | 2 +-
|
|
misc/udev-rules/80-deepin-fprintd.rules | 2 +-
|
|
system/display/displaycfg.go | 2 +-
|
|
system/power/manager_lmt.go | 3 ++-
|
|
system/power_manager/utils.go | 2 +-
|
|
system/systeminfo/manager.go | 2 +-
|
|
systeminfo/utils.go | 2 +-
|
|
17 files changed, 30 insertions(+), 39 deletions(-)
|
|
|
|
diff --git a/accounts/user.go b/accounts/user.go
|
|
index f8827fb2..ff604f38 100644
|
|
--- a/accounts/user.go
|
|
+++ b/accounts/user.go
|
|
@@ -450,7 +450,7 @@ func (u *User) checkIsControlCenter(sender dbus.Sender) bool {
|
|
return false
|
|
}
|
|
|
|
- if exe == controlCenterPath {
|
|
+ if strings.Contains(exe, "dde-control-center") {
|
|
return true
|
|
}
|
|
|
|
diff --git a/accounts/user_chpwd_union_id.go b/accounts/user_chpwd_union_id.go
|
|
index b0ba9cb9..e8aa1a1e 100644
|
|
--- a/accounts/user_chpwd_union_id.go
|
|
+++ b/accounts/user_chpwd_union_id.go
|
|
@@ -107,14 +107,13 @@ func newCaller(service *dbusutil.Service, sender dbus.Sender) (ret *caller, err
|
|
|
|
// 只允许来自控制中心, 锁屏和 greetter 的调用
|
|
var app string
|
|
- switch exe {
|
|
- case "/usr/bin/dde-control-center":
|
|
+ if (strings.Contains(exe, "dde-control-center")) {
|
|
app = "control-center"
|
|
- case "/usr/bin/dde-lock":
|
|
+ } else if (strings.Contains(exe, "dde-lock")) {
|
|
app = "lock"
|
|
- case "/usr/bin/lightdm-deepin-greeter":
|
|
+ } else if (strings.Contains(exe, "lightdm-deepin-greeter")) {
|
|
app = "greeter"
|
|
- default:
|
|
+ } else {
|
|
err = fmt.Errorf("set password with Union ID called by %s, which is not allow", exe)
|
|
return
|
|
}
|
|
diff --git a/bin/backlight_helper/ddcci/ddcci.go b/bin/backlight_helper/ddcci/ddcci.go
|
|
index 21653459..01a67e91 100644
|
|
--- a/bin/backlight_helper/ddcci/ddcci.go
|
|
+++ b/bin/backlight_helper/ddcci/ddcci.go
|
|
@@ -15,10 +15,7 @@ import (
|
|
"bytes"
|
|
"encoding/base64"
|
|
"fmt"
|
|
- "os/exec"
|
|
- "path/filepath"
|
|
"reflect"
|
|
- "strings"
|
|
"sync"
|
|
"unsafe"
|
|
|
|
@@ -113,18 +110,11 @@ func newDDCCI() (*ddcci, error) {
|
|
return nil, err
|
|
}
|
|
|
|
- content, err := exec.Command("/usr/bin/dpkg-architecture", "-qDEB_HOST_MULTIARCH").Output() // TODO: arch和rpm打包需要通过patch修改获取路径的方式
|
|
- if err != nil {
|
|
- logger.Warning(err)
|
|
- } else {
|
|
- path := filepath.Join("/usr/lib", strings.TrimSpace(string(content)), "libddcutil.so.0")
|
|
- logger.Debug("so path:", path)
|
|
- cStr := C.CString(path)
|
|
- defer C.free(unsafe.Pointer(cStr))
|
|
- ret := C.InitDDCCISo(cStr)
|
|
- if ret == -2 {
|
|
- logger.Debug("failed to initialize ddca_free_all_displays sym")
|
|
- }
|
|
+ cStr := C.CString("libddcutil.so.0")
|
|
+ defer C.free(unsafe.Pointer(cStr))
|
|
+ ret := C.InitDDCCISo(cStr)
|
|
+ if ret == -2 {
|
|
+ logger.Debug("failed to initialize ddca_free_all_displays sym")
|
|
}
|
|
|
|
return ddc, nil
|
|
diff --git a/bin/dde-authority/fprint_transaction.go b/bin/dde-authority/fprint_transaction.go
|
|
index 0e460ec3..b803d1c9 100644
|
|
--- a/bin/dde-authority/fprint_transaction.go
|
|
+++ b/bin/dde-authority/fprint_transaction.go
|
|
@@ -461,7 +461,7 @@ func (tx *FPrintTransaction) End(sender dbus.Sender) *dbus.Error {
|
|
|
|
func killFPrintDaemon() {
|
|
logger.Debug("kill fprintd")
|
|
- err := exec.Command("pkill", "-f", "/usr/lib/fprintd/fprintd").Run()
|
|
+ err := exec.Command("pkill", "fprintd").Run()
|
|
if err != nil {
|
|
logger.Warning("failed to kill fprintd:", err)
|
|
}
|
|
diff --git a/inputdevices/keyboard.go b/inputdevices/keyboard.go
|
|
index 6d05f662..ca29cecc 100644
|
|
--- a/inputdevices/keyboard.go
|
|
+++ b/inputdevices/keyboard.go
|
|
@@ -10,6 +10,7 @@ import (
|
|
"fmt"
|
|
"os"
|
|
"os/user"
|
|
+ "os/exec"
|
|
"path"
|
|
"regexp"
|
|
"strings"
|
|
@@ -51,7 +52,7 @@ const (
|
|
kbdSystemConfig = "/etc/default/keyboard"
|
|
qtDefaultConfig = ".config/Trolltech.conf"
|
|
|
|
- cmdSetKbd = "/usr/bin/setxkbmap"
|
|
+ cmdSetKbd = "setxkbmap"
|
|
)
|
|
|
|
type Keyboard struct {
|
|
@@ -704,7 +705,7 @@ func (kbd *Keyboard) handlePropertyNotifyEvent(ev *x.PropertyNotifyEvent) {
|
|
}
|
|
|
|
func (kbd *Keyboard) shouldUseDDEKwin() bool {
|
|
- _, err := os.Stat("/usr/bin/kwin_no_scale")
|
|
+ _, err := exec.LookPath("kwin_no_scale")
|
|
return err == nil
|
|
}
|
|
|
|
diff --git a/keybinding/shortcuts/system_shortcut.go b/keybinding/shortcuts/system_shortcut.go
|
|
index 95e1b222..95d82db7 100644
|
|
--- a/keybinding/shortcuts/system_shortcut.go
|
|
+++ b/keybinding/shortcuts/system_shortcut.go
|
|
@@ -83,10 +83,10 @@ var defaultSysActionCmdMap = map[string]string{
|
|
"launcher": "dbus-send --print-reply --dest=com.deepin.dde.Launcher /com/deepin/dde/Launcher com.deepin.dde.Launcher.Toggle",
|
|
"terminal": "/usr/lib/deepin-daemon/default-terminal",
|
|
"terminal-quake": "deepin-terminal --quake-mode",
|
|
- "lock-screen": "originmap=$(setxkbmap -query | grep option | awk -F ' ' '{print $2}');/usr/bin/setxkbmap -option grab:break_actions&&/usr/bin/xdotool key XF86Ungrab&&dbus-send --print-reply --dest=com.deepin.dde.lockFront /com/deepin/dde/lockFront com.deepin.dde.lockFront.Show&&/usr/bin/setxkbmap -option; setxkbmap -option $originmap",
|
|
+ "lock-screen": "originmap=$(setxkbmap -query | grep option | awk -F ' ' '{print $2}');setxkbmap -option grab:break_actions&&xdotool key XF86Ungrab&&dbus-send --print-reply --dest=com.deepin.dde.lockFront /com/deepin/dde/lockFront com.deepin.dde.lockFront.Show&&/usr/bin/setxkbmap -option; setxkbmap -option $originmap",
|
|
"logout": "dbus-send --print-reply --dest=com.deepin.dde.shutdownFront /com/deepin/dde/shutdownFront com.deepin.dde.shutdownFront.Show",
|
|
"deepin-screen-recorder": "dbus-send --print-reply --dest=com.deepin.ScreenRecorder /com/deepin/ScreenRecorder com.deepin.ScreenRecorder.stopRecord",
|
|
- "system-monitor": "/usr/bin/deepin-system-monitor",
|
|
+ "system-monitor": "deepin-system-monitor",
|
|
"color-picker": "dbus-send --print-reply --dest=com.deepin.Picker /com/deepin/Picker com.deepin.Picker.Show",
|
|
// screenshot actions:
|
|
"screenshot": screenshotCmdPrefix + "StartScreenshot",
|
|
@@ -104,7 +104,7 @@ var defaultSysActionCmdMap = map[string]string{
|
|
"global-search": "/usr/libexec/dde-daemon/keybinding/shortcut-dde-grand-search.sh",
|
|
"switch-next-kbd-layout": "dbus-send --print-reply --dest=com.deepin.daemon.Keybinding /com/deepin/daemon/InputDevice/Keyboard com.deepin.daemon.InputDevice.Keyboard.ToggleNextLayout",
|
|
// cmd
|
|
- "calculator": "/usr/bin/deepin-calculator",
|
|
+ "calculator": "deepin-calculator",
|
|
"search": "/usr/libexec/dde-daemon/keybinding/shortcut-dde-grand-search.sh",
|
|
}
|
|
|
|
diff --git a/keybinding/special_keycode.go b/keybinding/special_keycode.go
|
|
index d18c9a66..9704b241 100644
|
|
--- a/keybinding/special_keycode.go
|
|
+++ b/keybinding/special_keycode.go
|
|
@@ -276,7 +276,7 @@ func (m *Manager) handlePower() {
|
|
}
|
|
m.systemTurnOffScreen()
|
|
case powerActionShowUI:
|
|
- cmd := "originmap=$(setxkbmap -query | grep option | awk -F ' ' '{print $2}');/usr/bin/setxkbmap -option grab:break_actions&&/usr/bin/xdotool key XF86Ungrab&&dbus-send --print-reply --dest=com.deepin.dde.lockFront /com/deepin/dde/shutdownFront com.deepin.dde.shutdownFront.Show&&/usr/bin/setxkbmap -option; setxkbmap -option $originmap"
|
|
+ cmd := "originmap=$(setxkbmap -query | grep option | awk -F ' ' '{print $2}');setxkbmap -option grab:break_actions&&xdotool key XF86Ungrab&&dbus-send --print-reply --dest=com.deepin.dde.lockFront /com/deepin/dde/shutdownFront com.deepin.dde.shutdownFront.Show&&setxkbmap -option; setxkbmap -option $originmap"
|
|
go func() {
|
|
locked, err := m.sessionManager.Locked().Get(0)
|
|
if err != nil {
|
|
diff --git a/keybinding/utils.go b/keybinding/utils.go
|
|
index 8e531369..261c88e8 100644
|
|
--- a/keybinding/utils.go
|
|
+++ b/keybinding/utils.go
|
|
@@ -311,7 +311,7 @@ func readTinyFile(file string) ([]byte, error) {
|
|
}
|
|
|
|
func shouldUseDDEKwin() bool {
|
|
- _, err := os.Stat("/usr/bin/kwin_no_scale")
|
|
+ _, err := exec.LookPath("kwin_no_scale")
|
|
return err == nil
|
|
}
|
|
|
|
diff --git a/launcher/manager_ifc.go b/launcher/manager_ifc.go
|
|
index 440aa8e5..ad74f99f 100644
|
|
--- a/launcher/manager_ifc.go
|
|
+++ b/launcher/manager_ifc.go
|
|
@@ -24,7 +24,7 @@ const (
|
|
dbusObjPath = "/com/deepin/dde/daemon/Launcher"
|
|
dbusInterface = dbusServiceName
|
|
desktopMainSection = "Desktop Entry"
|
|
- launcherExecPath = "/usr/bin/dde-launcher"
|
|
+ launcherExecPath = "dde-launcher"
|
|
)
|
|
|
|
var errorInvalidID = errors.New("invalid ID")
|
|
diff --git a/misc/dde-daemon/keybinding/system_actions.json b/misc/dde-daemon/keybinding/system_actions.json
|
|
index 8de3f111..8048048e 100644
|
|
--- a/misc/dde-daemon/keybinding/system_actions.json
|
|
+++ b/misc/dde-daemon/keybinding/system_actions.json
|
|
@@ -13,7 +13,7 @@
|
|
"Action": "dbus-send --print-reply --dest=com.deepin.ScreenRecorder /com/deepin/ScreenRecorder com.deepin.ScreenRecorder.stopRecord"
|
|
},
|
|
{
|
|
- "Action": "/usr/bin/deepin-system-monitor",
|
|
+ "Action": "deepin-system-monitor",
|
|
"Key": "system-monitor"
|
|
},
|
|
{
|
|
@@ -21,7 +21,7 @@
|
|
"Action": "dbus-send --print-reply --dest=com.deepin.Picker /com/deepin/Picker com.deepin.Picker.Show"
|
|
},
|
|
{
|
|
- "Action": "originmap=$(setxkbmap -query | grep option | awk -F ' ' '{print $2}');/usr/bin/setxkbmap -option grab:break_actions&&/usr/bin/xdotool key XF86Ungrab&&dbus-send --print-reply --dest=com.deepin.dde.lockFront /com/deepin/dde/lockFront com.deepin.dde.lockFront.Show&&/usr/bin/setxkbmap -option; setxkbmap -option $originmap",
|
|
+ "Action": "originmap=$(setxkbmap -query | grep option | awk -F ' ' '{print $2}');setxkbmap -option grab:break_actions&&xdotool key XF86Ungrab&&dbus-send --print-reply --dest=com.deepin.dde.lockFront /com/deepin/dde/lockFront com.deepin.dde.lockFront.Show&&setxkbmap -option; setxkbmap -option $originmap",
|
|
"Key": "lock-screen"
|
|
},
|
|
{
|
|
diff --git a/misc/etc/acpi/powerbtn.sh b/misc/etc/acpi/powerbtn.sh
|
|
index 5c536b9e..39c28987 100755
|
|
--- a/misc/etc/acpi/powerbtn.sh
|
|
+++ b/misc/etc/acpi/powerbtn.sh
|
|
@@ -58,4 +58,4 @@ elif test "$XUSER" != "" && test -x /usr/bin/qdbus; then
|
|
fi
|
|
|
|
# If all else failed, just initiate a plain shutdown.
|
|
-/sbin/shutdown -h now "Power button pressed"
|
|
+shutdown -h now "Power button pressed"
|
|
diff --git a/misc/udev-rules/80-deepin-fprintd.rules b/misc/udev-rules/80-deepin-fprintd.rules
|
|
index d3d3554a..9163b91c 100644
|
|
--- a/misc/udev-rules/80-deepin-fprintd.rules
|
|
+++ b/misc/udev-rules/80-deepin-fprintd.rules
|
|
@@ -1 +1 @@
|
|
-SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_interface", ACTION=="add|remove", ENV{LIBFPRINT_DRIVER}!="" RUN+="/usr/bin/dbus-send --system --dest=com.deepin.daemon.Fprintd --print-reply /com/deepin/daemon/Fprintd com.deepin.daemon.Fprintd.TriggerUDevEvent"
|
|
+SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_interface", ACTION=="add|remove", ENV{LIBFPRINT_DRIVER}!="" RUN+="@dbus@/bin/dbus-send --system --dest=com.deepin.daemon.Fprintd --print-reply /com/deepin/daemon/Fprintd com.deepin.daemon.Fprintd.TriggerUDevEvent"
|
|
diff --git a/system/display/displaycfg.go b/system/display/displaycfg.go
|
|
index 57b5871a..5b7757b4 100644
|
|
--- a/system/display/displaycfg.go
|
|
+++ b/system/display/displaycfg.go
|
|
@@ -255,7 +255,7 @@ func (d *Display) doDetectSupportWayland(sender dbus.Sender) (bool, error) {
|
|
return false, err
|
|
}
|
|
var cmd *exec.Cmd
|
|
- if execPath == "/usr/bin/lightdm-deepin-greeter" {
|
|
+ if strings.Contains(execPath, "lightdm-deepin-greeter") {
|
|
cmd = exec.Command("runuser", "-u", "lightdm", "glxinfo") // runuser -u lightdm glxinfo
|
|
} else {
|
|
cmd = exec.Command("glxinfo")
|
|
diff --git a/system/power/manager_lmt.go b/system/power/manager_lmt.go
|
|
index e2bdb2af..baf32fbd 100644
|
|
--- a/system/power/manager_lmt.go
|
|
+++ b/system/power/manager_lmt.go
|
|
@@ -8,6 +8,7 @@ import (
|
|
"bufio"
|
|
"io/ioutil"
|
|
"os"
|
|
+ "os/exec"
|
|
"path/filepath"
|
|
"strings"
|
|
|
|
@@ -28,7 +29,7 @@ const (
|
|
const lowBatteryThreshold = 20.0
|
|
|
|
func isLaptopModeBinOk() bool {
|
|
- _, err := os.Stat(laptopModeBin)
|
|
+ _, err := exec.LookPath("laptop_mode")
|
|
return err == nil
|
|
}
|
|
|
|
diff --git a/system/power_manager/utils.go b/system/power_manager/utils.go
|
|
index 93f433c2..ef603c96 100644
|
|
--- a/system/power_manager/utils.go
|
|
+++ b/system/power_manager/utils.go
|
|
@@ -33,7 +33,7 @@ func canSuspend() bool {
|
|
}
|
|
|
|
func detectVirtualMachine() (string, error) {
|
|
- out, err := exec.Command("/usr/bin/systemd-detect-virt").Output()
|
|
+ out, err := exec.Command("systemd-detect-virt").Output()
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
diff --git a/system/systeminfo/manager.go b/system/systeminfo/manager.go
|
|
index 5525ae36..daab2c44 100644
|
|
--- a/system/systeminfo/manager.go
|
|
+++ b/system/systeminfo/manager.go
|
|
@@ -205,7 +205,7 @@ func filterUnNumber(value string) string {
|
|
|
|
//执行命令:/usr/bin/getconf LONG_BIT 获取系统位数
|
|
func (m *Manager) systemBit() string {
|
|
- output, err := exec.Command("/usr/bin/getconf", "LONG_BIT").Output()
|
|
+ output, err := exec.Command("getconf", "LONG_BIT").Output()
|
|
if err != nil {
|
|
return "64"
|
|
}
|
|
diff --git a/systeminfo/utils.go b/systeminfo/utils.go
|
|
index ed17aeb8..e919fb53 100644
|
|
--- a/systeminfo/utils.go
|
|
+++ b/systeminfo/utils.go
|
|
@@ -39,7 +39,7 @@ func getMemoryFromFile(file string) (uint64, error) {
|
|
|
|
//执行命令:/usr/bin/getconf LONG_BIT 获取系统位数
|
|
func systemBit() string {
|
|
- output, err := exec.Command("/usr/bin/getconf", "LONG_BIT").Output()
|
|
+ output, err := exec.Command("getconf", "LONG_BIT").Output()
|
|
if err != nil {
|
|
return "64"
|
|
}
|
|
--
|
|
2.39.2
|
|
|