1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-28 23:42:51 -05:00

clipboard: remove wl-copy references

This commit is contained in:
bbedward
2025-12-11 11:10:27 -05:00
parent 5bf54632be
commit 597e21d44d
16 changed files with 22 additions and 77 deletions

View File

@@ -135,7 +135,7 @@ PluginComponent {
cursorShape: Qt.PointingHandCursor
onClicked: {
Quickshell.execDetached(["sh", "-c", "echo -n '" + modelData + "' | wl-copy"])
Quickshell.execDetached(["dms", "cl", "copy", modelData])
ToastService.showInfo("Copied " + modelData + " to clipboard")
popoutColumn.closePopout()
}

View File

@@ -6,7 +6,7 @@ An example dms plugin that displays cycling emojis in your bar with an emoji pic
- **Cycling Emojis**: Automatically rotates through your selected emoji set in the bar
- **Emoji Picker**: Click the widget to open a grid of 120+ emojis
- **Copy to Clipboard**: Click any emoji in the picker to copy it to clipboard (uses `wl-copy`)
- **Copy to Clipboard**: Click any emoji in the picker to copy it to clipboard
- **Customizable**: Choose emoji sets, cycle speed, and max emojis shown
## Installation
@@ -38,10 +38,6 @@ How many emojis to display at once (1-8)
**Click the widget**: Opens emoji picker with 120+ emojis
**Click any emoji**: Copies it to clipboard and shows toast
## Requirements
- `wl-copy` (for clipboard support on Wayland)
## Example Code Highlights
This plugin demonstrates:

View File

@@ -119,7 +119,7 @@ Item {
}
function copyToClipboard(text) {
Quickshell.execDetached(["sh", "-c", "echo -n '" + text + "' | wl-copy"])
Quickshell.execDetached(["dms", "cl", "copy", text])
showToast("Copied to clipboard: " + text)
}

View File

@@ -91,7 +91,7 @@ The manifest file defines plugin metadata and configuration.
- `icon`: Material Design icon name (displayed in UI)
- `settings`: Path to settings component (enables settings UI)
- `requires_dms`: Minimum DMS version requirement (e.g., ">=0.1.18", ">0.1.0")
- `requires`: Array of required system tools/dependencies (e.g., ["wl-copy", "curl"])
- `requires`: Array of required system tools/dependencies (e.g., ["curl", "jq"])
- `permissions`: Required DMS permissions (e.g., ["settings_read", "settings_write"])
**Permissions:**
@@ -860,11 +860,11 @@ Or edit `$CONFIGPATH/quickshell/dms/config.json`:
## Clipboard Access
Plugins that need to copy text to the clipboard **must** use the Wayland clipboard utility `wl-copy` through Quickshell's `execDetached` function.
Plugins that need to copy text to the clipboard should use the built-in `dms cl copy` command through Quickshell's `execDetached` function.
### Correct Method
Import Quickshell and use `execDetached` with `wl-copy`:
Import Quickshell and use `execDetached` with `dms cl copy`:
```qml
import QtQuick
@@ -872,19 +872,19 @@ import Quickshell
Item {
function copyToClipboard(text) {
Quickshell.execDetached(["sh", "-c", "echo -n '" + text + "' | wl-copy"])
Quickshell.execDetached(["dms", "cl", "copy", text])
}
}
```
### Example Usage
From the ExampleEmojiPlugin (EmojiWidget.qml:136):
From the ExampleEmojiPlugin (EmojiWidget.qml):
```qml
MouseArea {
onClicked: {
Quickshell.execDetached(["sh", "-c", "echo -n '" + modelData + "' | wl-copy"])
Quickshell.execDetached(["dms", "cl", "copy", modelData])
ToastService.showInfo("Copied " + modelData + " to clipboard")
popoutColumn.closePopout()
}
@@ -895,13 +895,11 @@ MouseArea {
1. **Do NOT** use `globalThis.clipboard` or similar JavaScript APIs - they don't exist in the QML runtime
2. **Always** import `Quickshell` at the top of your QML file
3. **Use** `echo -n` to prevent adding a trailing newline to the clipboard content
4. The `-c` flag for `sh` is required to execute the pipe command properly
5. Consider showing a toast notification to confirm the copy action to users
3. Consider showing a toast notification to confirm the copy action to users
### Dependencies
This method requires `wl-copy` from the `wl-clipboard` package, which is standard on Wayland systems.
This method uses the built-in DMS clipboard functionality which has native Wayland support.
## Running External Commands