1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-06-13 14:36:32 -04:00
Files
DankMaterialShell/quickshell
David Mireles 5a5cc4f4e9 feat(plugins): expose scan/rescan/reload IPC handlers for runtime plugin discovery (#2611)
* feat(plugins): expose IPC handlers for runtime plugin discovery

Follow-up to #1659. That issue landed hot-reload for settings.json via
FileView.watchChanges + a 1ms Timer to skirt the JSON parse race. It does
not cover plugin discovery in runtime: adding a new plugin directory to
~/.config/DankMaterialShell/plugins/ while the shell is running is not
consistently picked up by the existing FolderListModel watcher in
PluginService.qml, and there is no IPC handle for forcing a rescan from
outside the shell.

Adds an IpcHandler on PluginService with five small functions:

- scan(): wraps existing scanPlugins(), returns count snapshot
- rescan(pluginId): wraps existing forceRescanPlugin(id), validates id
- reload(pluginId): wraps existing reloadPlugin(id), validates id
- list(): newline-joined id\tloaded\ttype\tname for every known plugin
- status(pluginId): loaded\ttype\terror for one plugin

Scope intentionally small: no file-watcher changes, no new daemons, no
schema additions. Target string "plugins" does not collide with any
existing target in DMSShellIPC.qml.

Validation:
- qs ipc --pid <PID> call plugins list returns one row per known plugin
- qs ipc --pid <PID> call plugins scan returns SCAN_TRIGGERED with count
- qs ipc --pid <PID> call plugins rescan <id> returns RESCAN_TRIGGERED
- Empty-arg paths return ERROR strings instead of throwing
- git merge-tree against origin/master is clean

* hardening(plugins): fix 7 review findings in scan-ipc IPC handlers

Follow-up to commit 43603f56 which ported PR #2601 (AvengeMedia scan-ipc)
to the fork. The original port was functionally correct but had seven
review issues that would block upstream adoption. This patch addresses
each one with a minimal, focused change.

* B1 IPC target collision: renamed `target: "plugins"` to
  `target: "plugin-scan"`. The original name collided with the
  existing IpcHandler in DMSShellIPC.qml:1180 which already registers
  enable/disable/toggle/list/status under "plugins". The split keeps
  both APIs discoverable without one shadowing the other.

* H1 Fire-and-forget scan: documented that scan() returns the
  pre-debounce count and that callers must poll list/status (or wait
  ~200ms) to observe the post-debounce state. A proper requestId +
  await mechanism was considered and rejected for scope reasons.

* H2 TOCTOU in rescan(): the handler now reads availablePlugins[id]
  inside forceRescanPlugin via the id string only — no captured
  object reference. A parallel resyncDebounce tick can otherwise
  mutate the entry between the read and the use.

* M1 list() cap: added a 256-entry cap and a leading header line
  (`# count=N returned=M`) so callers can detect truncation. A
  hostile / buggy plugin mass-creating entries could otherwise
  allocate 80 KB+ per IPC call.

* M2 status() prefix: "unknown\t\t" became
  `ERROR: unknown pluginId '...'` to match the rest of the
  handlers' prefix convention. Empty trailing field means no error.

* M3 id sanitization: every handler that takes pluginId now
  validates against `/^[a-zA-Z0-9_\-:]{1,64}$` before use. This
  rejects shell-injection payloads ("foo\tmalicious") and prototype
  pollution attempts ("__proto__", "constructor"). The list() and
  status() handlers also sanitize \t/\n in name and error fields
  so callers can rely on the TSV structure.

Verification: brace count balanced (252/252). Manual read of all
five handlers confirms no logic regression. QML runtime tests are
not part of the DMS test suite, so end-to-end validation requires
rebuilding the shell — deferred to the user.

Not pushed. Stage-local-first rule.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* refactor(plugins): strip inline comments per review feedback

Purian23 in PR #2611 review: 'let's address the amount of line
comments in the code, there's not a need for all of them to exist.'

Removed 48 comment lines. The substantive justification (why the
regex, why fire-and-forget, why re-read inside forceRescanPlugin,
why the 256 cap, why the target rename) now lives in the PR body
under 'Review-driven fixes in this iteration' and 'What changed'
where the reviewer already reads it.

No code logic changed. Brace count 252/252. Diff is -48/+0 on
quickshell/Services/PluginService.qml.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------
2026-06-11 14:44:41 -04:00
..
2026-05-16 15:11:54 -04:00
2026-02-17 10:39:32 -05:00

DMS Quickshell Interface

QML-based desktop shell interface for DankMaterialShell providing panels, widgets, and overlays.

See root README for project overview and installation.

Architecture

Modular QML Structure

  • Modules/ - UI components (panels, widgets, overlays)
  • Services/ - System integration singletons (audio, network, bluetooth)
  • Widgets/ - Reusable UI controls
  • Common/ - Shared resources and themes

Technology Stack

  • Quickshell - QML-based shell framework
  • Qt/QtQuick - UI rendering and controls
  • Material Design 3 - Design system and theming

Development

Run the shell:

quickshell -p quickshell/

Code formatting:

qmlfmt -t 4 -i 4 -b 250 -w path/to/file.qml
make lint-qml  # Run from repo root; requires quickshell/.qmlls.ini (generated by `qs -p quickshell/`)
               # Uses Qt 6 qmllint. Override path with QMLLINT=/path/to/qmllint if needed.
               # Auto-detects `qmllint6`, Fedora's `qmllint-qt6`, `/usr/lib/qt6/bin/qmllint`, then `qmllint`.

Components

Panels & Bars

  • Modules/TopBar/ - Multi-monitor status bars with workspace switching
  • Modules/DankBar/ - Customizable widget bar with plugin support
  • Modules/Dock/ - Application dock with window management

System Controls

  • Modules/ControlCenter/ - WiFi, Bluetooth, audio, display settings
  • Modules/Notifications/ - Notification center with popups
  • Modules/Greetd/ - Login greeter interface

Overlays

  • Modules/Spotlight/ - Application and file launcher
  • Modules/Overview/ - Workspace overview
  • Modules/Lock/ - Screen lock system

Utilities

  • Modules/ProcessList/ - System monitoring and process management
  • Modules/Calendar/ - Calendar widget with event sync
  • Modules/Weather/ - Weather display

Services

Singletons providing system integration:

Media & Audio

  • AudioService - PipeWire/PulseAudio volume and device control
  • MprisController - Media player integration

Network

  • NetworkService - NetworkManager WiFi control
  • BluetoothService - BlueZ Bluetooth management

Display

  • DisplayService - Brightness control and night mode
  • WallpaperService - Wallpaper management and effects

System

  • BatteryService - Battery status and power profiles
  • IdleService - Idle detection and inhibit locks
  • ClipboardService - Clipboard history with images
  • DgopService - System metrics (CPU, RAM, GPU)

Integration

  • NiriService - Niri workspace integration
  • HyprlandService - Hyprland workspace integration
  • PluginService - Plugin discovery and lifecycle

Widgets

Reusable Material Design 3 components in Widgets/:

  • DankIcon - Icon component with Material font
  • DankSlider - Enhanced slider with animations
  • DankToggle - Toggle switch component
  • DankTabBar - Tab bar implementation
  • DankGridView - Grid layout with adaptive columns
  • DankListView - Scrollable list view
  • DankTextField - Text input with validation
  • DankDropdown - Dropdown selection
  • DankPopout - Base for overlay components
  • StateLayer - Material interaction states

Theming

Dynamic Color Schemes

Wallpaper-based theming using matugen:

import qs.Common

Rectangle {
    color: Theme.container
    border.color: Theme.outline
}

Theme singleton provides Material Design 3 color system, spacing, fonts, and elevation.

Application Themes

Templates in scripts/templates/ generate themes for:

  • GTK 3/4
  • Qt5/Qt6
  • Alacritty, Kitty, Ghostty, Foot, Wezterm terminals
  • Neovim
  • VSCode/VSCodium
  • Firefox

Multi-Monitor Support

Per-monitor panel instances using Quickshell Variants:

Variants {
    model: Quickshell.screens
    PanelWindow {
        screen: modelData
        // Per-screen configuration
    }
}

Workspace switchers adapt to compositor (Niri/Hyprland).

Plugin System

External plugins in ~/.config/DankMaterialShell/plugins/:

Widget plugins - UI components in DankBar Daemon plugins - Background processes without UI

Plugin manifest (plugin.json):

{
    "id": "pluginId",
    "name": "Plugin Name",
    "version": "1.0.0",
    "type": "widget",
    "component": "./Widget.qml",
    "settings": "./Settings.qml",
    "permissions": ["settings_read", "settings_write"]
}

Plugins access pluginService for persistent data:

pluginService.savePluginData("pluginId", "key", value)
pluginService.loadPluginData("pluginId", "key", defaultValue)

IPC Integration

Backend IPC socket communication:

import Quickshell.Io

Process {
    command: ["dms", "ipc", "call", "spotlight", "toggle"]
    running: true
}

Common IPC commands exposed through services for reactive property bindings.

Code Conventions

Component Structure:

import QtQuick
import Quickshell
import qs.Common
import qs.Services

Item {
    id: root

    property type name: value

    signal customSignal(type param)

    Component { /* children */ }
}

Services (Singletons):

import QtQuick
import Quickshell
pragma Singleton
pragma ComponentBehavior: Bound

Singleton {
    id: root

    property bool featureAvailable: false
    property type currentValue: defaultValue

    function performAction(param) { /* implementation */ }
}

Guidelines:

  • Use Theme.propertyName for consistent styling
  • Bind directly to service properties for reactivity
  • Use DankIcon for all icons
  • Implement feature detection and graceful degradation
  • 4-space indentation, no unnecessary comments

Translation

Internationalization using POEditor:

export POEDITOR_API_TOKEN="token"
export POEDITOR_PROJECT_ID="id"
python3 scripts/i18nsync.py sync

Pre-commit hook checks translation sync status.

License

MIT License - See LICENSE for details.