diff --git a/nixosModules/ags/v2/app.ts b/nixosModules/ags/v2/app.ts index 2552284f..69fd1ab9 100644 --- a/nixosModules/ags/v2/app.ts +++ b/nixosModules/ags/v2/app.ts @@ -8,6 +8,7 @@ import AppLauncher from './widgets/applauncher/main'; import Bar from './widgets/bar/wim'; import BgFade from './widgets/bg-fade/main'; import Calendar from './widgets/date/main'; +import Clipboard from './widgets/clipboard/main'; import Corners from './widgets/corners/main'; import IconBrowser from './widgets/icon-browser/main'; import { NotifPopups, NotifCenter } from './widgets/notifs/main'; @@ -59,6 +60,7 @@ switch (CONF) { Bar(); BgFade(); Calendar(); + Clipboard(); Corners(); IconBrowser(); NotifPopups(); diff --git a/nixosModules/ags/v2/style.scss b/nixosModules/ags/v2/style.scss index 0203084e..af07abc2 100644 --- a/nixosModules/ags/v2/style.scss +++ b/nixosModules/ags/v2/style.scss @@ -40,6 +40,7 @@ progressbar { @import 'widgets/applauncher/style.scss'; @import 'widgets/bar/style.scss'; +@import 'widgets/clipboard/style.scss'; @import 'widgets/date/style.scss'; @import 'widgets/icon-browser/style.scss'; @import 'widgets/lockscreen/style.scss'; diff --git a/nixosModules/ags/v2/widgets/clipboard/clip-item.tsx b/nixosModules/ags/v2/widgets/clipboard/clip-item.tsx new file mode 100644 index 00000000..dea0f33b --- /dev/null +++ b/nixosModules/ags/v2/widgets/clipboard/clip-item.tsx @@ -0,0 +1,96 @@ +import { execAsync } from 'astal'; +import { register } from 'astal/gobject'; +import { Gtk, Widget } from 'astal/gtk3'; + +export interface EntryObject { + id: number + content: string + entry: string +} + +const SCALE = 150; +const BINARY_DATA = /\[\[ binary data (\d+) (KiB|MiB) (\w+) (\d+)x(\d+) \]\]/; + +export const CLIP_SCRIPT = `${SRC}/widgets/clipboard/cliphist.sh`; + +@register() +export class ClipItem extends Widget.Box { + declare id: number; + declare content: string; + + public show_image(file: string, width: string | number, height: string | number) { + this.children[2].destroy(); + + const initCss = () => { + const _widthPx = Number(width); + const heightPx = Number(height); + const maxWidth = 400; + const widthPx = (_widthPx / heightPx) * SCALE; + + let css = `background-image: url("${file}");`; + + if (widthPx > maxWidth) { + const newHeightPx = (SCALE / widthPx) * maxWidth; + + css += `min-height: ${newHeightPx}px; min-width: ${maxWidth}px;`; + } + else { + css += `min-height: 150px; min-width: ${widthPx}px;`; + } + + return css; + }; + + const icon = ( + + ); + + this.children = [...this.children, icon]; + }; + + constructor({ item }: { item: EntryObject }) { + super({ + children: [ +