mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-05-03 02:52:07 -04:00
Compare commits
3 Commits
blur
...
e9aeb9ac60
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e9aeb9ac60 | ||
|
|
fb02f7294d | ||
|
|
f15d49d80a |
40
core/cmd/dms/commands_blur.go
Normal file
40
core/cmd/dms/commands_blur.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/internal/blur"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var blurCmd = &cobra.Command{
|
||||
Use: "blur",
|
||||
Short: "Background blur utilities",
|
||||
}
|
||||
|
||||
var blurCheckCmd = &cobra.Command{
|
||||
Use: "check",
|
||||
Short: "Check if the compositor supports background blur (ext-background-effect-v1)",
|
||||
Args: cobra.NoArgs,
|
||||
Run: runBlurCheck,
|
||||
}
|
||||
|
||||
func init() {
|
||||
blurCmd.AddCommand(blurCheckCmd)
|
||||
}
|
||||
|
||||
func runBlurCheck(cmd *cobra.Command, args []string) {
|
||||
supported, err := blur.ProbeSupport()
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
switch supported {
|
||||
case true:
|
||||
fmt.Println("supported")
|
||||
default:
|
||||
fmt.Println("unsupported")
|
||||
}
|
||||
}
|
||||
@@ -525,5 +525,6 @@ func getCommonCommands() []*cobra.Command {
|
||||
configCmd,
|
||||
dlCmd,
|
||||
randrCmd,
|
||||
blurCmd,
|
||||
}
|
||||
}
|
||||
|
||||
35
core/internal/blur/probe.go
Normal file
35
core/internal/blur/probe.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package blur
|
||||
|
||||
import (
|
||||
wlhelpers "github.com/AvengeMedia/DankMaterialShell/core/internal/wayland/client"
|
||||
client "github.com/AvengeMedia/DankMaterialShell/core/pkg/go-wayland/wayland/client"
|
||||
)
|
||||
|
||||
const extBackgroundEffectInterface = "ext_background_effect_manager_v1"
|
||||
|
||||
func ProbeSupport() (bool, error) {
|
||||
display, err := client.Connect("")
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
defer display.Context().Close()
|
||||
|
||||
registry, err := display.GetRegistry()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
found := false
|
||||
registry.SetGlobalHandler(func(e client.RegistryGlobalEvent) {
|
||||
switch e.Interface {
|
||||
case extBackgroundEffectInterface:
|
||||
found = true
|
||||
}
|
||||
})
|
||||
|
||||
if err := wlhelpers.Roundtrip(display, display.Context()); err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return found, nil
|
||||
}
|
||||
@@ -20,6 +20,46 @@ Item {
|
||||
property var blurBarWindow: null
|
||||
property var hyprlandOverviewLoader: null
|
||||
property var parentScreen: null
|
||||
|
||||
readonly property real _leftMargin: {
|
||||
if (isVertical)
|
||||
return 0;
|
||||
root.x;
|
||||
if (!root.parent)
|
||||
return 0;
|
||||
const gap = root.mapToItem(null, 0, 0).x;
|
||||
return (gap > 0 && gap < 30) ? gap + 5 : 0;
|
||||
}
|
||||
readonly property real _rightMargin: {
|
||||
if (isVertical)
|
||||
return 0;
|
||||
root.x;
|
||||
root.width;
|
||||
if (!root.parent || !blurBarWindow)
|
||||
return 0;
|
||||
const gap = blurBarWindow.width - root.mapToItem(null, root.width, 0).x;
|
||||
return (gap > 0 && gap < 30) ? gap + 5 : 0;
|
||||
}
|
||||
readonly property real _topMargin: {
|
||||
if (!isVertical)
|
||||
return 0;
|
||||
root.y;
|
||||
if (!root.parent)
|
||||
return 0;
|
||||
const gap = root.mapToItem(null, 0, 0).y;
|
||||
return (gap > 0 && gap < 30) ? gap + 5 : 0;
|
||||
}
|
||||
readonly property real _bottomMargin: {
|
||||
if (!isVertical)
|
||||
return 0;
|
||||
root.y;
|
||||
root.height;
|
||||
if (!root.parent || !blurBarWindow)
|
||||
return 0;
|
||||
const gap = blurBarWindow.height - root.mapToItem(null, 0, root.height).y;
|
||||
return (gap > 0 && gap < 30) ? gap + 5 : 0;
|
||||
}
|
||||
|
||||
property int _desktopEntriesUpdateTrigger: 0
|
||||
readonly property var sortedToplevels: {
|
||||
return CompositorService.filterCurrentWorkspace(CompositorService.sortedToplevels, screenName);
|
||||
@@ -539,6 +579,60 @@ Item {
|
||||
});
|
||||
}
|
||||
|
||||
function switchToWorkspaceByModelData(data) {
|
||||
if (!data)
|
||||
return;
|
||||
|
||||
if (root.useExtWorkspace && (data.id || data.name)) {
|
||||
ExtWorkspaceService.activateWorkspace(data.id || data.name, data.groupID || "");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (CompositorService.compositor) {
|
||||
case "niri":
|
||||
if (data.idx !== undefined)
|
||||
NiriService.switchToWorkspace(data.idx);
|
||||
break;
|
||||
case "hyprland":
|
||||
if (data.id)
|
||||
Hyprland.dispatch(`workspace ${data.id}`);
|
||||
break;
|
||||
case "dwl":
|
||||
if (data.tag !== undefined)
|
||||
DwlService.switchToTag(root.screenName, data.tag);
|
||||
break;
|
||||
case "sway":
|
||||
case "scroll":
|
||||
case "miracle":
|
||||
if (data.num)
|
||||
try {
|
||||
I3.dispatch(`workspace number ${data.num}`);
|
||||
} catch (_) {}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function findClosestWorkspaceIndex(localX, localY) {
|
||||
if (workspaceRepeater.count === 0)
|
||||
return -1;
|
||||
|
||||
let closestIdx = -1;
|
||||
let closestDist = Infinity;
|
||||
|
||||
for (let i = 0; i < workspaceRepeater.count; i++) {
|
||||
const item = workspaceRepeater.itemAt(i);
|
||||
if (!item)
|
||||
continue;
|
||||
const center = item.mapToItem(root, item.width / 2, item.height / 2);
|
||||
const dist = isVertical ? Math.abs(localY - center.y) : Math.abs(localX - center.x);
|
||||
if (dist < closestDist) {
|
||||
closestDist = dist;
|
||||
closestIdx = i;
|
||||
}
|
||||
}
|
||||
return closestIdx;
|
||||
}
|
||||
|
||||
function switchWorkspace(direction) {
|
||||
if (useExtWorkspace) {
|
||||
const realWorkspaces = getRealWorkspaces();
|
||||
@@ -752,8 +846,15 @@ Item {
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.RightButton
|
||||
id: edgeMouseArea
|
||||
z: -1
|
||||
x: -root._leftMargin
|
||||
y: -root._topMargin
|
||||
width: root.width + root._leftMargin + root._rightMargin
|
||||
height: root.height + root._topMargin + root._bottomMargin
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
|
||||
property real touchpadAccumulator: 0
|
||||
property real mouseAccumulator: 0
|
||||
@@ -766,12 +867,20 @@ Item {
|
||||
}
|
||||
|
||||
onClicked: mouse => {
|
||||
if (mouse.button === Qt.RightButton) {
|
||||
const rootPos = edgeMouseArea.mapToItem(root, mouse.x, mouse.y);
|
||||
switch (mouse.button) {
|
||||
case Qt.RightButton:
|
||||
if (CompositorService.isNiri) {
|
||||
NiriService.toggleOverview();
|
||||
} else if (CompositorService.isHyprland && root.hyprlandOverviewLoader?.item) {
|
||||
root.hyprlandOverviewLoader.item.overviewOpen = !root.hyprlandOverviewLoader.item.overviewOpen;
|
||||
}
|
||||
break;
|
||||
case Qt.LeftButton:
|
||||
const idx = root.findClosestWorkspaceIndex(rootPos.x, rootPos.y);
|
||||
if (idx >= 0)
|
||||
root.switchToWorkspaceByModelData(root.workspaceList[idx]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import qs.Common
|
||||
import qs.Widgets
|
||||
import qs.Services
|
||||
@@ -52,15 +51,14 @@ Column {
|
||||
height: implicitHeight
|
||||
spacing: Theme.spacingM
|
||||
|
||||
RowLayout {
|
||||
width: parent.width
|
||||
Row {
|
||||
spacing: Theme.spacingM
|
||||
|
||||
DankIcon {
|
||||
name: root.titleIcon
|
||||
size: Theme.iconSize
|
||||
color: Theme.primary
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
StyledText {
|
||||
@@ -68,7 +66,7 @@ Column {
|
||||
font.pixelSize: Theme.fontSizeLarge
|
||||
font.weight: Font.Medium
|
||||
color: Theme.surfaceText
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
}
|
||||
}
|
||||
|
||||
@@ -981,10 +979,26 @@ Column {
|
||||
|
||||
Repeater {
|
||||
model: [
|
||||
{ label: I18n.tr("Percentage"), mode: 0, icon: "percent" },
|
||||
{ label: I18n.tr("Total"), mode: 1, icon: "storage" },
|
||||
{ label: I18n.tr("Remaining"), mode: 2, icon: "hourglass_empty" },
|
||||
{ label: I18n.tr("Remaining / Total"), mode: 3, icon: "pie_chart" }
|
||||
{
|
||||
label: I18n.tr("Percentage"),
|
||||
mode: 0,
|
||||
icon: "percent"
|
||||
},
|
||||
{
|
||||
label: I18n.tr("Total"),
|
||||
mode: 1,
|
||||
icon: "storage"
|
||||
},
|
||||
{
|
||||
label: I18n.tr("Remaining"),
|
||||
mode: 2,
|
||||
icon: "hourglass_empty"
|
||||
},
|
||||
{
|
||||
label: I18n.tr("Remaining / Total"),
|
||||
mode: 3,
|
||||
icon: "pie_chart"
|
||||
}
|
||||
]
|
||||
|
||||
delegate: Rectangle {
|
||||
@@ -1316,20 +1330,7 @@ Column {
|
||||
id: longestControlCenterLabelMetrics
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
text: {
|
||||
const labels = [
|
||||
I18n.tr("Network"),
|
||||
I18n.tr("VPN"),
|
||||
I18n.tr("Bluetooth"),
|
||||
I18n.tr("Audio"),
|
||||
I18n.tr("Volume"),
|
||||
I18n.tr("Microphone"),
|
||||
I18n.tr("Microphone Volume"),
|
||||
I18n.tr("Brightness"),
|
||||
I18n.tr("Brightness Value"),
|
||||
I18n.tr("Battery"),
|
||||
I18n.tr("Printer"),
|
||||
I18n.tr("Screen Sharing")
|
||||
];
|
||||
const labels = [I18n.tr("Network"), I18n.tr("VPN"), I18n.tr("Bluetooth"), I18n.tr("Audio"), I18n.tr("Volume"), I18n.tr("Microphone"), I18n.tr("Microphone Volume"), I18n.tr("Brightness"), I18n.tr("Brightness Value"), I18n.tr("Battery"), I18n.tr("Printer"), I18n.tr("Screen Sharing")];
|
||||
let longest = "";
|
||||
for (let i = 0; i < labels.length; i++) {
|
||||
if (labels[i].length > longest.length)
|
||||
@@ -1340,6 +1341,7 @@ Column {
|
||||
}
|
||||
|
||||
Repeater {
|
||||
id: groupRepeater
|
||||
model: controlCenterContextMenu.controlCenterGroups
|
||||
|
||||
delegate: Item {
|
||||
@@ -1569,8 +1571,6 @@ Column {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
id: groupRepeater
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,13 +3,16 @@ pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import Quickshell.Wayland // ! Import is needed despite what qmlls says
|
||||
import qs.Common
|
||||
|
||||
Singleton {
|
||||
id: root
|
||||
|
||||
property bool available: false
|
||||
property bool quickshellSupported: false
|
||||
property bool compositorSupported: false
|
||||
property bool available: quickshellSupported && compositorSupported
|
||||
readonly property bool enabled: available && (SettingsData.blurEnabled ?? false)
|
||||
|
||||
readonly property color borderColor: {
|
||||
@@ -72,6 +75,27 @@ Singleton {
|
||||
region.destroy();
|
||||
}
|
||||
|
||||
Process {
|
||||
id: blurProbe
|
||||
running: false
|
||||
command: ["dms", "blur", "check"]
|
||||
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
root.compositorSupported = text.trim() === "supported";
|
||||
if (root.compositorSupported)
|
||||
console.info("BlurService: Compositor supports ext-background-effect-v1");
|
||||
else
|
||||
console.info("BlurService: Compositor does not support ext-background-effect-v1");
|
||||
}
|
||||
}
|
||||
|
||||
onExited: exitCode => {
|
||||
if (exitCode !== 0)
|
||||
console.warn("BlurService: blur probe failed with code:", exitCode);
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
try {
|
||||
const test = Qt.createQmlObject(`
|
||||
@@ -79,8 +103,9 @@ Singleton {
|
||||
Region { radius: 0 }
|
||||
`, root, "BlurAvailabilityTest");
|
||||
test.destroy();
|
||||
available = true;
|
||||
console.info("BlurService: Initialized with blur support");
|
||||
quickshellSupported = true;
|
||||
console.info("BlurService: Quickshell blur support available");
|
||||
blurProbe.running = true;
|
||||
} catch (e) {
|
||||
console.info("BlurService: BackgroundEffect not available - blur disabled. Requires a newer version of Quickshell.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user