Skip to content

Commit

Permalink
deepin.dde-daemon: init at 5.14.122
Browse files Browse the repository at this point in the history
  • Loading branch information
wineee committed Feb 27, 2023
1 parent af735e7 commit 5781f2e
Show file tree
Hide file tree
Showing 6 changed files with 698 additions and 0 deletions.
42 changes: 42 additions & 0 deletions pkgs/desktops/deepin/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,47 @@ let
--replace "${x}" "${y}"
done
'';

getPatchFrom = commonRp:
let
rpstr = s1: s2: " --replace " + lib.strings.escapeShellArgs [ s1 s2 ];
# rpstr "t1" "t2" => " --replace 't1' 't2'"
rpstrL = l: if lib.length l == 2 then rpstr (lib.head l) (lib.last l) else (throw "input must be a list of 2 string: [ s1 s2 ]");
# rpstrL [ "t1" "t2" ] => rpstr "t1" "t2"
rpfile = filePath: replaceLists:
"substituteInPlace ${filePath}" + lib.concatMapStrings rpstrL replaceLists;
# rpfile "filepath1" [ [ "v1" "v2" ] [ "t1" "t2" ] ]
# => "substituteInPlace filepath1" + (rpstrL [ "v1" "v2" ] + rpstrL [ "t1" "t2" ])
# => "substituteInPlace filepath1 --replace 'v1' 'v2' --replace 't1' 't2'"
in
x: lib.pipe x [
(x: lib.mapAttrs (name: value: value ++ commonRp) x)
# insert commonRp to patch list for each file
(x: lib.mapAttrsToList (name: value: rpfile name value) x)
# convert `filepath = patch list` to patch phase using substituteInPlace
(lib.concatStringsSep "\n")
# connect different file's patch phase with spaces as intervals
(s: s + "\n")
# put a newline at the end of patch phase
];

/* Use a structure-specific AttrSet to generate patch phase (a string containing substituteInPlace)
Example:
getPatchFrom [ [ "s1" "s2" ] ] {
"filepath1" = [ [ "v1" "v2" ] [ "t1" "t2" ] ];
"filepath2" = [ ];
}
=> ''
substituteInPlace filepath1 --replace 'v1' 'v2' --replace 't1' 't2' --replace 's1' 's2'
substituteInPlace filepath2 --replace 's1' 's2'
''
Type:
getPatchFrom :: [ [ String ] ] -> AttrSet -> String
*/

getUsrPatchFrom = getPatchFrom [ [ "/usr" "${placeholder "out"}" ] ];

in {
#### LIBRARIES
dtkcommon = callPackage ./library/dtkcommon { };
Expand Down Expand Up @@ -52,6 +93,7 @@ let
go-gir-generator = callPackage ./go-package/go-gir-generator { };
go-dbus-factory = callPackage ./go-package/go-dbus-factory { };
dde-api = callPackage ./go-package/dde-api { inherit replaceAll; };
dde-daemon = callPackage ./go-package/dde-daemon { inherit replaceAll getUsrPatchFrom; };
deepin-pw-check = callPackage ./go-package/deepin-pw-check { };

#### TOOLS
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
diff --git a/dock/process_info.go b/dock/process_info.go
index 83c61d58..e2970f3a 100644
--- a/dock/process_info.go
+++ b/dock/process_info.go
@@ -119,6 +119,16 @@ func verifyExe(exe, cwd, firstArg string) bool {
return false
}
logger.Debugf("firstArgPath: %q", firstArgPath)
+ if exe == firstArgPath {
+ return true
+ }
+ if strings.HasSuffix(exe, "-wrapped") {
+ exeBase := filepath.Base(exe)
+ if (len(exeBase) <= 9) {
+ return false
+ }
+ exe = exe[0:len(exe)-len(exeBase)] + exeBase[1:len(exeBase)-8]
+ }
return exe == firstArgPath
}

27 changes: 27 additions & 0 deletions pkgs/desktops/deepin/go-package/dde-daemon/0002-dont-set-PATH.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
diff --git a/bin/dde-system-daemon/main.go b/bin/dde-system-daemon/main.go
index e39fa46b..95461df1 100644
--- a/bin/dde-system-daemon/main.go
+++ b/bin/dde-system-daemon/main.go
@@ -78,10 +78,6 @@ func main() {
// fix no PATH when was launched by dbus
if os.Getenv("PATH") == "" {
logger.Warning("No PATH found, manual special")
- err = os.Setenv("PATH", "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin")
- if err != nil {
- logger.Warning(err)
- }
}

// 系统级服务,无需设置LANG和LANGUAGE,保证翻译不受到影响
diff --git a/grub2/modify_manger.go b/grub2/modify_manger.go
index a811770b..30e9561e 100644
--- a/grub2/modify_manger.go
+++ b/grub2/modify_manger.go
@@ -21,7 +21,6 @@ const (
)

func init() {
- _ = os.Setenv("PATH", "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin")
}

type modifyManager struct {
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
diff --git a/accounts/user.go b/accounts/user.go
index 900033c6..f8827fb2 100644
--- a/accounts/user.go
+++ b/accounts/user.go
@@ -15,6 +15,7 @@ import (
"strings"
"sync"

+ "github.com/adrg/xdg"
dbus "github.com/godbus/dbus"
"github.com/linuxdeepin/dde-daemon/accounts/users"
authenticate "github.com/linuxdeepin/go-dbus-factory/com.deepin.daemon.authenticate"
@@ -649,7 +650,12 @@ func getUserSession(homeDir string) string {
}

func getSessionList() []string {
- fileInfoList, err := ioutil.ReadDir("/usr/share/xsessions")
+ xsessionPath, err := xdg.SearchDataFile("xsessions")
+ if err != nil {
+ return nil;
+ }
+
+ fileInfoList, err := ioutil.ReadDir(xsessionPath)
if err != nil {
return nil
}
diff --git a/appearance/fsnotify.go b/appearance/fsnotify.go
index a409d0ba..ff674600 100644
--- a/appearance/fsnotify.go
+++ b/appearance/fsnotify.go
@@ -5,12 +5,15 @@
package appearance

import (
+ "errors"
+ "io/fs"
"os"
"path"
"path/filepath"
"strings"
"time"

+ "github.com/adrg/xdg"
"github.com/fsnotify/fsnotify"
"github.com/linuxdeepin/dde-daemon/appearance/background"
"github.com/linuxdeepin/dde-daemon/appearance/subthemes"
@@ -100,9 +103,14 @@ func (m *Manager) watchGtkDirs() {
gtkDirs = []string{
path.Join(home, ".local/share/themes"),
path.Join(home, ".themes"),
- "/usr/local/share/themes",
- "/usr/share/themes",
}
+ for _, dataPath := range xdg.DataDirs {
+ gtkPath := filepath.Join(dataPath, "themes");
+ if _, err := os.Stat(gtkPath); err != nil && errors.Is(err, fs.ErrNotExist) {
+ continue
+ }
+ gtkDirs = append(gtkDirs, gtkPath);
+ }

m.watchDirs(gtkDirs)
}
@@ -112,9 +120,14 @@ func (m *Manager) watchIconDirs() {
iconDirs = []string{
path.Join(home, ".local/share/icons"),
path.Join(home, ".icons"),
- "/usr/local/share/icons",
- "/usr/share/icons",
}
+ for _, dataPath := range xdg.DataDirs {
+ iconPath := filepath.Join(dataPath, "icons");
+ if _, err := os.Stat(iconPath); err != nil && errors.Is(err, fs.ErrNotExist) {
+ continue
+ }
+ iconDirs = append(iconDirs, iconPath);
+ }

m.watchDirs(iconDirs)
}
diff --git a/apps/utils.go b/apps/utils.go
index 8863d6c2..dd6f8e16 100644
--- a/apps/utils.go
+++ b/apps/utils.go
@@ -11,6 +11,7 @@ import (
"strconv"
"strings"
"syscall"
+ "github.com/adrg/xdg"
)

func intSliceContains(slice []int, a int) bool {
@@ -96,7 +97,7 @@ func removeDesktopExt(name string) string {
}

func getSystemDataDirs() []string {
- return []string{"/usr/share", "/usr/local/share"}
+ return xdg.DataDirs
}

// get user home
Loading

0 comments on commit 5781f2e

Please sign in to comment.