mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 21:42:51 -05:00
plugins: ipc visibility conditions
This commit is contained in:
@@ -787,7 +787,16 @@ Item {
|
|||||||
const widgets = BarWidgetService.getRegisteredWidgetIds();
|
const widgets = BarWidgetService.getRegisteredWidgetIds();
|
||||||
if (widgets.length === 0)
|
if (widgets.length === 0)
|
||||||
return "No widgets registered";
|
return "No widgets registered";
|
||||||
return widgets.join("\n");
|
|
||||||
|
const lines = [];
|
||||||
|
for (const widgetId of widgets) {
|
||||||
|
const widget = BarWidgetService.getWidgetOnFocusedScreen(widgetId);
|
||||||
|
let state = "";
|
||||||
|
if (widget?.effectiveVisible !== undefined)
|
||||||
|
state = widget.effectiveVisible ? " [visible]" : " [hidden]";
|
||||||
|
lines.push(widgetId + state);
|
||||||
|
}
|
||||||
|
return lines.join("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
function status(widgetId: string): string {
|
function status(widgetId: string): string {
|
||||||
@@ -806,6 +815,76 @@ Item {
|
|||||||
return "hidden";
|
return "hidden";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function reveal(widgetId: string): string {
|
||||||
|
if (!widgetId)
|
||||||
|
return "ERROR: No widget ID specified";
|
||||||
|
|
||||||
|
if (!BarWidgetService.hasWidget(widgetId))
|
||||||
|
return `WIDGET_NOT_FOUND: ${widgetId}`;
|
||||||
|
|
||||||
|
const widget = BarWidgetService.getWidgetOnFocusedScreen(widgetId);
|
||||||
|
if (!widget)
|
||||||
|
return `WIDGET_NOT_AVAILABLE: ${widgetId}`;
|
||||||
|
|
||||||
|
if (typeof widget.setVisibilityOverride === "function") {
|
||||||
|
widget.setVisibilityOverride(true);
|
||||||
|
return `WIDGET_REVEAL_SUCCESS: ${widgetId}`;
|
||||||
|
}
|
||||||
|
return `WIDGET_REVEAL_NOT_SUPPORTED: ${widgetId}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function hide(widgetId: string): string {
|
||||||
|
if (!widgetId)
|
||||||
|
return "ERROR: No widget ID specified";
|
||||||
|
|
||||||
|
if (!BarWidgetService.hasWidget(widgetId))
|
||||||
|
return `WIDGET_NOT_FOUND: ${widgetId}`;
|
||||||
|
|
||||||
|
const widget = BarWidgetService.getWidgetOnFocusedScreen(widgetId);
|
||||||
|
if (!widget)
|
||||||
|
return `WIDGET_NOT_AVAILABLE: ${widgetId}`;
|
||||||
|
|
||||||
|
if (typeof widget.setVisibilityOverride === "function") {
|
||||||
|
widget.setVisibilityOverride(false);
|
||||||
|
return `WIDGET_HIDE_SUCCESS: ${widgetId}`;
|
||||||
|
}
|
||||||
|
return `WIDGET_HIDE_NOT_SUPPORTED: ${widgetId}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function reset(widgetId: string): string {
|
||||||
|
if (!widgetId)
|
||||||
|
return "ERROR: No widget ID specified";
|
||||||
|
|
||||||
|
if (!BarWidgetService.hasWidget(widgetId))
|
||||||
|
return `WIDGET_NOT_FOUND: ${widgetId}`;
|
||||||
|
|
||||||
|
const widget = BarWidgetService.getWidgetOnFocusedScreen(widgetId);
|
||||||
|
if (!widget)
|
||||||
|
return `WIDGET_NOT_AVAILABLE: ${widgetId}`;
|
||||||
|
|
||||||
|
if (typeof widget.clearVisibilityOverride === "function") {
|
||||||
|
widget.clearVisibilityOverride();
|
||||||
|
return `WIDGET_RESET_SUCCESS: ${widgetId}`;
|
||||||
|
}
|
||||||
|
return `WIDGET_RESET_NOT_SUPPORTED: ${widgetId}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function visibility(widgetId: string): string {
|
||||||
|
if (!widgetId)
|
||||||
|
return "ERROR: No widget ID specified";
|
||||||
|
|
||||||
|
if (!BarWidgetService.hasWidget(widgetId))
|
||||||
|
return `WIDGET_NOT_FOUND: ${widgetId}`;
|
||||||
|
|
||||||
|
const widget = BarWidgetService.getWidgetOnFocusedScreen(widgetId);
|
||||||
|
if (!widget)
|
||||||
|
return `WIDGET_NOT_AVAILABLE: ${widgetId}`;
|
||||||
|
|
||||||
|
if (widget.effectiveVisible !== undefined)
|
||||||
|
return widget.effectiveVisible ? "visible" : "hidden";
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
|
||||||
target: "widget"
|
target: "widget"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
|
import Quickshell.Io
|
||||||
import qs.Common
|
import qs.Common
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
@@ -16,6 +17,20 @@ Item {
|
|||||||
property string pluginId: ""
|
property string pluginId: ""
|
||||||
property var pluginService: null
|
property var pluginService: null
|
||||||
|
|
||||||
|
property string visibilityCommand: ""
|
||||||
|
property int visibilityInterval: 0
|
||||||
|
property bool conditionVisible: true
|
||||||
|
property bool _visibilityOverride: false
|
||||||
|
property bool _visibilityOverrideValue: true
|
||||||
|
|
||||||
|
readonly property bool effectiveVisible: {
|
||||||
|
if (_visibilityOverride)
|
||||||
|
return _visibilityOverrideValue;
|
||||||
|
if (!visibilityCommand)
|
||||||
|
return true;
|
||||||
|
return conditionVisible;
|
||||||
|
}
|
||||||
|
|
||||||
property Component horizontalBarPill: null
|
property Component horizontalBarPill: null
|
||||||
property Component verticalBarPill: null
|
property Component verticalBarPill: null
|
||||||
property Component popoutContent: null
|
property Component popoutContent: null
|
||||||
@@ -49,6 +64,8 @@ Item {
|
|||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
loadPluginData();
|
loadPluginData();
|
||||||
|
if (visibilityCommand)
|
||||||
|
Qt.callLater(checkVisibility);
|
||||||
}
|
}
|
||||||
|
|
||||||
onPluginServiceChanged: {
|
onPluginServiceChanged: {
|
||||||
@@ -78,6 +95,57 @@ Item {
|
|||||||
variants = pluginService.getPluginVariants(pluginId);
|
variants = pluginService.getPluginVariants(pluginId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkVisibility() {
|
||||||
|
if (!visibilityCommand) {
|
||||||
|
conditionVisible = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
visibilityProcess.running = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setVisibilityOverride(visible) {
|
||||||
|
_visibilityOverride = true;
|
||||||
|
_visibilityOverrideValue = visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearVisibilityOverride() {
|
||||||
|
_visibilityOverride = false;
|
||||||
|
if (visibilityCommand)
|
||||||
|
checkVisibility();
|
||||||
|
}
|
||||||
|
|
||||||
|
onVisibilityCommandChanged: {
|
||||||
|
if (visibilityCommand)
|
||||||
|
Qt.callLater(checkVisibility);
|
||||||
|
else
|
||||||
|
conditionVisible = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
onVisibilityIntervalChanged: {
|
||||||
|
if (visibilityInterval > 0 && visibilityCommand) {
|
||||||
|
visibilityTimer.restart();
|
||||||
|
} else {
|
||||||
|
visibilityTimer.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: visibilityTimer
|
||||||
|
interval: root.visibilityInterval * 1000
|
||||||
|
repeat: true
|
||||||
|
running: root.visibilityInterval > 0 && root.visibilityCommand !== ""
|
||||||
|
onTriggered: root.checkVisibility()
|
||||||
|
}
|
||||||
|
|
||||||
|
Process {
|
||||||
|
id: visibilityProcess
|
||||||
|
command: ["sh", "-c", root.visibilityCommand]
|
||||||
|
running: false
|
||||||
|
onExited: (exitCode, exitStatus) => {
|
||||||
|
root.conditionVisible = (exitCode === 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function createVariant(variantName, variantConfig) {
|
function createVariant(variantName, variantConfig) {
|
||||||
if (!pluginService || !pluginId) {
|
if (!pluginService || !pluginId) {
|
||||||
return null;
|
return null;
|
||||||
@@ -105,6 +173,7 @@ Item {
|
|||||||
BasePill {
|
BasePill {
|
||||||
id: horizontalPill
|
id: horizontalPill
|
||||||
visible: !isVertical && hasHorizontalPill
|
visible: !isVertical && hasHorizontalPill
|
||||||
|
opacity: root.effectiveVisible ? 1 : 0
|
||||||
axis: root.axis
|
axis: root.axis
|
||||||
section: root.section
|
section: root.section
|
||||||
popoutTarget: hasPopout ? pluginPopout : null
|
popoutTarget: hasPopout ? pluginPopout : null
|
||||||
@@ -114,6 +183,24 @@ Item {
|
|||||||
barSpacing: root.barSpacing
|
barSpacing: root.barSpacing
|
||||||
barConfig: root.barConfig
|
barConfig: root.barConfig
|
||||||
content: root.horizontalBarPill
|
content: root.horizontalBarPill
|
||||||
|
|
||||||
|
states: State {
|
||||||
|
name: "hidden"
|
||||||
|
when: !root.effectiveVisible
|
||||||
|
PropertyChanges {
|
||||||
|
target: horizontalPill
|
||||||
|
width: 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
transitions: Transition {
|
||||||
|
NumberAnimation {
|
||||||
|
properties: "width,opacity"
|
||||||
|
duration: Theme.shortDuration
|
||||||
|
easing.type: Theme.standardEasing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (pillClickAction) {
|
if (pillClickAction) {
|
||||||
if (pillClickAction.length === 0) {
|
if (pillClickAction.length === 0) {
|
||||||
@@ -145,6 +232,7 @@ Item {
|
|||||||
BasePill {
|
BasePill {
|
||||||
id: verticalPill
|
id: verticalPill
|
||||||
visible: isVertical && hasVerticalPill
|
visible: isVertical && hasVerticalPill
|
||||||
|
opacity: root.effectiveVisible ? 1 : 0
|
||||||
axis: root.axis
|
axis: root.axis
|
||||||
section: root.section
|
section: root.section
|
||||||
popoutTarget: hasPopout ? pluginPopout : null
|
popoutTarget: hasPopout ? pluginPopout : null
|
||||||
@@ -155,6 +243,24 @@ Item {
|
|||||||
barConfig: root.barConfig
|
barConfig: root.barConfig
|
||||||
content: root.verticalBarPill
|
content: root.verticalBarPill
|
||||||
isVerticalOrientation: true
|
isVerticalOrientation: true
|
||||||
|
|
||||||
|
states: State {
|
||||||
|
name: "hidden"
|
||||||
|
when: !root.effectiveVisible
|
||||||
|
PropertyChanges {
|
||||||
|
target: verticalPill
|
||||||
|
height: 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
transitions: Transition {
|
||||||
|
NumberAnimation {
|
||||||
|
properties: "height,opacity"
|
||||||
|
duration: Theme.shortDuration
|
||||||
|
easing.type: Theme.standardEasing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (pillClickAction) {
|
if (pillClickAction) {
|
||||||
if (pillClickAction.length === 0) {
|
if (pillClickAction.length === 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user