forked from Shinonome/dots-hyprland
init illogical-impulse
This commit is contained in:
@@ -123,7 +123,7 @@ const BarBattery = () => {
|
||||
['fallback', memUsage],
|
||||
['battery', batteryWidget],
|
||||
],
|
||||
setup: (stack) => Utils.timeout(1, () => {
|
||||
setup: (stack) => Utils.timeout(1, () => { // On desktops systems with no battery, show memory usage instead
|
||||
if (Battery.available) stack.shown = 'battery';
|
||||
else stack.shown = 'fallback';
|
||||
})
|
||||
@@ -134,6 +134,7 @@ const BarBattery = () => {
|
||||
export const ModuleSystem = () => Widget.EventBox({
|
||||
onScrollUp: () => execAsync('hyprctl dispatch workspace -1'),
|
||||
onScrollDown: () => execAsync('hyprctl dispatch workspace +1'),
|
||||
onPrimaryClick: () => App.toggleWindow('sideright'),
|
||||
child: Widget.Box({
|
||||
className: 'bar-group-margin bar-sides',
|
||||
children: [
|
||||
|
||||
@@ -74,12 +74,14 @@ export const ModuleWorkspaces = () => Widget.EventBox({
|
||||
[Hyprland, (box) => {
|
||||
// console.log('update');
|
||||
const kids = box.children;
|
||||
kids.forEach((child, i) => {
|
||||
for (let i = 0; i < kids.length; i++) {
|
||||
const child = kids[i];
|
||||
child.child.toggleClassName('bar-ws-occupied', false);
|
||||
child.child.toggleClassName('bar-ws-occupied-left', false);
|
||||
child.child.toggleClassName('bar-ws-occupied-right', false);
|
||||
child.child.toggleClassName('bar-ws-occupied-left-right', false);
|
||||
});
|
||||
}
|
||||
|
||||
const occupied = Array.from({ length: NUM_OF_WORKSPACES }, (_, i) => Hyprland.getWorkspace(i + 1)?.windows > 0);
|
||||
for (let i = 0; i < occupied.length; i++) {
|
||||
if (!occupied[i]) continue;
|
||||
|
||||
@@ -138,10 +138,12 @@ export default () => Box({
|
||||
}),
|
||||
onPrimaryClickRelease: () => {
|
||||
const kids = resources.get_children();
|
||||
|
||||
kids.forEach((child, i) => {
|
||||
child.get_children()[0].revealChild = !child.get_children()[0].revealChild;
|
||||
});
|
||||
for (let i = 0; i < kids.length; i++) {
|
||||
const child = kids[i];
|
||||
const firstChild = child.get_children()[0];
|
||||
firstChild.revealChild = !firstChild.revealChild;
|
||||
}
|
||||
|
||||
},
|
||||
})
|
||||
],
|
||||
|
||||
@@ -86,7 +86,8 @@ const Taskbar = () => Widget.Box({
|
||||
return a._workspace > b._workspace;
|
||||
}],
|
||||
['update', (box) => {
|
||||
Hyprland.clients.forEach(client => {
|
||||
for (let i = 0; i < Hyprland.clients.length; i++) {
|
||||
const client = Hyprland.clients[i];
|
||||
if (client["pid"] == -1) return;
|
||||
const appClass = substitute(client.class);
|
||||
for (const appName of pinnedApps) {
|
||||
@@ -101,7 +102,7 @@ const Taskbar = () => Widget.Box({
|
||||
newButton._workspace = client.workspace.id;
|
||||
newButton.revealChild = true;
|
||||
box._map.set(client.address, newButton);
|
||||
})
|
||||
}
|
||||
box.children = Array.from(box._map.values());
|
||||
}],
|
||||
['add', (box, address) => {
|
||||
|
||||
@@ -360,7 +360,11 @@ export default () => Widget.Revealer({
|
||||
|
||||
if (!foundPlayer) {
|
||||
box._player = null;
|
||||
box.get_children().forEach(ch => ch.destroy());
|
||||
const children = box.get_children();
|
||||
for (let i = 0; i < children.length; i++) {
|
||||
const child = children[i];
|
||||
child.destroy();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}, 'notify::players']],
|
||||
|
||||
@@ -257,7 +257,7 @@ const workspace = index => {
|
||||
child: fixed,
|
||||
})],
|
||||
});
|
||||
widget.update = clients => {
|
||||
widget.update = (clients) => {
|
||||
clients = clients.filter(({ workspace: { id } }) => id === index);
|
||||
|
||||
// this is for my monitor layout
|
||||
@@ -269,9 +269,22 @@ const workspace = index => {
|
||||
return client;
|
||||
});
|
||||
|
||||
fixed.get_children().forEach(ch => ch.destroy());
|
||||
const children = fixed.get_children();
|
||||
for (let i = 0; i < children.length; i++) {
|
||||
const child = children[i];
|
||||
child.destroy();
|
||||
}
|
||||
fixed.put(WorkspaceNumber(index), 0, 0);
|
||||
clients.forEach(c => c.mapped && fixed.put(client(c), c.at[0] * OVERVIEW_SCALE, c.at[1] * OVERVIEW_SCALE));
|
||||
|
||||
for (let i = 0; i < clients.length; i++) {
|
||||
const c = clients[i];
|
||||
if (c.mapped) {
|
||||
fixed.put(client(c), c.at[0] * OVERVIEW_SCALE, c.at[1] * OVERVIEW_SCALE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
fixed.show_all();
|
||||
};
|
||||
return widget;
|
||||
@@ -290,7 +303,12 @@ const OverviewRow = ({ startWorkspace, workspaces, windowName = 'overview' }) =>
|
||||
properties: [['update', box => {
|
||||
execAsync('hyprctl -j clients').then(clients => {
|
||||
const json = JSON.parse(clients);
|
||||
box.get_children().forEach(ch => ch.update(json));
|
||||
const children = box.get_children();
|
||||
for (let i = 0; i < children.length; i++) {
|
||||
const ch = children[i];
|
||||
ch.update(json)
|
||||
}
|
||||
|
||||
}).catch(print);
|
||||
}]],
|
||||
setup: (box) => box._update(box),
|
||||
@@ -375,7 +393,7 @@ export const SearchAndWindows = () => {
|
||||
hpack: 'center',
|
||||
onAccept: (self) => { // This is when you hit Enter
|
||||
const text = self.text;
|
||||
if(text.length == 0) return;
|
||||
if (text.length == 0) return;
|
||||
const isAction = text.startsWith('>');
|
||||
const isDir = (entry.text[0] == '/' || entry.text[0] == '~');
|
||||
|
||||
@@ -423,7 +441,11 @@ export const SearchAndWindows = () => {
|
||||
['notify::text', (entry) => { // This is when you type
|
||||
const isAction = entry.text[0] == '>';
|
||||
const isDir = (entry.text[0] == '/' || entry.text[0] == '~');
|
||||
resultsBox.get_children().forEach(ch => ch.destroy());
|
||||
const children = resultsBox.get_children();
|
||||
for (let i = 0; i < children.length; i++) {
|
||||
const child = children[i];
|
||||
child.destroy();
|
||||
}
|
||||
// check empty if so then dont do stuff
|
||||
if (entry.text == '') {
|
||||
resultsRevealer.set_reveal_child(false);
|
||||
|
||||
@@ -6,7 +6,7 @@ import ChatGPT from '../../../services/chatgpt.js';
|
||||
import { MaterialIcon } from "../../../lib/materialicon.js";
|
||||
import { setupCursorHover, setupCursorHoverInfo } from "../../../lib/cursorhover.js";
|
||||
import { SystemMessage, ChatMessage } from "./chatgpt_chatmessage.js";
|
||||
import { ConfigToggle } from '../../../lib/configwidgets.js';
|
||||
import { ConfigToggle, ConfigSegmentedSelection, ConfigGap } from '../../../lib/configwidgets.js';
|
||||
import { markdownTest } from '../../../lib/md2pango.js';
|
||||
|
||||
const chatGPTTabIcon = Icon({
|
||||
@@ -68,36 +68,58 @@ export const chatGPTSettings = Revealer({
|
||||
transitionDuration: 150,
|
||||
revealChild: true,
|
||||
connections: [
|
||||
[ChatGPT, (self) => {
|
||||
[ChatGPT, (self) => Utils.timeout(200, () => {
|
||||
self.revealChild = false;
|
||||
}, 'newMsg'],
|
||||
[ChatGPT, (self) => {
|
||||
}), 'newMsg'],
|
||||
[ChatGPT, (self) => Utils.timeout(200, () => {
|
||||
self.revealChild = true;
|
||||
}, 'clear'],
|
||||
}), 'clear'],
|
||||
],
|
||||
child: Box({
|
||||
vertical: true,
|
||||
hpack: 'fill',
|
||||
className: 'sidebar-chat-settings',
|
||||
children: [
|
||||
ConfigToggle({
|
||||
icon: 'cycle',
|
||||
name: 'Cycle models',
|
||||
desc: 'Helps avoid exceeding the API rate of 3 messages per minute.\nTurn this on if you message rapidly.',
|
||||
initValue: ChatGPT.cycleModels,
|
||||
onChange: (self, newValue) => {
|
||||
ChatGPT.cycleModels = newValue;
|
||||
},
|
||||
}),
|
||||
ConfigToggle({
|
||||
icon: 'description',
|
||||
name: 'Assistant prompt',
|
||||
desc: 'Tells ChatGPT\n 1. It\'s a sidebar assistant on Linux\n 2. Be short and concise\n 3. Use markdown features extensively\nLeave this off for a vanilla ChatGPT experience.',
|
||||
initValue: ChatGPT.assistantPrompt,
|
||||
onChange: (self, newValue) => {
|
||||
ChatGPT.assistantPrompt = newValue;
|
||||
ConfigSegmentedSelection({
|
||||
hpack: 'center',
|
||||
icon: 'casino',
|
||||
name: 'Randomness',
|
||||
desc: 'ChatGPT\'s temperature value.\n Precise = 0\n Balanced = 0.5\n Creative = 1',
|
||||
options: [
|
||||
{ value: 0.00, name: 'Precise', },
|
||||
{ value: 0.50, name: 'Balanced', },
|
||||
{ value: 1.00, name: 'Creative', },
|
||||
],
|
||||
initIndex: 1,
|
||||
onChange: (value, name) => {
|
||||
ChatGPT.temperature = value;
|
||||
},
|
||||
}),
|
||||
ConfigGap({ vertical: true, size: 10 }), // Note: size can only be 5, 10, or 15
|
||||
Box({
|
||||
vertical: true,
|
||||
hpack: 'fill',
|
||||
className: 'sidebar-chat-settings-toggles',
|
||||
children: [
|
||||
ConfigToggle({
|
||||
icon: 'cycle',
|
||||
name: 'Cycle models',
|
||||
desc: 'Helps avoid exceeding the API rate of 3 messages per minute.\nTurn this on if you message rapidly.',
|
||||
initValue: ChatGPT.cycleModels,
|
||||
onChange: (self, newValue) => {
|
||||
ChatGPT.cycleModels = newValue;
|
||||
},
|
||||
}),
|
||||
ConfigToggle({
|
||||
icon: 'description',
|
||||
name: 'Assistant prompt',
|
||||
desc: 'Tells ChatGPT\n 1. It\'s a sidebar assistant on Linux\n 2. Be short and concise\n 3. Use markdown features extensively\nLeave this off for a vanilla ChatGPT experience.',
|
||||
initValue: ChatGPT.assistantPrompt,
|
||||
onChange: (self, newValue) => {
|
||||
ChatGPT.assistantPrompt = newValue;
|
||||
},
|
||||
}),
|
||||
]
|
||||
})
|
||||
]
|
||||
})
|
||||
});
|
||||
@@ -136,7 +158,7 @@ export const chatGPTWelcome = Box({
|
||||
children: [
|
||||
chatGPTInfo,
|
||||
openaiApiKeyInstructions,
|
||||
chatGPTSettings,
|
||||
chatGPTSettings, ``
|
||||
]
|
||||
})
|
||||
});
|
||||
@@ -148,21 +170,30 @@ export const chatContent = Box({
|
||||
[ChatGPT, (box, id) => {
|
||||
const message = ChatGPT.messages[id];
|
||||
if (!message) return;
|
||||
box.add(ChatMessage(message))
|
||||
box.add(ChatMessage(message, chatGPTView))
|
||||
}, 'newMsg'],
|
||||
[ChatGPT, (box) => {
|
||||
box.children = [chatGPTWelcome];
|
||||
}, 'clear'],
|
||||
[ChatGPT, (box) => {
|
||||
box.children = [chatGPTWelcome];
|
||||
}, 'initialized'],
|
||||
]
|
||||
});
|
||||
|
||||
const clearChat = () => {
|
||||
ChatGPT.clear();
|
||||
const children = chatContent.get_children();
|
||||
for (let i = 0; i < children.length; i++) {
|
||||
const child = children[i];
|
||||
child.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
export const chatGPTView = Scrollable({
|
||||
className: 'sidebar-chat-viewport',
|
||||
vexpand: true,
|
||||
child: chatContent,
|
||||
child: Box({
|
||||
vertical: true,
|
||||
children: [
|
||||
chatGPTWelcome,
|
||||
chatContent,
|
||||
]
|
||||
}),
|
||||
setup: (scrolledWindow) => {
|
||||
scrolledWindow.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
|
||||
const vScrollbar = scrolledWindow.get_vscrollbar();
|
||||
@@ -183,7 +214,8 @@ export const chatGPTCommands = Box({
|
||||
className: 'sidebar-chat-chip sidebar-chat-chip-action txt txt-small',
|
||||
onClicked: () => chatContent.add(SystemMessage(
|
||||
`Key stored in:\n\`${ChatGPT.keyPath}\`\nTo update this key, type \`/key YOUR_API_KEY\``,
|
||||
'/key')),
|
||||
'/key',
|
||||
chatGPTView)),
|
||||
setup: setupCursorHover,
|
||||
label: '/key',
|
||||
}),
|
||||
@@ -191,14 +223,15 @@ export const chatGPTCommands = Box({
|
||||
className: 'sidebar-chat-chip sidebar-chat-chip-action txt txt-small',
|
||||
onClicked: () => chatContent.add(SystemMessage(
|
||||
`Currently using \`${ChatGPT.modelName}\``,
|
||||
'/model'
|
||||
'/model',
|
||||
chatGPTView
|
||||
)),
|
||||
setup: setupCursorHover,
|
||||
label: '/model',
|
||||
}),
|
||||
Button({
|
||||
className: 'sidebar-chat-chip sidebar-chat-chip-action txt txt-small',
|
||||
onClicked: () => ChatGPT.clear(),
|
||||
onClicked: () => clearChat(),
|
||||
setup: setupCursorHover,
|
||||
label: '/clear',
|
||||
}),
|
||||
@@ -210,26 +243,29 @@ export const chatGPTSendMessage = (text) => {
|
||||
if (text.length == 0) return;
|
||||
if (ChatGPT.key.length == 0) {
|
||||
ChatGPT.key = text;
|
||||
chatContent.add(SystemMessage(`Key saved to\n\`${ChatGPT.keyPath}\``, 'API Key'));
|
||||
chatContent.add(SystemMessage(`Key saved to\n\`${ChatGPT.keyPath}\``, 'API Key', chatGPTView));
|
||||
text = '';
|
||||
return;
|
||||
}
|
||||
// Commands
|
||||
if (text.startsWith('/')) {
|
||||
if (text.startsWith('/clear')) ChatGPT.clear();
|
||||
else if (text.startsWith('/model')) chatContent.add(SystemMessage(`Currently using \`${ChatGPT.modelName}\``, '/model'))
|
||||
if (text.startsWith('/clear')) clearChat();
|
||||
else if (text.startsWith('/model')) chatContent.add(SystemMessage(`Currently using \`${ChatGPT.modelName}\``, '/model', chatGPTView))
|
||||
else if (text.startsWith('/key')) {
|
||||
const parts = text.split(' ');
|
||||
if (parts.length == 1) chatContent.add(SystemMessage(`Key stored in:\n\`${ChatGPT.keyPath}\`\nTo update this key, type \`/key YOUR_API_KEY\``, '/key'));
|
||||
if (parts.length == 1) chatContent.add(SystemMessage(
|
||||
`Key stored in:\n\`${ChatGPT.keyPath}\`\nTo update this key, type \`/key YOUR_API_KEY\``,
|
||||
'/key',
|
||||
chatGPTView));
|
||||
else {
|
||||
ChatGPT.key = parts[1];
|
||||
chatContent.add(SystemMessage(`Updated API Key at\n\`${ChatGPT.keyPath}\``, '/key'));
|
||||
chatContent.add(SystemMessage(`Updated API Key at\n\`${ChatGPT.keyPath}\``, '/key', chatGPTView));
|
||||
}
|
||||
}
|
||||
else if (text.startsWith('/test'))
|
||||
chatContent.add(SystemMessage(markdownTest, `Markdown test`));
|
||||
chatContent.add(SystemMessage(markdownTest, `Markdown test`, chatGPTView));
|
||||
else
|
||||
chatContent.add(SystemMessage(`Invalid command.`, 'Error'))
|
||||
chatContent.add(SystemMessage(`Invalid command.`, 'Error', chatGPTView))
|
||||
}
|
||||
else {
|
||||
ChatGPT.send(text);
|
||||
|
||||
@@ -148,7 +148,11 @@ const MessageContent = (content) => {
|
||||
properties: [
|
||||
['fullUpdate', (self, content, useCursor = false) => {
|
||||
// Clear and add first text widget
|
||||
contentBox.get_children().forEach(ch => ch.destroy());
|
||||
const children = contentBox.get_children();
|
||||
for (let i = 0; i < children.length; i++) {
|
||||
const child = children[i];
|
||||
child.destroy();
|
||||
}
|
||||
contentBox.add(TextBlock())
|
||||
// Loop lines. Put normal text in markdown parser
|
||||
// and put code into code highlighter (TODO)
|
||||
@@ -214,7 +218,7 @@ const MessageContent = (content) => {
|
||||
return contentBox;
|
||||
}
|
||||
|
||||
export const ChatMessage = (message) => {
|
||||
export const ChatMessage = (message, scrolledWindow) => {
|
||||
const messageContentBox = MessageContent(message.content);
|
||||
const thisMessage = Box({
|
||||
className: 'sidebar-chat-message',
|
||||
@@ -243,7 +247,7 @@ export const ChatMessage = (message) => {
|
||||
[message, (self) => { // Message update
|
||||
messageContentBox._fullUpdate(messageContentBox, message.content, message.role != 'user');
|
||||
Utils.timeout(MESSAGE_SCROLL_DELAY, () => {
|
||||
const scrolledWindow = thisMessage.get_parent().get_parent();
|
||||
if (!scrolledWindow) return;
|
||||
var adjustment = scrolledWindow.get_vadjustment();
|
||||
adjustment.set_value(adjustment.get_upper() - adjustment.get_page_size());
|
||||
});
|
||||
@@ -258,7 +262,7 @@ export const ChatMessage = (message) => {
|
||||
return thisMessage;
|
||||
}
|
||||
|
||||
export const SystemMessage = (content, commandName) => {
|
||||
export const SystemMessage = (content, commandName, scrolledWindow) => {
|
||||
const messageContentBox = MessageContent(content);
|
||||
const thisMessage = Box({
|
||||
className: 'sidebar-chat-message',
|
||||
@@ -282,7 +286,7 @@ export const SystemMessage = (content, commandName) => {
|
||||
})
|
||||
],
|
||||
setup: (self) => Utils.timeout(MESSAGE_SCROLL_DELAY, () => {
|
||||
const scrolledWindow = thisMessage.get_parent().get_parent();
|
||||
if (!scrolledWindow) return;
|
||||
var adjustment = scrolledWindow.get_vadjustment();
|
||||
adjustment.set_value(adjustment.get_upper() - adjustment.get_page_size());
|
||||
})
|
||||
|
||||
@@ -18,6 +18,9 @@ export const SidebarModule = ({
|
||||
className: 'txt-small txt',
|
||||
label: `${name}`,
|
||||
}),
|
||||
Box({
|
||||
hexpand: true,
|
||||
}),
|
||||
Label({
|
||||
className: 'sidebar-module-btn-arrow',
|
||||
})
|
||||
|
||||
@@ -7,6 +7,5 @@ import { SidebarModule } from './module.js';
|
||||
export const QuickScripts = () => SidebarModule({
|
||||
name: 'Quick scripts',
|
||||
child: Box({
|
||||
|
||||
})
|
||||
})
|
||||
@@ -65,6 +65,11 @@ const CalendarWidget = () => {
|
||||
}
|
||||
});
|
||||
const addCalendarChildren = (box, calendarJson) => {
|
||||
const children = box.get_children();
|
||||
for (let i = 0; i < children.length; i++) {
|
||||
const child = children[i];
|
||||
child.destroy();
|
||||
}
|
||||
box.children = calendarJson.map((row, i) => Widget.Box({
|
||||
// homogeneous: true,
|
||||
className: 'spacing-h-5',
|
||||
|
||||
@@ -41,18 +41,18 @@ import { ModuleCalendar } from "./calendar.js";
|
||||
const timeRow = Box({
|
||||
className: 'spacing-h-5 sidebar-group-invisible-morehorizpad',
|
||||
children: [
|
||||
Widget.Label({
|
||||
className: 'txt-title txt',
|
||||
connections: [[5000, label => {
|
||||
label.label = GLib.DateTime.new_now_local().format("%H:%M");
|
||||
}]],
|
||||
}),
|
||||
// Widget.Label({
|
||||
// className: 'txt-title txt',
|
||||
// connections: [[5000, label => {
|
||||
// label.label = GLib.DateTime.new_now_local().format("%H:%M");
|
||||
// }]],
|
||||
// }),
|
||||
Widget.Label({
|
||||
hpack: 'center',
|
||||
className: 'txt-small txt',
|
||||
connections: [[5000, label => {
|
||||
execAsync(['bash', '-c', `uptime -p | sed -e 's/up //;s/ hours,/h/;s/ minutes/m/'`]).then(upTimeString => {
|
||||
label.label = `• up: ${upTimeString}`;
|
||||
label.label = `System uptime: ${upTimeString}`;
|
||||
}).catch(print);
|
||||
}]],
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user