mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-29 16:02:51 -05:00
@@ -11,14 +11,16 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"hash/fnv"
|
||||||
|
|
||||||
"github.com/fsnotify/fsnotify"
|
"github.com/fsnotify/fsnotify"
|
||||||
_ "golang.org/x/image/bmp"
|
_ "golang.org/x/image/bmp"
|
||||||
_ "golang.org/x/image/tiff"
|
_ "golang.org/x/image/tiff"
|
||||||
"hash/fnv"
|
|
||||||
|
|
||||||
bolt "go.etcd.io/bbolt"
|
bolt "go.etcd.io/bbolt"
|
||||||
|
|
||||||
@@ -28,6 +30,11 @@ import (
|
|||||||
wlclient "github.com/AvengeMedia/DankMaterialShell/core/pkg/go-wayland/wayland/client"
|
wlclient "github.com/AvengeMedia/DankMaterialShell/core/pkg/go-wayland/wayland/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// These mime types wont be stored in history
|
||||||
|
var sensitiveMimeTypes = []string{
|
||||||
|
"x-kde-passwordManagerHint",
|
||||||
|
}
|
||||||
|
|
||||||
func NewManager(wlCtx wlcontext.WaylandContext, config Config) (*Manager, error) {
|
func NewManager(wlCtx wlcontext.WaylandContext, config Config) (*Manager, error) {
|
||||||
if config.Disabled {
|
if config.Disabled {
|
||||||
return nil, fmt.Errorf("clipboard disabled in config")
|
return nil, fmt.Errorf("clipboard disabled in config")
|
||||||
@@ -253,6 +260,10 @@ func (m *Manager) setupDataDeviceSync() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if m.hasSensitiveMimeType(mimes) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
preferredMime := m.selectMimeType(mimes)
|
preferredMime := m.selectMimeType(mimes)
|
||||||
if preferredMime == "" {
|
if preferredMime == "" {
|
||||||
return
|
return
|
||||||
@@ -492,6 +503,12 @@ func extractHash(data []byte) uint64 {
|
|||||||
return binary.BigEndian.Uint64(data[len(data)-8:])
|
return binary.BigEndian.Uint64(data[len(data)-8:])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *Manager) hasSensitiveMimeType(mimes []string) bool {
|
||||||
|
return slices.ContainsFunc(mimes, func(mime string) bool {
|
||||||
|
return slices.Contains(sensitiveMimeTypes, mime)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func (m *Manager) selectMimeType(mimes []string) string {
|
func (m *Manager) selectMimeType(mimes []string) string {
|
||||||
preferredTypes := []string{
|
preferredTypes := []string{
|
||||||
"text/plain;charset=utf-8",
|
"text/plain;charset=utf-8",
|
||||||
|
|||||||
Reference in New Issue
Block a user