mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-14 09:42:10 -04:00
clipboard: remove wl-copy references
This commit is contained in:
@@ -3,8 +3,8 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
|
||||||
|
|
||||||
|
"github.com/AvengeMedia/DankMaterialShell/core/internal/clipboard"
|
||||||
"github.com/AvengeMedia/DankMaterialShell/core/internal/colorpicker"
|
"github.com/AvengeMedia/DankMaterialShell/core/internal/colorpicker"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
@@ -121,13 +121,7 @@ func runColorPick(cmd *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func copyToClipboard(text string) {
|
func copyToClipboard(text string) {
|
||||||
var cmd *exec.Cmd
|
if err := clipboard.CopyText(text); err != nil {
|
||||||
if _, err := exec.LookPath("wl-copy"); err == nil {
|
fmt.Fprintln(os.Stderr, "clipboard copy failed:", err)
|
||||||
cmd = exec.Command("wl-copy", text)
|
|
||||||
} else {
|
|
||||||
fmt.Fprintln(os.Stderr, "wl-copy not found, cannot copy to clipboard")
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = cmd.Run()
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/AvengeMedia/DankMaterialShell/core/internal/clipboard"
|
||||||
"github.com/AvengeMedia/DankMaterialShell/core/internal/screenshot"
|
"github.com/AvengeMedia/DankMaterialShell/core/internal/screenshot"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
@@ -257,9 +257,7 @@ func copyImageToClipboard(buf *screenshot.ShmBuffer, format screenshot.Format, q
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := exec.Command("wl-copy", "--type", mimeType)
|
return clipboard.Copy(data.Bytes(), mimeType)
|
||||||
cmd.Stdin = &data
|
|
||||||
return cmd.Run()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeImageToStdout(buf *screenshot.ShmBuffer, format screenshot.Format, quality int, pixelFormat uint32) error {
|
func writeImageToStdout(buf *screenshot.ShmBuffer, format screenshot.Format, quality int, pixelFormat uint32) error {
|
||||||
|
|||||||
@@ -103,10 +103,8 @@ func (a *ArchDistribution) DetectDependenciesWithTerminal(ctx context.Context, w
|
|||||||
dependencies = append(dependencies, a.detectXwaylandSatellite())
|
dependencies = append(dependencies, a.detectXwaylandSatellite())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Base detections (common across distros)
|
|
||||||
dependencies = append(dependencies, a.detectMatugen())
|
dependencies = append(dependencies, a.detectMatugen())
|
||||||
dependencies = append(dependencies, a.detectDgop())
|
dependencies = append(dependencies, a.detectDgop())
|
||||||
dependencies = append(dependencies, a.detectClipboardTools()...)
|
|
||||||
|
|
||||||
return dependencies, nil
|
return dependencies, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -185,26 +185,6 @@ func (b *BaseDistribution) detectSpecificTerminal(terminal deps.Terminal) deps.D
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *BaseDistribution) detectClipboardTools() []deps.Dependency {
|
|
||||||
var dependencies []deps.Dependency
|
|
||||||
|
|
||||||
wlClipboard := deps.StatusMissing
|
|
||||||
if b.commandExists("wl-copy") && b.commandExists("wl-paste") {
|
|
||||||
wlClipboard = deps.StatusInstalled
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies = append(dependencies,
|
|
||||||
deps.Dependency{
|
|
||||||
Name: "wl-clipboard",
|
|
||||||
Status: wlClipboard,
|
|
||||||
Description: "Wayland clipboard utilities",
|
|
||||||
Required: true,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
return dependencies
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *BaseDistribution) detectHyprlandTools() []deps.Dependency {
|
func (b *BaseDistribution) detectHyprlandTools() []deps.Dependency {
|
||||||
var dependencies []deps.Dependency
|
var dependencies []deps.Dependency
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ func (d *DebianDistribution) DetectDependenciesWithTerminal(ctx context.Context,
|
|||||||
|
|
||||||
dependencies = append(dependencies, d.detectMatugen())
|
dependencies = append(dependencies, d.detectMatugen())
|
||||||
dependencies = append(dependencies, d.detectDgop())
|
dependencies = append(dependencies, d.detectDgop())
|
||||||
dependencies = append(dependencies, d.detectClipboardTools()...)
|
|
||||||
|
|
||||||
return dependencies, nil
|
return dependencies, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -88,10 +88,8 @@ func (f *FedoraDistribution) DetectDependenciesWithTerminal(ctx context.Context,
|
|||||||
dependencies = append(dependencies, f.detectXwaylandSatellite())
|
dependencies = append(dependencies, f.detectXwaylandSatellite())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Base detections (common across distros)
|
|
||||||
dependencies = append(dependencies, f.detectMatugen())
|
dependencies = append(dependencies, f.detectMatugen())
|
||||||
dependencies = append(dependencies, f.detectDgop())
|
dependencies = append(dependencies, f.detectDgop())
|
||||||
dependencies = append(dependencies, f.detectClipboardTools()...)
|
|
||||||
|
|
||||||
return dependencies, nil
|
return dependencies, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,7 +107,6 @@ func (g *GentooDistribution) DetectDependenciesWithTerminal(ctx context.Context,
|
|||||||
|
|
||||||
dependencies = append(dependencies, g.detectMatugen())
|
dependencies = append(dependencies, g.detectMatugen())
|
||||||
dependencies = append(dependencies, g.detectDgop())
|
dependencies = append(dependencies, g.detectDgop())
|
||||||
dependencies = append(dependencies, g.detectClipboardTools()...)
|
|
||||||
|
|
||||||
return dependencies, nil
|
return dependencies, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,10 +78,8 @@ func (o *OpenSUSEDistribution) DetectDependenciesWithTerminal(ctx context.Contex
|
|||||||
dependencies = append(dependencies, o.detectXwaylandSatellite())
|
dependencies = append(dependencies, o.detectXwaylandSatellite())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Base detections (common across distros)
|
|
||||||
dependencies = append(dependencies, o.detectMatugen())
|
dependencies = append(dependencies, o.detectMatugen())
|
||||||
dependencies = append(dependencies, o.detectDgop())
|
dependencies = append(dependencies, o.detectDgop())
|
||||||
dependencies = append(dependencies, o.detectClipboardTools()...)
|
|
||||||
|
|
||||||
return dependencies, nil
|
return dependencies, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,10 +76,8 @@ func (u *UbuntuDistribution) DetectDependenciesWithTerminal(ctx context.Context,
|
|||||||
dependencies = append(dependencies, u.detectXwaylandSatellite())
|
dependencies = append(dependencies, u.detectXwaylandSatellite())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Base detections (common across distros)
|
|
||||||
dependencies = append(dependencies, u.detectMatugen())
|
dependencies = append(dependencies, u.detectMatugen())
|
||||||
dependencies = append(dependencies, u.detectDgop())
|
dependencies = append(dependencies, u.detectDgop())
|
||||||
dependencies = append(dependencies, u.detectClipboardTools()...)
|
|
||||||
|
|
||||||
return dependencies, nil
|
return dependencies, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ DankModal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function copyColorToClipboard(colorValue) {
|
function copyColorToClipboard(colorValue) {
|
||||||
Quickshell.execDetached(["sh", "-c", `echo -n "${colorValue}" | wl-copy`]);
|
Quickshell.execDetached(["dms", "cl", "copy", colorValue]);
|
||||||
ToastService.showInfo(`Color ${colorValue} copied`);
|
ToastService.showInfo(`Color ${colorValue} copied`);
|
||||||
SessionData.addRecentColor(currentColor);
|
SessionData.addRecentColor(currentColor);
|
||||||
}
|
}
|
||||||
@@ -614,7 +614,7 @@ DankModal {
|
|||||||
} else {
|
} else {
|
||||||
rgbString = `rgb(${r}, ${g}, ${b})`;
|
rgbString = `rgb(${r}, ${g}, ${b})`;
|
||||||
}
|
}
|
||||||
Quickshell.execDetached(["sh", "-c", `echo -n "${rgbString}" | wl-copy`]);
|
Quickshell.execDetached(["dms", "cl", "copy", rgbString]);
|
||||||
ToastService.showInfo(`${rgbString} copied`);
|
ToastService.showInfo(`${rgbString} copied`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -678,7 +678,7 @@ DankModal {
|
|||||||
} else {
|
} else {
|
||||||
hsvString = `${h}, ${s}, ${v}`;
|
hsvString = `${h}, ${s}, ${v}`;
|
||||||
}
|
}
|
||||||
Quickshell.execDetached(["sh", "-c", `echo -n "${hsvString}" | wl-copy`]);
|
Quickshell.execDetached(["dms", "cl", "copy", hsvString]);
|
||||||
ToastService.showInfo(`HSV ${hsvString} copied`);
|
ToastService.showInfo(`HSV ${hsvString} copied`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Controls
|
import QtQuick.Controls
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Io
|
|
||||||
import qs.Common
|
import qs.Common
|
||||||
import qs.Services
|
|
||||||
import qs.Widgets
|
import qs.Widgets
|
||||||
|
|
||||||
Popup {
|
Popup {
|
||||||
@@ -99,13 +97,11 @@ Popup {
|
|||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (processContextMenu.processData) {
|
if (processContextMenu.processData) {
|
||||||
Quickshell.execDetached(["wl-copy", processContextMenu.processData.pid.toString()]);
|
Quickshell.execDetached(["dms", "cl", "copy", processContextMenu.processData.pid.toString()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
processContextMenu.close();
|
processContextMenu.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
@@ -133,12 +129,11 @@ Popup {
|
|||||||
onClicked: {
|
onClicked: {
|
||||||
if (processContextMenu.processData) {
|
if (processContextMenu.processData) {
|
||||||
const processName = processContextMenu.processData.displayName || processContextMenu.processData.command;
|
const processName = processContextMenu.processData.displayName || processContextMenu.processData.command;
|
||||||
Quickshell.execDetached(["wl-copy", processName]);
|
Quickshell.execDetached(["dms", "cl", "copy", processName]);
|
||||||
}
|
}
|
||||||
processContextMenu.close();
|
processContextMenu.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
@@ -153,7 +148,6 @@ Popup {
|
|||||||
height: 1
|
height: 1
|
||||||
color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2)
|
color: Qt.rgba(Theme.outline.r, Theme.outline.g, Theme.outline.b, 0.2)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
@@ -189,7 +183,6 @@ Popup {
|
|||||||
processContextMenu.close();
|
processContextMenu.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
@@ -225,11 +218,7 @@ Popup {
|
|||||||
processContextMenu.close();
|
processContextMenu.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -293,7 +293,7 @@ PanelWindow {
|
|||||||
property bool showTooltip: false
|
property bool showTooltip: false
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
Quickshell.execDetached(["wl-copy", ToastService.currentCommand]);
|
Quickshell.execDetached(["dms", "cl", "copy", ToastService.currentCommand]);
|
||||||
showTooltip = true;
|
showTooltip = true;
|
||||||
tooltipTimer.start();
|
tooltipTimer.start();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ PluginComponent {
|
|||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
Quickshell.execDetached(["sh", "-c", "echo -n '" + modelData + "' | wl-copy"])
|
Quickshell.execDetached(["dms", "cl", "copy", modelData])
|
||||||
ToastService.showInfo("Copied " + modelData + " to clipboard")
|
ToastService.showInfo("Copied " + modelData + " to clipboard")
|
||||||
popoutColumn.closePopout()
|
popoutColumn.closePopout()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
- **Cycling Emojis**: Automatically rotates through your selected emoji set in the bar
|
||||||
- **Emoji Picker**: Click the widget to open a grid of 120+ emojis
|
- **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
|
- **Customizable**: Choose emoji sets, cycle speed, and max emojis shown
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
@@ -38,10 +38,6 @@ How many emojis to display at once (1-8)
|
|||||||
**Click the widget**: Opens emoji picker with 120+ emojis
|
**Click the widget**: Opens emoji picker with 120+ emojis
|
||||||
**Click any emoji**: Copies it to clipboard and shows toast
|
**Click any emoji**: Copies it to clipboard and shows toast
|
||||||
|
|
||||||
## Requirements
|
|
||||||
|
|
||||||
- `wl-copy` (for clipboard support on Wayland)
|
|
||||||
|
|
||||||
## Example Code Highlights
|
## Example Code Highlights
|
||||||
|
|
||||||
This plugin demonstrates:
|
This plugin demonstrates:
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function copyToClipboard(text) {
|
function copyToClipboard(text) {
|
||||||
Quickshell.execDetached(["sh", "-c", "echo -n '" + text + "' | wl-copy"])
|
Quickshell.execDetached(["dms", "cl", "copy", text])
|
||||||
showToast("Copied to clipboard: " + text)
|
showToast("Copied to clipboard: " + text)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ The manifest file defines plugin metadata and configuration.
|
|||||||
- `icon`: Material Design icon name (displayed in UI)
|
- `icon`: Material Design icon name (displayed in UI)
|
||||||
- `settings`: Path to settings component (enables settings UI)
|
- `settings`: Path to settings component (enables settings UI)
|
||||||
- `requires_dms`: Minimum DMS version requirement (e.g., ">=0.1.18", ">0.1.0")
|
- `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`: Required DMS permissions (e.g., ["settings_read", "settings_write"])
|
||||||
|
|
||||||
**Permissions:**
|
**Permissions:**
|
||||||
@@ -860,11 +860,11 @@ Or edit `$CONFIGPATH/quickshell/dms/config.json`:
|
|||||||
|
|
||||||
## Clipboard Access
|
## 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
|
### Correct Method
|
||||||
|
|
||||||
Import Quickshell and use `execDetached` with `wl-copy`:
|
Import Quickshell and use `execDetached` with `dms cl copy`:
|
||||||
|
|
||||||
```qml
|
```qml
|
||||||
import QtQuick
|
import QtQuick
|
||||||
@@ -872,19 +872,19 @@ import Quickshell
|
|||||||
|
|
||||||
Item {
|
Item {
|
||||||
function copyToClipboard(text) {
|
function copyToClipboard(text) {
|
||||||
Quickshell.execDetached(["sh", "-c", "echo -n '" + text + "' | wl-copy"])
|
Quickshell.execDetached(["dms", "cl", "copy", text])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### Example Usage
|
### Example Usage
|
||||||
|
|
||||||
From the ExampleEmojiPlugin (EmojiWidget.qml:136):
|
From the ExampleEmojiPlugin (EmojiWidget.qml):
|
||||||
|
|
||||||
```qml
|
```qml
|
||||||
MouseArea {
|
MouseArea {
|
||||||
onClicked: {
|
onClicked: {
|
||||||
Quickshell.execDetached(["sh", "-c", "echo -n '" + modelData + "' | wl-copy"])
|
Quickshell.execDetached(["dms", "cl", "copy", modelData])
|
||||||
ToastService.showInfo("Copied " + modelData + " to clipboard")
|
ToastService.showInfo("Copied " + modelData + " to clipboard")
|
||||||
popoutColumn.closePopout()
|
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
|
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
|
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
|
3. Consider showing a toast notification to confirm the copy action to users
|
||||||
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
|
|
||||||
|
|
||||||
### Dependencies
|
### 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
|
## Running External Commands
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user