forked from Shinonome/dots-hyprland
ags: sync
This commit is contained in:
@@ -10,7 +10,13 @@ const SysTrayItem = item => Button({
|
||||
className: 'bar-systray-item',
|
||||
child: Icon({
|
||||
hpack: 'center',
|
||||
binds: [['icon', item, 'icon']]
|
||||
binds: [['icon', item, 'icon']],
|
||||
setup: (self) => Utils.timeout(1, () => {
|
||||
const styleContext = self.get_parent().get_style_context();
|
||||
const width = styleContext.get_property('min-width', Gtk.StateFlags.NORMAL);
|
||||
const height = styleContext.get_property('min-height', Gtk.StateFlags.NORMAL);
|
||||
self.size = Math.max(width, height, 1); // im too lazy to add another box lol
|
||||
}),
|
||||
}),
|
||||
binds: [['tooltipMarkup', item, 'tooltip-markup']],
|
||||
onClicked: btn => item.menu.popup_at_widget(btn, Gravity.SOUTH, Gravity.NORTH, null),
|
||||
@@ -19,8 +25,7 @@ const SysTrayItem = item => Button({
|
||||
|
||||
export const Tray = (props = {}) => {
|
||||
const trayContent = Box({
|
||||
vpack: 'center',
|
||||
className: 'bar-systray bar-group',
|
||||
className: 'bar-systray bar-group spacing-h-10',
|
||||
properties: [
|
||||
['items', new Map()],
|
||||
['onAdded', (box, id) => {
|
||||
@@ -31,7 +36,7 @@ export const Tray = (props = {}) => {
|
||||
return;
|
||||
const widget = SysTrayItem(item);
|
||||
box._items.set(id, widget);
|
||||
box.pack_start(widget, false, false, 0);
|
||||
box.add(widget);
|
||||
box.show_all();
|
||||
if (box._items.size === 1)
|
||||
trayRevealer.revealChild = true;
|
||||
|
||||
@@ -2,34 +2,32 @@
|
||||
const { GLib, Gtk } = imports.gi;
|
||||
import { App, Service, Utils, Widget } from '../../imports.js';
|
||||
import Audio from 'resource:///com/github/Aylur/ags/service/audio.js';
|
||||
import Notifications from 'resource:///com/github/Aylur/ags/service/notifications.js';
|
||||
const { Box, EventBox, Icon, Scrollable, Label, Button, Revealer } = Widget;
|
||||
const { Box, Label, ProgressBar, Revealer } = Widget;
|
||||
import Brightness from '../../services/brightness.js';
|
||||
import Indicator from '../../services/indicator.js';
|
||||
import Notification from '../../lib/notification.js';
|
||||
|
||||
const OsdValue = (name, labelConnections, progressConnections, props = {}) => Widget.Box({ // Volume
|
||||
const OsdValue = (name, labelConnections, progressConnections, props = {}) => Box({ // Volume
|
||||
...props,
|
||||
vertical: true,
|
||||
className: 'osd-bg osd-value',
|
||||
hexpand: true,
|
||||
children: [
|
||||
Widget.Box({
|
||||
Box({
|
||||
vexpand: true,
|
||||
children: [
|
||||
Widget.Label({
|
||||
Label({
|
||||
xalign: 0, yalign: 0, hexpand: true,
|
||||
className: 'osd-label',
|
||||
label: `${name}`,
|
||||
}),
|
||||
Widget.Label({
|
||||
Label({
|
||||
hexpand: false, className: 'osd-value-txt',
|
||||
label: '100',
|
||||
connections: labelConnections,
|
||||
}),
|
||||
]
|
||||
}),
|
||||
Widget.ProgressBar({
|
||||
ProgressBar({
|
||||
className: 'osd-progress',
|
||||
hexpand: true,
|
||||
vertical: false,
|
||||
@@ -58,14 +56,14 @@ const volumeIndicator = OsdValue('Volume',
|
||||
}]],
|
||||
);
|
||||
|
||||
export default () => Widget.Revealer({
|
||||
export default () => Revealer({
|
||||
transition: 'slide_down',
|
||||
connections: [
|
||||
[Indicator, (revealer, value) => {
|
||||
revealer.revealChild = (value > -1);
|
||||
}, 'popup'],
|
||||
],
|
||||
child: Widget.Box({
|
||||
child: Box({
|
||||
hpack: 'center',
|
||||
vertical: false,
|
||||
children: [
|
||||
|
||||
@@ -10,6 +10,7 @@ export default (monitor) => Widget.Window({
|
||||
monitor,
|
||||
className: 'indicator',
|
||||
layer: 'overlay',
|
||||
// exclusivity: 'ignore',
|
||||
visible: true,
|
||||
anchor: ['top'],
|
||||
child: Widget.EventBox({
|
||||
@@ -18,6 +19,7 @@ export default (monitor) => Widget.Window({
|
||||
},
|
||||
child: Widget.Box({
|
||||
vertical: true,
|
||||
className: 'osd-window',
|
||||
css: 'min-height: 2px;',
|
||||
children: [
|
||||
IndicatorValues(),
|
||||
@@ -28,3 +30,4 @@ export default (monitor) => Widget.Window({
|
||||
})
|
||||
}),
|
||||
});
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import Applications from 'resource:///com/github/Aylur/ags/service/applications.
|
||||
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
|
||||
const { execAsync, exec } = Utils;
|
||||
import { setupCursorHover, setupCursorHoverGrab } from "../../lib/cursorhover.js";
|
||||
import { DoubleRevealer } from "../../lib/doublerevealer.js";
|
||||
import { DoubleRevealer } from "../../lib/advancedrevealers.js";
|
||||
import { execAndClose, expandTilde, hasUnterminatedBackslash, startsWithNumber, launchCustomCommand, ls } from './miscfunctions.js';
|
||||
import {
|
||||
CalculationResultButton, CustomCommandButton, DirectoryButton,
|
||||
|
||||
@@ -8,6 +8,7 @@ import { setupCursorHover, setupCursorHoverInfo } from "../../../lib/cursorhover
|
||||
import { SystemMessage, ChatMessage } from "./chatgpt_chatmessage.js";
|
||||
import { ConfigToggle, ConfigSegmentedSelection, ConfigGap } from '../../../lib/configwidgets.js';
|
||||
import { markdownTest } from '../../../lib/md2pango.js';
|
||||
import { MarginRevealer } from '../../../lib/advancedrevealers.js';
|
||||
|
||||
export const chatGPTTabIcon = Box({
|
||||
hpack: 'center',
|
||||
@@ -60,16 +61,15 @@ const chatGPTInfo = Box({
|
||||
]
|
||||
})
|
||||
|
||||
export const chatGPTSettings = Revealer({
|
||||
export const chatGPTSettings = MarginRevealer({
|
||||
transition: 'slide_down',
|
||||
transitionDuration: 150,
|
||||
revealChild: true,
|
||||
connections: [
|
||||
[ChatGPT, (self) => Utils.timeout(200, () => {
|
||||
self.revealChild = false;
|
||||
self._hide(self);
|
||||
}), 'newMsg'],
|
||||
[ChatGPT, (self) => Utils.timeout(200, () => {
|
||||
self.revealChild = true;
|
||||
self._show(self);
|
||||
}), 'clear'],
|
||||
],
|
||||
child: Box({
|
||||
@@ -249,6 +249,16 @@ export const chatGPTSendMessage = (text) => {
|
||||
if (text.startsWith('/')) {
|
||||
if (text.startsWith('/clear')) clearChat();
|
||||
else if (text.startsWith('/model')) chatContent.add(SystemMessage(`Currently using \`${ChatGPT.modelName}\``, '/model', chatGPTView))
|
||||
else if (text.startsWith('/prompt')) {
|
||||
const firstSpaceIndex = text.indexOf(' ');
|
||||
const prompt = text.slice(firstSpaceIndex + 1);
|
||||
if (firstSpaceIndex == -1 || prompt.length < 1) {
|
||||
chatContent.add(SystemMessage(`Usage: \`/prompt MESSAGE\``, '/prompt', chatGPTView))
|
||||
}
|
||||
else {
|
||||
ChatGPT.addMessage('user', prompt)
|
||||
}
|
||||
}
|
||||
else if (text.startsWith('/key')) {
|
||||
const parts = text.split(' ');
|
||||
if (parts.length == 1) chatContent.add(SystemMessage(
|
||||
|
||||
@@ -9,7 +9,7 @@ import GtkSource from "gi://GtkSource?version=3.0";
|
||||
const CUSTOM_SOURCEVIEW_SCHEME_PATH = `${App.configDir}/data/sourceviewtheme.xml`;
|
||||
const CUSTOM_SCHEME_ID = 'custom';
|
||||
const USERNAME = GLib.get_user_name();
|
||||
const CHATGPT_CURSOR = ' >> ';
|
||||
const CHATGPT_CURSOR = ' (o) ';
|
||||
const MESSAGE_SCROLL_DELAY = 13; // In milliseconds, the time before an updated message scrolls to bottom
|
||||
|
||||
/////////////////////// Custom source view colorscheme /////////////////////////
|
||||
@@ -92,10 +92,6 @@ const CodeBlock = (content = '', lang = 'txt') => {
|
||||
}),
|
||||
Button({
|
||||
className: 'sidebar-chat-codeblock-topbar-btn',
|
||||
onClicked: (self) => {
|
||||
// execAsync(['bash', '-c', `wl-copy '${content}'`, `&`]).catch(print);
|
||||
execAsync([`wl-copy`, `${sourceView.label}`]).catch(print);
|
||||
},
|
||||
child: Box({
|
||||
className: 'spacing-h-5',
|
||||
children: [
|
||||
@@ -104,8 +100,13 @@ const CodeBlock = (content = '', lang = 'txt') => {
|
||||
label: 'Copy',
|
||||
})
|
||||
]
|
||||
})
|
||||
})
|
||||
}),
|
||||
onClicked: (self) => {
|
||||
const copyContent = sourceView.get_buffer().get_text(0, 0, 0); // TODO: fix this
|
||||
console.log(copyContent);
|
||||
execAsync([`wl-copy`, `${copyContent}`]).catch(print);
|
||||
},
|
||||
}),
|
||||
]
|
||||
})
|
||||
// Source view
|
||||
|
||||
@@ -4,6 +4,7 @@ const { Box, Button, Entry, EventBox, Icon, Label, Revealer, Scrollable, Stack }
|
||||
const { execAsync, exec } = Utils;
|
||||
import { MaterialIcon } from "../../../lib/materialicon.js";
|
||||
import { setupCursorHover, setupCursorHoverInfo } from "../../../lib/cursorhover.js";
|
||||
import WaifuService from '../../../services/waifus.js';
|
||||
|
||||
export const waifuTabIcon = Box({
|
||||
hpack: 'center',
|
||||
@@ -14,12 +15,27 @@ export const waifuTabIcon = Box({
|
||||
]
|
||||
});
|
||||
|
||||
const waifuContent = Box({
|
||||
className: 'spacing-v-15',
|
||||
vertical: true,
|
||||
connections: [
|
||||
[WaifuService, (box, id) => {
|
||||
const message = WaifuService.responses[id];
|
||||
if (!message) return;
|
||||
box.add(Label({
|
||||
label: message,
|
||||
}))
|
||||
}, 'newResponse'],
|
||||
]
|
||||
});
|
||||
|
||||
export const waifuView = Scrollable({
|
||||
className: 'sidebar-chat-viewport',
|
||||
vexpand: true,
|
||||
child: Box({
|
||||
vertical: true,
|
||||
children: [
|
||||
waifuContent,
|
||||
]
|
||||
}),
|
||||
setup: (scrolledWindow) => {
|
||||
@@ -45,11 +61,12 @@ export const waifuCommands = Box({
|
||||
// command do something
|
||||
},
|
||||
setup: setupCursorHover,
|
||||
label: '/A command button',
|
||||
label: '/call',
|
||||
}),
|
||||
]
|
||||
});
|
||||
|
||||
export const waifuCallAPI = (text) => {
|
||||
// Do something on send
|
||||
WaifuService.fetch(text);
|
||||
}
|
||||
@@ -15,6 +15,7 @@ const APIS = [
|
||||
contentWidget: chatGPTView,
|
||||
commandBar: chatGPTCommands,
|
||||
tabIcon: chatGPTTabIcon,
|
||||
placeholderText: 'Message ChatGPT',
|
||||
},
|
||||
{
|
||||
name: 'Waifus',
|
||||
@@ -22,6 +23,7 @@ const APIS = [
|
||||
contentWidget: waifuView,
|
||||
commandBar: waifuCommands,
|
||||
tabIcon: waifuTabIcon,
|
||||
placeholderText: 'Enter tags',
|
||||
},
|
||||
];
|
||||
let currentApiId = 0;
|
||||
@@ -80,6 +82,7 @@ function switchToTab(id) {
|
||||
APIS[id].tabIcon.toggleClassName('sidebar-chat-apiswitcher-icon-enabled', true);
|
||||
apiContentStack.shown = APIS[id].name;
|
||||
apiCommandStack.shown = APIS[id].name;
|
||||
chatEntry.placeholderText = APIS[id].placeholderText,
|
||||
currentApiId = id;
|
||||
}
|
||||
const apiSwitcher = Box({
|
||||
|
||||
@@ -172,6 +172,8 @@ export default () => Box({
|
||||
if (event.get_keyval()[1] == Gdk.KEY_p)
|
||||
pinButton._toggle(pinButton);
|
||||
// Switch sidebar tab
|
||||
else if (event.get_keyval()[1] === Gdk.KEY_Tab)
|
||||
switchToTab((currentTabId + 1) % contents.length);
|
||||
else if (event.get_keyval()[1] === Gdk.KEY_Page_Up)
|
||||
switchToTab(Math.max(currentTabId - 1), 0);
|
||||
else if (event.get_keyval()[1] === Gdk.KEY_Page_Down)
|
||||
|
||||
Reference in New Issue
Block a user