Merge branch 'main' of github.com:noctalia-dev/noctalia-shell
This commit is contained in:
commit
69a5f0c2c0
2 changed files with 69 additions and 11 deletions
|
|
@ -186,7 +186,7 @@ Singleton {
|
||||||
// applauncher
|
// applauncher
|
||||||
property JsonObject appLauncher: JsonObject {
|
property JsonObject appLauncher: JsonObject {
|
||||||
// When disabled, Launcher hides clipboard command and ignores cliphist
|
// When disabled, Launcher hides clipboard command and ignores cliphist
|
||||||
property bool enableClipboardHistory: true
|
property bool enableClipboardHistory: false
|
||||||
// Position: center, top_left, top_right, bottom_left, bottom_right, bottom_center, top_center
|
// Position: center, top_left, top_right, bottom_left, bottom_right, bottom_center, top_center
|
||||||
property string position: "center"
|
property string position: "center"
|
||||||
property real backgroundOpacity: 1.0
|
property real backgroundOpacity: 1.0
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,12 @@ Singleton {
|
||||||
// Public API
|
// Public API
|
||||||
property var items: [] // [{id, preview, mime, isImage}]
|
property var items: [] // [{id, preview, mime, isImage}]
|
||||||
property bool loading: false
|
property bool loading: false
|
||||||
// Active only when feature is enabled and settings have finished initial load
|
// Active only when feature is enabled, settings have finished initial load, and cliphist is available
|
||||||
property bool active: Settings.data.appLauncher.enableClipboardHistory && Settings.isLoaded
|
property bool active: Settings.data.appLauncher.enableClipboardHistory && Settings.isLoaded && cliphistAvailable
|
||||||
|
|
||||||
|
// Check if cliphist is available on the system
|
||||||
|
property bool cliphistAvailable: false
|
||||||
|
property bool dependencyChecked: false
|
||||||
|
|
||||||
// Optional automatic watchers to feed cliphist DB
|
// Optional automatic watchers to feed cliphist DB
|
||||||
property bool autoWatch: true
|
property bool autoWatch: true
|
||||||
|
|
@ -32,13 +36,48 @@ Singleton {
|
||||||
property string _b64CurrentMime: ""
|
property string _b64CurrentMime: ""
|
||||||
property string _b64CurrentId: ""
|
property string _b64CurrentId: ""
|
||||||
|
|
||||||
// Start/stop watchers when enabled changes
|
// Check if cliphist is available
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (root.active)
|
checkCliphistAvailability()
|
||||||
startWatchers()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check dependency availability
|
||||||
|
function checkCliphistAvailability() {
|
||||||
|
if (dependencyChecked)
|
||||||
|
return
|
||||||
|
|
||||||
|
dependencyCheckProcess.command = ["which", "cliphist"]
|
||||||
|
dependencyCheckProcess.running = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// Process to check if cliphist is available
|
||||||
|
Process {
|
||||||
|
id: dependencyCheckProcess
|
||||||
|
stdout: StdioCollector {}
|
||||||
|
onExited: (exitCode, exitStatus) => {
|
||||||
|
root.dependencyChecked = true
|
||||||
|
if (exitCode === 0) {
|
||||||
|
root.cliphistAvailable = true
|
||||||
|
// Start watchers if feature is enabled
|
||||||
|
if (root.active) {
|
||||||
|
startWatchers()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
root.cliphistAvailable = false
|
||||||
|
// Show toast notification if feature is enabled but cliphist is missing
|
||||||
|
if (Settings.data.appLauncher.enableClipboardHistory) {
|
||||||
|
ToastService.showWarning(
|
||||||
|
"Clipboard History Unavailable",
|
||||||
|
"The 'cliphist' application is not installed. Please install it to use clipboard history features.",
|
||||||
|
false, 6000)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start/stop watchers when enabled changes
|
||||||
onActiveChanged: {
|
onActiveChanged: {
|
||||||
if (root.active) {
|
if (root.active && root.cliphistAvailable) {
|
||||||
startWatchers()
|
startWatchers()
|
||||||
} else {
|
} else {
|
||||||
stopWatchers()
|
stopWatchers()
|
||||||
|
|
@ -52,7 +91,7 @@ Singleton {
|
||||||
Timer {
|
Timer {
|
||||||
interval: 5000
|
interval: 5000
|
||||||
repeat: true
|
repeat: true
|
||||||
running: root.active
|
running: root.active && root.cliphistAvailable
|
||||||
onTriggered: list()
|
onTriggered: list()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -173,7 +212,7 @@ Singleton {
|
||||||
}
|
}
|
||||||
|
|
||||||
function startWatchers() {
|
function startWatchers() {
|
||||||
if (!root.active || !autoWatch || watchersStarted)
|
if (!root.active || !autoWatch || watchersStarted || !root.cliphistAvailable)
|
||||||
return
|
return
|
||||||
watchersStarted = true
|
watchersStarted = true
|
||||||
// Start text watcher
|
// Start text watcher
|
||||||
|
|
@ -193,7 +232,7 @@ Singleton {
|
||||||
}
|
}
|
||||||
|
|
||||||
function list(maxPreviewWidth) {
|
function list(maxPreviewWidth) {
|
||||||
if (!root.active) {
|
if (!root.active || !root.cliphistAvailable) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (listProc.running)
|
if (listProc.running)
|
||||||
|
|
@ -205,12 +244,22 @@ Singleton {
|
||||||
}
|
}
|
||||||
|
|
||||||
function decode(id, cb) {
|
function decode(id, cb) {
|
||||||
|
if (!root.cliphistAvailable) {
|
||||||
|
if (cb)
|
||||||
|
cb("")
|
||||||
|
return
|
||||||
|
}
|
||||||
root._decodeCallback = cb
|
root._decodeCallback = cb
|
||||||
decodeProc.command = ["cliphist", "decode", id]
|
decodeProc.command = ["cliphist", "decode", id]
|
||||||
decodeProc.running = true
|
decodeProc.running = true
|
||||||
}
|
}
|
||||||
|
|
||||||
function decodeToDataUrl(id, mime, cb) {
|
function decodeToDataUrl(id, mime, cb) {
|
||||||
|
if (!root.cliphistAvailable) {
|
||||||
|
if (cb)
|
||||||
|
cb("")
|
||||||
|
return
|
||||||
|
}
|
||||||
// If cached, return immediately
|
// If cached, return immediately
|
||||||
if (root.imageDataById[id]) {
|
if (root.imageDataById[id]) {
|
||||||
if (cb)
|
if (cb)
|
||||||
|
|
@ -229,7 +278,7 @@ Singleton {
|
||||||
}
|
}
|
||||||
|
|
||||||
function _startNextB64() {
|
function _startNextB64() {
|
||||||
if (root._b64Queue.length === 0)
|
if (root._b64Queue.length === 0 || !root.cliphistAvailable)
|
||||||
return
|
return
|
||||||
const job = root._b64Queue.shift()
|
const job = root._b64Queue.shift()
|
||||||
root._b64CurrentCb = job.cb
|
root._b64CurrentCb = job.cb
|
||||||
|
|
@ -240,17 +289,26 @@ Singleton {
|
||||||
}
|
}
|
||||||
|
|
||||||
function copyToClipboard(id) {
|
function copyToClipboard(id) {
|
||||||
|
if (!root.cliphistAvailable) {
|
||||||
|
return
|
||||||
|
}
|
||||||
// decode and pipe to wl-copy; implement via shell to preserve binary
|
// decode and pipe to wl-copy; implement via shell to preserve binary
|
||||||
copyProc.command = ["sh", "-lc", `cliphist decode ${id} | wl-copy`]
|
copyProc.command = ["sh", "-lc", `cliphist decode ${id} | wl-copy`]
|
||||||
copyProc.running = true
|
copyProc.running = true
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteById(id) {
|
function deleteById(id) {
|
||||||
|
if (!root.cliphistAvailable) {
|
||||||
|
return
|
||||||
|
}
|
||||||
Quickshell.execDetached(["cliphist", "delete", id])
|
Quickshell.execDetached(["cliphist", "delete", id])
|
||||||
Qt.callLater(() => list())
|
Qt.callLater(() => list())
|
||||||
}
|
}
|
||||||
|
|
||||||
function wipeAll() {
|
function wipeAll() {
|
||||||
|
if (!root.cliphistAvailable) {
|
||||||
|
return
|
||||||
|
}
|
||||||
Quickshell.execDetached(["cliphist", "wipe"])
|
Quickshell.execDetached(["cliphist", "wipe"])
|
||||||
Qt.callLater(() => list())
|
Qt.callLater(() => list())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue