update ags

This commit is contained in:
2023-11-15 16:09:26 +01:00
parent a6292fe031
commit 73e2b949a0
4025 changed files with 3168562 additions and 5715 deletions

View File

@@ -1,75 +1,85 @@
const { Gdk, Gtk } = imports.gi;
import { App, Service, Utils, Widget } from '../imports.js';
import Applications from 'resource:///com/github/Aylur/ags/service/applications.js';
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
const { execAsync, exec } = Utils;
const { Box, EventBox, Button, Label, Scrollable } = Widget;
const {Gdk, Gtk} = imports.gi
import {App, Service, Utils, Widget} from "../imports.js"
import Applications from "resource:///com/github/Aylur/ags/service/applications.js"
import Hyprland from "resource:///com/github/Aylur/ags/service/hyprland.js"
const {execAsync, exec} = Utils
const {Box, EventBox, Button, Label, Scrollable} = Widget
const CLIPBOARD_SHOWN_ENTRIES = 20;
const CLIPBOARD_SHOWN_ENTRIES = 20
const ClipboardItems = () => {
return Box({
vertical: true,
className: 'spacing-v-5',
connections: [
[App, (box, name, visible) => {
if (name != 'sideleft')
return;
return Box({
vertical: true,
className: "spacing-v-5",
connections: [
[
App,
(box, name, visible) => {
if (name != "sideleft") return
let clipboardContents = exec('cliphist list'); // Output is lines like this: 1000 copied text
clipboardContents = clipboardContents.split('\n');
let clipboardContents = exec("cliphist list") // Output is lines like this: 1000 copied text
clipboardContents = clipboardContents.split("\n")
// console.log(clipboardContents);
// console.log(`bash -c 'echo "${clipboardContents[0]}" | sed "s/ /\\t/" | cliphist decode'`);
// console.log(exec(`bash -c 'echo "${clipboardContents[0]}" | sed "s/ /\\t/" | cliphist decode'`));
// console.log(clipboardContents);
// console.log(`bash -c 'echo "${clipboardContents[0]}" | sed "s/ /\\t/" | cliphist decode'`);
// console.log(exec(`bash -c 'echo "${clipboardContents[0]}" | sed "s/ /\\t/" | cliphist decode'`));
box.children = clipboardContents.map((text, i) => {
if (i >= CLIPBOARD_SHOWN_ENTRIES) return;
return Button({
onClicked: () => {
print(`bash` + `-c` + `echo "${clipboardContents[i]}" | sed "s/ /\\\t/" | cliphist decode | wl-copy`);
execAsync(`bash`, `-c`, `echo "${clipboardContents[i]}" | sed "s/ /\\\t/" | cliphist decode | wl-copy`).catch(print);
App.closeWindow('sideleft');
},
className: 'sidebar-clipboard-item',
child: Box({
children: [
Label({
label: text,
className: 'txt-small',
truncate: 'end',
})
]
})
})
});
}]
]
});
box.children = clipboardContents.map((text, i) => {
if (i >= CLIPBOARD_SHOWN_ENTRIES) return
return Button({
onClicked: () => {
print(
`bash` +
`-c` +
`echo "${clipboardContents[i]}" | sed "s/ /\\\t/" | cliphist decode | wl-copy`,
)
execAsync(
`bash`,
`-c`,
`echo "${clipboardContents[i]}" | sed "s/ /\\\t/" | cliphist decode | wl-copy`,
).catch(print)
App.closeWindow("sideleft")
},
className: "sidebar-clipboard-item",
child: Box({
children: [
Label({
label: text,
className: "txt-small",
truncate: "end",
}),
],
}),
})
})
},
],
],
})
}
export default () => Box({
export default () =>
Box({
vertical: true,
children: [
EventBox({
onPrimaryClick: () => App.closeWindow('sideleft'),
onSecondaryClick: () => App.closeWindow('sideleft'),
onMiddleClick: () => App.closeWindow('sideleft'),
}),
ClipboardItems(),
// Box({
// vertical: true,
// vexpand: true,
// className: 'sidebar-left',
// children: [
// Widget.Box({
// className: 'spacing-v-5',
// children: [
// ClipboardItems(),
// ]
// })
// ],
// }),
]
});
EventBox({
onPrimaryClick: () => App.closeWindow("sideleft"),
onSecondaryClick: () => App.closeWindow("sideleft"),
onMiddleClick: () => App.closeWindow("sideleft"),
}),
ClipboardItems(),
// Box({
// vertical: true,
// vexpand: true,
// className: 'sidebar-left',
// children: [
// Widget.Box({
// className: 'spacing-v-5',
// children: [
// ClipboardItems(),
// ]
// })
// ],
// }),
],
})