From 3ef08f0c2258f38db8c373989c71e1be4d70ae34 Mon Sep 17 00:00:00 2001 From: S4NKALP Date: Sat, 20 Jul 2024 13:29:40 +0545 Subject: [PATCH] updates --- config/ags/modules/sideleft/applauncher.ts | 2 +- config/ags/modules/sideleft/cliphist.ts | 61 ++++++++++++---------- 2 files changed, 35 insertions(+), 28 deletions(-) diff --git a/config/ags/modules/sideleft/applauncher.ts b/config/ags/modules/sideleft/applauncher.ts index 9e0577d7..454d5624 100644 --- a/config/ags/modules/sideleft/applauncher.ts +++ b/config/ags/modules/sideleft/applauncher.ts @@ -75,7 +75,7 @@ function AppItem(app: Application): Box { button.connect("clicked", () => { clickCount++; - if (clickCount === 2) { + if (clickCount === 1) { incrementLaunchCount(app.name); App.closeWindow(WINDOW_NAME); app.launch(); diff --git a/config/ags/modules/sideleft/cliphist.ts b/config/ags/modules/sideleft/cliphist.ts index 270fdd70..8437cb60 100644 --- a/config/ags/modules/sideleft/cliphist.ts +++ b/config/ags/modules/sideleft/cliphist.ts @@ -35,25 +35,6 @@ async function clearClipboardHistory() { } } -async function copyById(id) { - try { - const command = `${App.configDir}/scripts/cliphist.sh --copy-by-id ${id}`; - const entry = await Utils.execAsync(command); - - if (!entry) return; - - const process = new Gio.Subprocess({ - argv: ['bash', '-c', `echo "${entry.trim()}" | wl-copy`], - flags: Gio.SubprocessFlags.STDOUT_PIPE | Gio.SubprocessFlags.STDERR_PIPE - }); - - process.init(null); - await process.communicate_utf8(null, null); - } catch (error) { - // Handle error silently or log to a file if needed - } -} - function ClipHistItem(entry) { const [id, ...content] = entry.split("\t"); let clickCount = 0; @@ -61,9 +42,25 @@ function ClipHistItem(entry) { class_name: "clip_container", child: Widget.Box({ children: [ - Widget.Label({ label: id, class_name: "clip_id", xalign: 0, vpack: "center" }), - Widget.Label({ label: "・", class_name: "dot_divider", xalign: 0, vpack: "center" }), - Widget.Label({ label: content.join(" ").trim(), class_name: "clip_label", xalign: 0, vpack: "center", truncate: "end" }) + Widget.Label({ + label: id, + class_name: "clip_id", + xalign: 0, + vpack: "center" + }), + Widget.Label({ + label: "・", + class_name: "dot_divider", + xalign: 0, + vpack: "center" + }), + Widget.Label({ + label: content.join(" ").trim(), + class_name: "clip_label", + xalign: 0, + vpack: "center", + truncate: "end" + }) ] }) }); @@ -71,9 +68,9 @@ function ClipHistItem(entry) { button.connect("clicked", async () => { try { clickCount++; - if (clickCount === 2) { - await copyById(id); + if (clickCount === 1) { App.closeWindow(WINDOW_NAME); + Utils.execAsync(`${App.configDir}/scripts/cliphist.sh --copy-by-id ${id}`); clickCount = 0; } } catch (error) { @@ -90,14 +87,20 @@ function ClipHistItem(entry) { orientation: Gtk.Orientation.VERTICAL, children: [ button, - Widget.Separator({ class_name: "clip_divider", orientation: Gtk.Orientation.HORIZONTAL }) + Widget.Separator({ + class_name: "clip_divider", + orientation: Gtk.Orientation.HORIZONTAL + }) ] }); } export const cliphist = () => { const list = Widget.Box({ vertical: true, vexpand: true }); - const loadingIndicator = Widget.Label({ label: "Loading...", class_name: "loading" }); + const loadingIndicator = Widget.Label({ + label: "Loading...", + class_name: "loading" + }); list.children = [loadingIndicator]; async function repopulate() { @@ -110,7 +113,11 @@ export const cliphist = () => { } } catch (error) { - list.children = [Widget.Label({ label: "Error loading history", class_name: "error_loading" })]; + list.children = [Widget.Label ({ + label: "Error loading history", + class_name: "error_loading" + }) + ]; } }