mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-05-03 02:52:07 -04:00
Compare commits
3 Commits
222187d8a6
...
v1.4.4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1f64bb8031 | ||
|
|
eea7d12c0b | ||
|
|
85173126f4 |
@@ -135,6 +135,42 @@ func (a *ArchDistribution) packageInstalled(pkg string) bool {
|
||||
return err == nil
|
||||
}
|
||||
|
||||
// parseSRCINFODeps reads a .SRCINFO file and returns runtime dep and makedep package
|
||||
func parseSRCINFODeps(srcinfoPath string) (deps []string, makedeps []string, err error) {
|
||||
data, err := os.ReadFile(srcinfoPath)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
for _, line := range strings.Split(string(data), "\n") {
|
||||
line = strings.TrimSpace(line)
|
||||
var pkg string
|
||||
var target *[]string
|
||||
switch {
|
||||
case strings.HasPrefix(line, "makedepends = "):
|
||||
pkg = strings.TrimPrefix(line, "makedepends = ")
|
||||
target = &makedeps
|
||||
case strings.HasPrefix(line, "depends = "):
|
||||
pkg = strings.TrimPrefix(line, "depends = ")
|
||||
target = &deps
|
||||
default:
|
||||
continue
|
||||
}
|
||||
// Strip version constraint (>=, <=, >, <, =) and colon-descriptions
|
||||
if idx := strings.IndexAny(pkg, "><:="); idx >= 0 {
|
||||
pkg = pkg[:idx]
|
||||
}
|
||||
pkg = strings.TrimSpace(pkg)
|
||||
if pkg != "" {
|
||||
*target = append(*target, pkg)
|
||||
}
|
||||
}
|
||||
return deps, makedeps, nil
|
||||
}
|
||||
|
||||
func (a *ArchDistribution) isInSystemRepo(pkg string) bool {
|
||||
return exec.Command("pacman", "-Si", pkg).Run() == nil
|
||||
}
|
||||
|
||||
func (a *ArchDistribution) GetPackageMapping(wm deps.WindowManager) map[string]PackageMapping {
|
||||
return a.GetPackageMappingWithVariants(wm, make(map[string]deps.PackageVariant))
|
||||
}
|
||||
@@ -524,6 +560,16 @@ func (a *ArchDistribution) reorderAURPackages(packages []string) []string {
|
||||
}
|
||||
|
||||
func (a *ArchDistribution) installSingleAURPackage(ctx context.Context, pkg, sudoPassword string, progressChan chan<- InstallProgressMsg, startProgress, endProgress float64) error {
|
||||
return a.installSingleAURPackageInternal(ctx, pkg, sudoPassword, progressChan, startProgress, endProgress, make(map[string]bool))
|
||||
}
|
||||
|
||||
func (a *ArchDistribution) installSingleAURPackageInternal(ctx context.Context, pkg, sudoPassword string, progressChan chan<- InstallProgressMsg, startProgress, endProgress float64, visited map[string]bool) error {
|
||||
if visited[pkg] {
|
||||
a.log(fmt.Sprintf("Skipping %s (already being installed, cycle detected)", pkg))
|
||||
return nil
|
||||
}
|
||||
visited[pkg] = true
|
||||
|
||||
homeDir, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to get user home directory: %w", err)
|
||||
@@ -610,39 +656,61 @@ func (a *ArchDistribution) installSingleAURPackage(ctx context.Context, pkg, sud
|
||||
progressChan <- InstallProgressMsg{
|
||||
Phase: PhaseAURPackages,
|
||||
Progress: startProgress + 0.3*(endProgress-startProgress),
|
||||
Step: fmt.Sprintf("Installing dependencies for %s...", pkg),
|
||||
Step: fmt.Sprintf("Resolving dependencies for %s...", pkg),
|
||||
IsComplete: false,
|
||||
CommandInfo: "Installing package dependencies and makedepends",
|
||||
CommandInfo: "Classifying dependencies as system or AUR",
|
||||
}
|
||||
|
||||
// Install dependencies from .SRCINFO
|
||||
depFilter := ""
|
||||
if pkg == "dms-shell-git" {
|
||||
depFilter = ` | sed -E 's/[[:space:]]*(quickshell|dgop)[[:space:]]*/ /g' | tr -s ' '`
|
||||
runtimeDeps, makeDeps, err := parseSRCINFODeps(srcinfoPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to parse .SRCINFO for %s: %w", pkg, err)
|
||||
}
|
||||
|
||||
depsCmd := exec.CommandContext(ctx, "bash", "-c",
|
||||
fmt.Sprintf(`
|
||||
deps=$(grep "depends = " "%s" | grep -v "makedepends" | sed 's/.*depends = //' | tr '\n' ' ' %s | sed 's/[[:space:]]*$//')
|
||||
if [ ! -z "$deps" ] && [ "$deps" != " " ]; then
|
||||
echo '%s' | sudo -S pacman -S --needed --noconfirm $deps
|
||||
fi
|
||||
`, srcinfoPath, depFilter, sudoPassword))
|
||||
seen := make(map[string]bool)
|
||||
var systemPkgs []string
|
||||
var aurPkgs []string
|
||||
|
||||
if err := a.runWithProgress(depsCmd, progressChan, PhaseAURPackages, startProgress+0.3*(endProgress-startProgress), startProgress+0.35*(endProgress-startProgress)); err != nil {
|
||||
return fmt.Errorf("FAILED to install runtime dependencies for %s: %w", pkg, err)
|
||||
for _, dep := range append(runtimeDeps, makeDeps...) {
|
||||
if seen[dep] || a.packageInstalled(dep) {
|
||||
continue
|
||||
}
|
||||
seen[dep] = true
|
||||
if a.isInSystemRepo(dep) {
|
||||
systemPkgs = append(systemPkgs, dep)
|
||||
} else {
|
||||
aurPkgs = append(aurPkgs, dep)
|
||||
}
|
||||
}
|
||||
|
||||
makedepsCmd := exec.CommandContext(ctx, "bash", "-c",
|
||||
fmt.Sprintf(`
|
||||
makedeps=$(grep -E "^[[:space:]]*makedepends = " "%s" | sed 's/^[[:space:]]*makedepends = //' | tr '\n' ' ')
|
||||
if [ ! -z "$makedeps" ]; then
|
||||
echo '%s' | sudo -S pacman -S --needed --noconfirm $makedeps
|
||||
fi
|
||||
`, srcinfoPath, sudoPassword))
|
||||
if len(systemPkgs) > 0 {
|
||||
progressChan <- InstallProgressMsg{
|
||||
Phase: PhaseAURPackages,
|
||||
Progress: startProgress + 0.32*(endProgress-startProgress),
|
||||
Step: fmt.Sprintf("Installing %d system dependencies for %s...", len(systemPkgs), pkg),
|
||||
IsComplete: false,
|
||||
CommandInfo: fmt.Sprintf("sudo pacman -S --needed --noconfirm %s", strings.Join(systemPkgs, " ")),
|
||||
}
|
||||
if err := a.installSystemPackages(ctx, systemPkgs, sudoPassword, progressChan); err != nil {
|
||||
return fmt.Errorf("failed to install system dependencies for %s: %w", pkg, err)
|
||||
}
|
||||
}
|
||||
|
||||
if err := a.runWithProgress(makedepsCmd, progressChan, PhaseAURPackages, startProgress+0.35*(endProgress-startProgress), startProgress+0.4*(endProgress-startProgress)); err != nil {
|
||||
return fmt.Errorf("FAILED to install make dependencies for %s: %w", pkg, err)
|
||||
for _, aurDep := range aurPkgs {
|
||||
a.log(fmt.Sprintf("Dependency %s is AUR-only, building from source...", aurDep))
|
||||
progressChan <- InstallProgressMsg{
|
||||
Phase: PhaseAURPackages,
|
||||
Progress: startProgress + 0.35*(endProgress-startProgress),
|
||||
Step: fmt.Sprintf("Installing AUR dependency %s for %s...", aurDep, pkg),
|
||||
IsComplete: false,
|
||||
CommandInfo: fmt.Sprintf("Building AUR dependency: %s", aurDep),
|
||||
}
|
||||
if err := a.installSingleAURPackageInternal(ctx, aurDep, sudoPassword, progressChan,
|
||||
startProgress+0.35*(endProgress-startProgress),
|
||||
startProgress+0.39*(endProgress-startProgress),
|
||||
visited,
|
||||
); err != nil {
|
||||
return fmt.Errorf("failed to install AUR dependency %s for %s: %w", aurDep, pkg, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -133,13 +133,20 @@ DankPopout {
|
||||
|
||||
property var externalKeyboardController: null
|
||||
property real cachedHeaderHeight: 32
|
||||
readonly property real settingsMaxHeight: {
|
||||
const screenH = root.screen ? root.screen.height : 1080;
|
||||
const maxPopupH = screenH * 0.8;
|
||||
const overhead = cachedHeaderHeight + Theme.spacingL * 2 + Theme.spacingM * 2;
|
||||
return Math.max(200, maxPopupH - overhead - 150);
|
||||
}
|
||||
implicitHeight: {
|
||||
let baseHeight = Theme.spacingL * 2;
|
||||
baseHeight += cachedHeaderHeight;
|
||||
baseHeight += Theme.spacingM * 2;
|
||||
|
||||
const settingsHeight = notificationSettings.expanded ? notificationSettings.contentHeight : 0;
|
||||
let listHeight = notificationHeader.currentTab === 0 ? notificationList.stableContentHeight : Math.max(200, NotificationService.historyList.length * 80);
|
||||
const settingsHeight = notificationSettings.expanded ? Math.min(notificationSettings.naturalContentHeight, notificationContent.settingsMaxHeight) : 0;
|
||||
const currentListHeight = root.shouldBeVisible ? notificationList.stableContentHeight : notificationList.listContentHeight;
|
||||
let listHeight = notificationHeader.currentTab === 0 ? currentListHeight : Math.max(200, NotificationService.historyList.length * 80);
|
||||
if (notificationHeader.currentTab === 0 && NotificationService.groupedNotifications.length === 0) {
|
||||
listHeight = 200;
|
||||
}
|
||||
@@ -231,6 +238,7 @@ DankPopout {
|
||||
NotificationSettings {
|
||||
id: notificationSettings
|
||||
expanded: notificationHeader.showSettings
|
||||
maxAllowedHeight: notificationContent.settingsMaxHeight
|
||||
}
|
||||
|
||||
KeyboardNavigatedNotificationList {
|
||||
|
||||
@@ -6,10 +6,11 @@ Rectangle {
|
||||
id: root
|
||||
|
||||
property bool expanded: false
|
||||
readonly property real contentHeight: contentColumn.height + Theme.spacingL * 2
|
||||
property real maxAllowedHeight: 0
|
||||
readonly property real naturalContentHeight: contentColumn.height + Theme.spacingL * 2
|
||||
|
||||
width: parent.width
|
||||
height: expanded ? contentHeight : 0
|
||||
height: expanded ? (maxAllowedHeight > 0 ? Math.min(naturalContentHeight, maxAllowedHeight) : naturalContentHeight) : 0
|
||||
visible: expanded
|
||||
clip: true
|
||||
radius: Theme.cornerRadius
|
||||
@@ -105,13 +106,22 @@ Rectangle {
|
||||
return Math.round(value / 60000) + " minutes";
|
||||
}
|
||||
|
||||
Column {
|
||||
id: contentColumn
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.margins: Theme.spacingL
|
||||
spacing: Theme.spacingM
|
||||
Flickable {
|
||||
id: settingsFlickable
|
||||
anchors.fill: parent
|
||||
contentHeight: contentColumn.height + Theme.spacingL * 2
|
||||
clip: true
|
||||
flickableDirection: Flickable.VerticalFlick
|
||||
boundsBehavior: Flickable.DragAndOvershootBounds
|
||||
interactive: root.naturalContentHeight > root.height
|
||||
|
||||
Column {
|
||||
id: contentColumn
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.margins: Theme.spacingL
|
||||
spacing: Theme.spacingM
|
||||
|
||||
StyledText {
|
||||
text: I18n.tr("Notification Settings")
|
||||
@@ -421,4 +431,5 @@ Rectangle {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,10 +194,11 @@ Singleton {
|
||||
var timer = monitorTimers[screenName];
|
||||
if (!timer && monitorTimerComponent && monitorTimerComponent.status === Component.Ready) {
|
||||
var newTimers = Object.assign({}, monitorTimers);
|
||||
newTimers[screenName] = monitorTimerComponent.createObject(root);
|
||||
newTimers[screenName].targetScreen = screenName;
|
||||
var newTimer = monitorTimerComponent.createObject(root);
|
||||
newTimer.targetScreen = screenName;
|
||||
newTimers[screenName] = newTimer;
|
||||
monitorTimers = newTimers;
|
||||
timer = monitorTimers[screenName];
|
||||
timer = newTimer;
|
||||
}
|
||||
if (timer) {
|
||||
timer.interval = settings.interval * 1000;
|
||||
@@ -258,9 +259,10 @@ Singleton {
|
||||
var process = monitorProcesses[screenName];
|
||||
if (!process) {
|
||||
var newProcesses = Object.assign({}, monitorProcesses);
|
||||
newProcesses[screenName] = monitorProcessComponent.createObject(root);
|
||||
var newProcess = monitorProcessComponent.createObject(root);
|
||||
newProcesses[screenName] = newProcess;
|
||||
monitorProcesses = newProcesses;
|
||||
process = monitorProcesses[screenName];
|
||||
process = newProcess;
|
||||
}
|
||||
|
||||
if (process) {
|
||||
@@ -290,9 +292,10 @@ Singleton {
|
||||
var process = monitorProcesses[screenName];
|
||||
if (!process) {
|
||||
var newProcesses = Object.assign({}, monitorProcesses);
|
||||
newProcesses[screenName] = monitorProcessComponent.createObject(root);
|
||||
var newProcess = monitorProcessComponent.createObject(root);
|
||||
newProcesses[screenName] = newProcess;
|
||||
monitorProcesses = newProcesses;
|
||||
process = monitorProcesses[screenName];
|
||||
process = newProcess;
|
||||
}
|
||||
|
||||
if (process) {
|
||||
|
||||
Reference in New Issue
Block a user