mirror of
https://github.com/danbulant/dots-hyprland
synced 2026-05-24 12:22:09 +00:00
ags: make not crash in sway
This commit is contained in:
parent
85704218e3
commit
8cf0f02b56
18 changed files with 253 additions and 215 deletions
|
|
@ -1,6 +1,5 @@
|
|||
"use strict";
|
||||
// Import
|
||||
const { GLib } = imports.gi;
|
||||
import App from 'resource:///com/github/Aylur/ags/app.js'
|
||||
import * as Utils from 'resource:///com/github/Aylur/ags/utils.js'
|
||||
// Widgets
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ export const Applications = await service('applications');
|
|||
export const Audio = await service('audio');
|
||||
export const Battery = await service('battery');
|
||||
export const Bluetooth = await service('bluetooth');
|
||||
export const Hyprland = await service('hyprland');
|
||||
// export const Hyprland = await service('hyprland');
|
||||
export const Mpris = await service('mpris');
|
||||
export const Network = await service('network');
|
||||
export const Notifications = await service('notifications');
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import { MaterialIcon } from './materialicon.js';
|
|||
import Bluetooth from 'resource:///com/github/Aylur/ags/service/bluetooth.js';
|
||||
import Network from 'resource:///com/github/Aylur/ags/service/network.js';
|
||||
import Notifications from 'resource:///com/github/Aylur/ags/service/notifications.js';
|
||||
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
|
||||
import { languages } from '../data/languages.js';
|
||||
|
||||
// A guessing func to try to support langs not listed in data/languages.js
|
||||
|
|
@ -163,57 +162,62 @@ export const NetworkIndicator = () => Widget.Stack({
|
|||
});
|
||||
|
||||
const HyprlandXkbKeyboardLayout = async ({ useFlag } = {}) => {
|
||||
var initLangs = [];
|
||||
var languageStackArray = [];
|
||||
var currentKeyboard;
|
||||
try {
|
||||
const Hyprland = (await import('resource:///com/github/Aylur/ags/service/hyprland.js')).default;
|
||||
var initLangs = [];
|
||||
var languageStackArray = [];
|
||||
var currentKeyboard;
|
||||
|
||||
const updateCurrentKeyboards = () => {
|
||||
currentKeyboard = JSON.parse(Utils.exec('hyprctl -j devices')).keyboards
|
||||
.find(device => device.name === 'at-translated-set-2-keyboard');
|
||||
if (currentKeyboard) {
|
||||
initLangs = currentKeyboard.layout.split(',').map(lang => lang.trim());
|
||||
}
|
||||
languageStackArray = Array.from({ length: initLangs.length }, (_, i) => {
|
||||
const lang = languages.find(lang => lang.layout == initLangs[i]);
|
||||
if (!lang) return [
|
||||
initLangs[i],
|
||||
Widget.Label({ label: initLangs[i] })
|
||||
];
|
||||
return [
|
||||
lang.layout,
|
||||
Widget.Label({ label: (useFlag ? lang.flag : lang.layout) })
|
||||
];
|
||||
const updateCurrentKeyboards = () => {
|
||||
currentKeyboard = JSON.parse(Utils.exec('hyprctl -j devices')).keyboards
|
||||
.find(device => device.name === 'at-translated-set-2-keyboard');
|
||||
if (currentKeyboard) {
|
||||
initLangs = currentKeyboard.layout.split(',').map(lang => lang.trim());
|
||||
}
|
||||
languageStackArray = Array.from({ length: initLangs.length }, (_, i) => {
|
||||
const lang = languages.find(lang => lang.layout == initLangs[i]);
|
||||
if (!lang) return [
|
||||
initLangs[i],
|
||||
Widget.Label({ label: initLangs[i] })
|
||||
];
|
||||
return [
|
||||
lang.layout,
|
||||
Widget.Label({ label: (useFlag ? lang.flag : lang.layout) })
|
||||
];
|
||||
});
|
||||
};
|
||||
updateCurrentKeyboards();
|
||||
const widgetRevealer = Widget.Revealer({
|
||||
transition: 150,
|
||||
transition: 'slide_left',
|
||||
revealChild: languageStackArray.length > 1,
|
||||
});
|
||||
};
|
||||
updateCurrentKeyboards();
|
||||
const widgetRevealer = Widget.Revealer({
|
||||
transition: 150,
|
||||
transition: 'slide_left',
|
||||
revealChild: languageStackArray.length > 1,
|
||||
});
|
||||
const widgetContent = Widget.Stack({
|
||||
transition: 'slide_up_down',
|
||||
items: [
|
||||
...languageStackArray,
|
||||
['undef', Widget.Label({ label: '?' })]
|
||||
],
|
||||
setup: (self) => self.hook(Hyprland, (stack, kbName, layoutName) => {
|
||||
if (!kbName) {
|
||||
return;
|
||||
}
|
||||
var lang = languages.find(lang => layoutName.includes(lang.name));
|
||||
if (lang) {
|
||||
widgetContent.shown = lang.layout;
|
||||
}
|
||||
else { // Attempt to support langs not listed
|
||||
lang = languageStackArray.find(lang => isLanguageMatch(lang[0], layoutName));
|
||||
if (!lang) stack.shown = 'undef';
|
||||
else stack.shown = lang[0];
|
||||
}
|
||||
}, 'keyboard-layout'),
|
||||
});
|
||||
widgetRevealer.child = widgetContent;
|
||||
return widgetRevealer;
|
||||
const widgetContent = Widget.Stack({
|
||||
transition: 'slide_up_down',
|
||||
items: [
|
||||
...languageStackArray,
|
||||
['undef', Widget.Label({ label: '?' })]
|
||||
],
|
||||
setup: (self) => self.hook(Hyprland, (stack, kbName, layoutName) => {
|
||||
if (!kbName) {
|
||||
return;
|
||||
}
|
||||
var lang = languages.find(lang => layoutName.includes(lang.name));
|
||||
if (lang) {
|
||||
widgetContent.shown = lang.layout;
|
||||
}
|
||||
else { // Attempt to support langs not listed
|
||||
lang = languageStackArray.find(lang => isLanguageMatch(lang[0], layoutName));
|
||||
if (!lang) stack.shown = 'undef';
|
||||
else stack.shown = lang[0];
|
||||
}
|
||||
}, 'keyboard-layout'),
|
||||
});
|
||||
widgetRevealer.child = widgetContent;
|
||||
return widgetRevealer;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
const OptionalKeyboardLayout = async () => {
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ apply_gtk() { # Using gradience-cli
|
|||
# (which is unreadable when broken when you use dark mode)
|
||||
if [ "$lightdark" = "-l" ]; then
|
||||
gsettings set org.gnome.desktop.interface gtk-theme 'adw-gtk3'
|
||||
gsettings set org.gnome.desktop.interface color-scheme 'default'
|
||||
gsettings set org.gnome.desktop.interface color-scheme 'prefer-light'
|
||||
else
|
||||
gsettings set org.gnome.desktop.interface gtk-theme adw-gtk3-dark
|
||||
gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark'
|
||||
|
|
|
|||
|
|
@ -416,8 +416,8 @@ $onChatgpt: $onPrimary;
|
|||
}
|
||||
|
||||
.sidebar-todo-add {
|
||||
@include full-rounding;
|
||||
@include menu_decel;
|
||||
@include small-rounding;
|
||||
min-width: 1.705rem;
|
||||
min-height: 1.705rem;
|
||||
color: $onSecondaryContainer;
|
||||
|
|
@ -435,7 +435,7 @@ $onChatgpt: $onPrimary;
|
|||
|
||||
.sidebar-todo-add-available {
|
||||
@include menu_decel;
|
||||
@include full-rounding;
|
||||
@include small-rounding;
|
||||
min-width: 1.705rem;
|
||||
min-height: 1.705rem;
|
||||
background-color: $primary;
|
||||
|
|
|
|||
|
|
@ -1735,9 +1735,9 @@ tooltip {
|
|||
background-color: #52696f; }
|
||||
|
||||
.sidebar-todo-add {
|
||||
border-radius: 9999px;
|
||||
-gtk-outline-radius: 9999px;
|
||||
transition: 300ms cubic-bezier(0.1, 1, 0, 1);
|
||||
border-radius: 0.818rem;
|
||||
-gtk-outline-radius: 0.818rem;
|
||||
min-width: 1.705rem;
|
||||
min-height: 1.705rem;
|
||||
color: #cde7ed;
|
||||
|
|
@ -1752,8 +1752,8 @@ tooltip {
|
|||
|
||||
.sidebar-todo-add-available {
|
||||
transition: 300ms cubic-bezier(0.1, 1, 0, 1);
|
||||
border-radius: 9999px;
|
||||
-gtk-outline-radius: 9999px;
|
||||
border-radius: 0.818rem;
|
||||
-gtk-outline-radius: 0.818rem;
|
||||
min-width: 1.705rem;
|
||||
min-height: 1.705rem;
|
||||
background-color: #85e3f4;
|
||||
|
|
|
|||
|
|
@ -1,42 +1,41 @@
|
|||
import App from 'resource:///com/github/Aylur/ags/app.js';
|
||||
import Widget from 'resource:///com/github/Aylur/ags/widget.js';
|
||||
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
|
||||
import { RoundedCorner } from "../../lib/roundedcorner.js";
|
||||
import Brightness from '../../services/brightness.js';
|
||||
import Indicator from '../../services/indicator.js';
|
||||
|
||||
const WindowTitle = async () => Widget.Scrollable({
|
||||
hexpand: true, vexpand: true,
|
||||
hscroll: 'automatic', vscroll: 'never',
|
||||
child: Widget.Box({
|
||||
vertical: true,
|
||||
children: [
|
||||
Widget.Label({
|
||||
xalign: 0,
|
||||
className: 'txt-smaller bar-topdesc txt',
|
||||
setup: (self) => self.hook(Hyprland.active.client, label => { // Hyprland.active.client
|
||||
label.label = Hyprland.active.client.class.length === 0 ? 'Desktop' : Hyprland.active.client.class;
|
||||
}),
|
||||
}),
|
||||
Widget.Label({
|
||||
xalign: 0,
|
||||
className: 'txt txt-smallie',
|
||||
setup: (self) => self.hook(Hyprland.active.client, label => { // Hyprland.active.client
|
||||
label.label = Hyprland.active.client.title.length === 0 ? `Workspace ${Hyprland.active.workspace.id}` : Hyprland.active.client.title;
|
||||
}),
|
||||
})
|
||||
]
|
||||
})
|
||||
})
|
||||
|
||||
const OptionalWindowTitle = async () => {
|
||||
const WindowTitle = async () => {
|
||||
try {
|
||||
return await WindowTitle();
|
||||
const Hyprland = (await import('resource:///com/github/Aylur/ags/service/hyprland.js')).default;
|
||||
return Widget.Scrollable({
|
||||
hexpand: true, vexpand: true,
|
||||
hscroll: 'automatic', vscroll: 'never',
|
||||
child: Widget.Box({
|
||||
vertical: true,
|
||||
children: [
|
||||
Widget.Label({
|
||||
xalign: 0,
|
||||
className: 'txt-smaller bar-topdesc txt',
|
||||
setup: (self) => self.hook(Hyprland.active.client, label => { // Hyprland.active.client
|
||||
label.label = Hyprland.active.client.class.length === 0 ? 'Desktop' : Hyprland.active.client.class;
|
||||
}),
|
||||
}),
|
||||
Widget.Label({
|
||||
xalign: 0,
|
||||
className: 'txt txt-smallie',
|
||||
setup: (self) => self.hook(Hyprland.active.client, label => { // Hyprland.active.client
|
||||
label.label = Hyprland.active.client.title.length === 0 ? `Workspace ${Hyprland.active.workspace.id}` : Hyprland.active.client.title;
|
||||
}),
|
||||
})
|
||||
]
|
||||
})
|
||||
});
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
const OptionalWindowTitleInstance = await OptionalWindowTitle();
|
||||
}
|
||||
|
||||
const OptionalWindowTitleInstance = await WindowTitle();
|
||||
|
||||
export const ModuleLeftSpace = () => Widget.EventBox({
|
||||
onScrollUp: () => {
|
||||
|
|
|
|||
|
|
@ -2,29 +2,25 @@ const { Gtk } = imports.gi;
|
|||
import Widget from 'resource:///com/github/Aylur/ags/widget.js';
|
||||
|
||||
import { ModuleLeftSpace } from "./leftspace.js";
|
||||
import { ModuleMusic } from "./music.js";
|
||||
import { ModuleRightSpace } from "./rightspace.js";
|
||||
import { ModuleMusic } from "./music.js";
|
||||
import { ModuleSystem } from "./system.js";
|
||||
const OptionalWorkspaces = async () => {
|
||||
try {
|
||||
return (await import('./workspaces_hyprland.js')).default();
|
||||
} catch {
|
||||
// return (await import('./workspaces_sway.js')).default();
|
||||
return Box({});
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
const left = Widget.Box({
|
||||
className: 'bar-sidemodule',
|
||||
children: [
|
||||
ModuleMusic()
|
||||
],
|
||||
children: [ ModuleMusic()],
|
||||
});
|
||||
|
||||
const center = Widget.Box({
|
||||
children: [
|
||||
await OptionalWorkspaces(),
|
||||
],
|
||||
children: [await OptionalWorkspaces()],
|
||||
});
|
||||
|
||||
const right = Widget.Box({
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import Widget from 'resource:///com/github/Aylur/ags/widget.js';
|
||||
import * as Utils from 'resource:///com/github/Aylur/ags/utils.js';
|
||||
import Mpris from 'resource:///com/github/Aylur/ags/service/mpris.js';
|
||||
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
|
||||
const { execAsync, exec } = Utils;
|
||||
import { AnimatedCircProg } from "../../lib/animatedcircularprogress.js";
|
||||
import { showMusicControls } from '../../variables.js';
|
||||
|
|
@ -30,9 +29,18 @@ const TrackProgress = () => {
|
|||
})
|
||||
}
|
||||
|
||||
const moveToRelativeWorkspace = async (self, num) => {
|
||||
try {
|
||||
const Hyprland = (await import('resource:///com/github/Aylur/ags/service/hyprland.js')).default;
|
||||
Hyprland.sendMessage(`dispatch workspace ${num > 0 ? '+' : ''}${num}`);
|
||||
} catch {
|
||||
console.log(`TODO: Sway workspace ${num > 0 ? '+' : ''}${num}`);
|
||||
}
|
||||
}
|
||||
|
||||
export const ModuleMusic = () => Widget.EventBox({ // TODO: use cairo to make button bounce smaller on click
|
||||
onScrollUp: () => Hyprland.sendMessage(`dispatch workspace -1`),
|
||||
onScrollDown: () => Hyprland.sendMessage(`dispatch workspace +1`),
|
||||
onScrollUp: (self) => moveToRelativeWorkspace(self, -1),
|
||||
onScrollDown: (self) => moveToRelativeWorkspace(self, +1),
|
||||
onPrimaryClickRelease: () => showMusicControls.setValue(!showMusicControls.value),
|
||||
onSecondaryClickRelease: () => execAsync(['bash', '-c', 'playerctl next || playerctl position `bc <<< "100 * $(playerctl metadata mpris:length) / 1000000 / 100"` &']),
|
||||
onMiddleClickRelease: () => execAsync('playerctl play-pause').catch(print),
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@ export const ModuleRightSpace = () => {
|
|||
Audio.speaker.volume -= 0.03;
|
||||
Indicator.popup(1);
|
||||
},
|
||||
// onHover: () => { barStatusIcons.toggleClassName('bar-statusicons-hover', true) },
|
||||
// onHoverLost: () => { barStatusIcons.toggleClassName('bar-statusicons-hover', false) },
|
||||
onHover: () => { barStatusIcons.toggleClassName('bar-statusicons-hover', true) },
|
||||
onHoverLost: () => { barStatusIcons.toggleClassName('bar-statusicons-hover', false) },
|
||||
onPrimaryClick: () => App.toggleWindow('sideright'),
|
||||
onSecondaryClickRelease: () => execAsync(['bash', '-c', 'playerctl next || playerctl position `bc <<< "100 * $(playerctl metadata mpris:length) / 1000000 / 100"` &']).catch(print),
|
||||
onMiddleClickRelease: () => execAsync('playerctl play-pause').catch(print),
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import * as Utils from 'resource:///com/github/Aylur/ags/utils.js';
|
|||
const { Box, Label, Button, Overlay, Revealer, Scrollable, Stack, EventBox } = Widget;
|
||||
const { exec, execAsync } = Utils;
|
||||
const { GLib } = imports.gi;
|
||||
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
|
||||
import Battery from 'resource:///com/github/Aylur/ags/service/battery.js';
|
||||
import { MaterialIcon } from '../../lib/materialicon.js';
|
||||
import { AnimatedCircProg } from "../../lib/animatedcircularprogress.js";
|
||||
|
|
@ -14,7 +13,7 @@ const BATTERY_LOW = 20;
|
|||
|
||||
const BatBatteryProgress = () => {
|
||||
const _updateProgress = (circprog) => { // Set circular progress value
|
||||
circprog.css = `font-size: ${Battery.percent}px;`
|
||||
circprog.css = `font-size: ${Math.abs(Battery.percent)}px;`
|
||||
|
||||
circprog.toggleClassName('bar-batt-circprog-low', Battery.percent <= BATTERY_LOW);
|
||||
circprog.toggleClassName('bar-batt-circprog-full', Battery.charged);
|
||||
|
|
@ -187,9 +186,18 @@ const BarGroup = ({ child }) => Widget.Box({
|
|||
]
|
||||
});
|
||||
|
||||
const moveToRelativeWorkspace = async (self, num) => {
|
||||
try {
|
||||
const Hyprland = (await import('resource:///com/github/Aylur/ags/service/hyprland.js')).default;
|
||||
Hyprland.sendMessage(`dispatch workspace ${num > 0 ? '+' : ''}${num}`);
|
||||
} catch {
|
||||
console.log(`TODO: Sway workspace ${num > 0 ? '+' : ''}${num}`);
|
||||
}
|
||||
}
|
||||
|
||||
export const ModuleSystem = () => Widget.EventBox({
|
||||
onScrollUp: () => Hyprland.sendMessage(`dispatch workspace -1`),
|
||||
onScrollDown: () => Hyprland.sendMessage(`dispatch workspace +1`),
|
||||
onScrollUp: (self) => moveToRelativeWorkspace(self, -1),
|
||||
onScrollDown: (self) => moveToRelativeWorkspace(self, +1),
|
||||
onPrimaryClick: () => App.toggleWindow('sideright'),
|
||||
child: Widget.Box({
|
||||
className: 'spacing-h-5',
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ const WorkspaceContents = (count = 10) => {
|
|||
let workspaceMask = 0;
|
||||
for (let i = 0; i < workspaces.length; i++) {
|
||||
const ws = workspaces[i];
|
||||
if (ws.id < 0) continue; // Ignore scratchpads
|
||||
if (ws.id <= 0) continue; // Ignore scratchpads
|
||||
if (ws.id > count) return; // Not rendered
|
||||
if (workspaces[i].windows > 0) {
|
||||
workspaceMask |= (1 << ws.id);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import GraphWidget from './graph.js'
|
|||
export default () => Widget.Window({
|
||||
name: 'desktopbackground',
|
||||
anchor: ['top', 'bottom', 'left', 'right'],
|
||||
layer: 'background',
|
||||
layer: 'bottom',
|
||||
exclusivity: 'normal',
|
||||
visible: true,
|
||||
child: Widget.Overlay({
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import Widget from 'resource:///com/github/Aylur/ags/widget.js';
|
|||
import Service from 'resource:///com/github/Aylur/ags/service.js';
|
||||
import * as Utils from 'resource:///com/github/Aylur/ags/utils.js';
|
||||
|
||||
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
|
||||
const { Box, EventBox, Button, Revealer } = Widget;
|
||||
const { execAsync, exec } = Utils;
|
||||
import { MaterialIcon } from '../../lib/materialicon.js';
|
||||
|
|
@ -146,22 +145,32 @@ const keyboardWindow = Box({
|
|||
|
||||
const gestureEvBox = EventBox({ child: keyboardWindow })
|
||||
const gesture = Gtk.GestureDrag.new(gestureEvBox);
|
||||
gesture.connect('drag-begin', () => {
|
||||
Hyprland.sendMessage('j/cursorpos').then((out) => {
|
||||
gesture.startY = JSON.parse(out).y;
|
||||
}).catch(print);
|
||||
gesture.connect('drag-begin', async () => {
|
||||
try {
|
||||
const Hyprland = (await import('resource:///com/github/Aylur/ags/service/hyprland.js')).default;
|
||||
Hyprland.sendMessage('j/cursorpos').then((out) => {
|
||||
gesture.startY = JSON.parse(out).y;
|
||||
}).catch(print);
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
});
|
||||
gesture.connect('drag-update', () => {
|
||||
Hyprland.sendMessage('j/cursorpos').then((out) => {
|
||||
const currentY = JSON.parse(out).y;
|
||||
const offset = gesture.startY - currentY;
|
||||
gesture.connect('drag-update', async () => {
|
||||
try {
|
||||
const Hyprland = (await import('resource:///com/github/Aylur/ags/service/hyprland.js')).default;
|
||||
Hyprland.sendMessage('j/cursorpos').then((out) => {
|
||||
const currentY = JSON.parse(out).y;
|
||||
const offset = gesture.startY - currentY;
|
||||
|
||||
if (offset > 0) return;
|
||||
if (offset > 0) return;
|
||||
|
||||
keyboardWindow.setCss(`
|
||||
keyboardWindow.setCss(`
|
||||
margin-bottom: ${offset}px;
|
||||
`);
|
||||
}).catch(print);
|
||||
}).catch(print);
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
});
|
||||
gesture.connect('drag-end', () => {
|
||||
var offset = gesture.get_offset()[2];
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ const OptionalOverview = async () => {
|
|||
try {
|
||||
return (await import('./overview_hyprland.js')).default();
|
||||
} catch {
|
||||
return null;
|
||||
return Widget.Box({});
|
||||
// return (await import('./overview_hyprland.js')).default();
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -22,49 +22,52 @@ export const chatGPTTabIcon = Box({
|
|||
],
|
||||
});
|
||||
|
||||
const chatGPTInfo = Box({
|
||||
vertical: true,
|
||||
className: 'spacing-v-15',
|
||||
children: [
|
||||
Icon({
|
||||
hpack: 'center',
|
||||
className: 'sidebar-chat-welcome-logo',
|
||||
icon: `${App.configDir}/assets/openai-logomark.svg`,
|
||||
setup: (self) => Utils.timeout(1, () => {
|
||||
const styleContext = self.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) * 116 / 180; // Why such a specific proportion? See https://openai.com/brand#logos
|
||||
})
|
||||
}),
|
||||
Label({
|
||||
className: 'txt txt-title-small sidebar-chat-welcome-txt',
|
||||
wrap: true,
|
||||
justify: Gtk.Justification.CENTER,
|
||||
label: 'ChatGPT',
|
||||
}),
|
||||
Box({
|
||||
className: 'spacing-h-5',
|
||||
hpack: 'center',
|
||||
children: [
|
||||
Label({
|
||||
className: 'txt-smallie txt-subtext',
|
||||
wrap: true,
|
||||
justify: Gtk.Justification.CENTER,
|
||||
label: 'Powered by OpenAI',
|
||||
}),
|
||||
Button({
|
||||
className: 'txt-subtext txt-norm icon-material',
|
||||
label: 'info',
|
||||
tooltipText: 'Uses gpt-3.5-turbo.\nNot affiliated, endorsed, or sponsored by OpenAI.',
|
||||
setup: setupCursorHoverInfo,
|
||||
}),
|
||||
]
|
||||
}),
|
||||
]
|
||||
})
|
||||
const ChatGPTInfo = () => {
|
||||
const openAiLogo = Icon({
|
||||
hpack: 'center',
|
||||
className: 'sidebar-chat-welcome-logo',
|
||||
icon: `${App.configDir}/assets/openai-logomark.svg`,
|
||||
setup: (self) => Utils.timeout(1, () => {
|
||||
const styleContext = self.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) * 116 / 180; // Why such a specific proportion? See https://openai.com/brand#logos
|
||||
})
|
||||
});
|
||||
return Box({
|
||||
vertical: true,
|
||||
className: 'spacing-v-15',
|
||||
children: [
|
||||
openAiLogo,
|
||||
Label({
|
||||
className: 'txt txt-title-small sidebar-chat-welcome-txt',
|
||||
wrap: true,
|
||||
justify: Gtk.Justification.CENTER,
|
||||
label: 'ChatGPT',
|
||||
}),
|
||||
Box({
|
||||
className: 'spacing-h-5',
|
||||
hpack: 'center',
|
||||
children: [
|
||||
Label({
|
||||
className: 'txt-smallie txt-subtext',
|
||||
wrap: true,
|
||||
justify: Gtk.Justification.CENTER,
|
||||
label: 'Powered by OpenAI',
|
||||
}),
|
||||
Button({
|
||||
className: 'txt-subtext txt-norm icon-material',
|
||||
label: 'info',
|
||||
tooltipText: 'Uses gpt-3.5-turbo.\nNot affiliated, endorsed, or sponsored by OpenAI.',
|
||||
setup: setupCursorHoverInfo,
|
||||
}),
|
||||
]
|
||||
}),
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
export const chatGPTSettings = MarginRevealer({
|
||||
export const ChatGPTSettings = () => MarginRevealer({
|
||||
transition: 'slide_down',
|
||||
revealChild: true,
|
||||
extraSetup: (self) => self
|
||||
|
|
@ -124,7 +127,7 @@ export const chatGPTSettings = MarginRevealer({
|
|||
})
|
||||
});
|
||||
|
||||
export const openaiApiKeyInstructions = Box({
|
||||
export const OpenaiApiKeyInstructions = () => Box({
|
||||
homogeneous: true,
|
||||
children: [Revealer({
|
||||
transition: 'slide_down',
|
||||
|
|
@ -158,9 +161,9 @@ export const chatGPTWelcome = Box({
|
|||
vpack: 'center',
|
||||
vertical: true,
|
||||
children: [
|
||||
chatGPTInfo,
|
||||
openaiApiKeyInstructions,
|
||||
chatGPTSettings, ``
|
||||
ChatGPTInfo(),
|
||||
OpenaiApiKeyInstructions(),
|
||||
ChatGPTSettings(),
|
||||
]
|
||||
})
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import * as Utils from 'resource:///com/github/Aylur/ags/utils.js';
|
|||
|
||||
import Bluetooth from 'resource:///com/github/Aylur/ags/service/bluetooth.js';
|
||||
import Network from 'resource:///com/github/Aylur/ags/service/network.js';
|
||||
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
|
||||
const { execAsync, exec } = Utils;
|
||||
import { BluetoothIndicator, NetworkIndicator } from "../../lib/statusicons.js";
|
||||
import { setupCursorHover } from "../../lib/cursorhover.js";
|
||||
|
|
@ -62,24 +61,30 @@ export const ToggleIconBluetooth = (props = {}) => Widget.Button({
|
|||
...props,
|
||||
});
|
||||
|
||||
export const HyprToggleIcon = (icon, name, hyprlandConfigValue, props = {}) => Widget.Button({
|
||||
className: 'txt-small sidebar-iconbutton',
|
||||
tooltipText: `${name}`,
|
||||
onClicked: (button) => {
|
||||
// Set the value to 1 - value
|
||||
Utils.execAsync(`hyprctl -j getoption ${hyprlandConfigValue}`).then((result) => {
|
||||
const currentOption = JSON.parse(result).int;
|
||||
execAsync(['bash', '-c', `hyprctl keyword ${hyprlandConfigValue} ${1 - currentOption} &`]).catch(print);
|
||||
button.toggleClassName('sidebar-button-active', currentOption == 0);
|
||||
}).catch(print);
|
||||
},
|
||||
child: MaterialIcon(icon, 'norm', { hpack: 'center' }),
|
||||
setup: button => {
|
||||
button.toggleClassName('sidebar-button-active', JSON.parse(Utils.exec(`hyprctl -j getoption ${hyprlandConfigValue}`)).int == 1);
|
||||
setupCursorHover(button);
|
||||
},
|
||||
...props,
|
||||
})
|
||||
export const HyprToggleIcon = async (icon, name, hyprlandConfigValue, props = {}) => {
|
||||
try {
|
||||
return Widget.Button({
|
||||
className: 'txt-small sidebar-iconbutton',
|
||||
tooltipText: `${name}`,
|
||||
onClicked: (button) => {
|
||||
// Set the value to 1 - value
|
||||
Utils.execAsync(`hyprctl -j getoption ${hyprlandConfigValue}`).then((result) => {
|
||||
const currentOption = JSON.parse(result).int;
|
||||
execAsync(['bash', '-c', `hyprctl keyword ${hyprlandConfigValue} ${1 - currentOption} &`]).catch(print);
|
||||
button.toggleClassName('sidebar-button-active', currentOption == 0);
|
||||
}).catch(print);
|
||||
},
|
||||
child: MaterialIcon(icon, 'norm', { hpack: 'center' }),
|
||||
setup: button => {
|
||||
button.toggleClassName('sidebar-button-active', JSON.parse(Utils.exec(`hyprctl -j getoption ${hyprlandConfigValue}`)).int == 1);
|
||||
setupCursorHover(button);
|
||||
},
|
||||
...props,
|
||||
})
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export const ModuleNightLight = (props = {}) => Widget.Button({ // TODO: Make this work
|
||||
attribute: {
|
||||
|
|
@ -104,31 +109,38 @@ export const ModuleNightLight = (props = {}) => Widget.Button({ // TODO: Make th
|
|||
...props,
|
||||
});
|
||||
|
||||
export const ModuleInvertColors = (props = {}) => Widget.Button({
|
||||
className: 'txt-small sidebar-iconbutton',
|
||||
tooltipText: 'Color inversion',
|
||||
onClicked: (button) => {
|
||||
// const shaderPath = JSON.parse(exec('hyprctl -j getoption decoration:screen_shader')).str;
|
||||
Hyprland.sendMessage('j/getoption decoration:screen_shader')
|
||||
.then((output) => {
|
||||
const shaderPath = JSON.parse(output)["str"].trim();
|
||||
console.log(output)
|
||||
console.log(shaderPath)
|
||||
if (shaderPath != "[[EMPTY]]" && shaderPath != "") {
|
||||
execAsync(['bash', '-c', `hyprctl keyword decoration:screen_shader '[[EMPTY]]'`]).catch(print);
|
||||
button.toggleClassName('sidebar-button-active', false);
|
||||
}
|
||||
else {
|
||||
Hyprland.sendMessage(`j/keyword decoration:screen_shader ${expandTilde('~/.config/hypr/shaders/invert.frag')}`)
|
||||
.catch(print);
|
||||
button.toggleClassName('sidebar-button-active', true);
|
||||
}
|
||||
})
|
||||
},
|
||||
child: MaterialIcon('invert_colors', 'norm'),
|
||||
setup: setupCursorHover,
|
||||
...props,
|
||||
})
|
||||
export const ModuleInvertColors = async (props = {}) => {
|
||||
try {
|
||||
const Hyprland = (await import('resource:///com/github/Aylur/ags/service/hyprland.js')).default;
|
||||
return Widget.Button({
|
||||
className: 'txt-small sidebar-iconbutton',
|
||||
tooltipText: 'Color inversion',
|
||||
onClicked: (button) => {
|
||||
// const shaderPath = JSON.parse(exec('hyprctl -j getoption decoration:screen_shader')).str;
|
||||
Hyprland.sendMessage('j/getoption decoration:screen_shader')
|
||||
.then((output) => {
|
||||
const shaderPath = JSON.parse(output)["str"].trim();
|
||||
console.log(output)
|
||||
console.log(shaderPath)
|
||||
if (shaderPath != "[[EMPTY]]" && shaderPath != "") {
|
||||
execAsync(['bash', '-c', `hyprctl keyword decoration:screen_shader '[[EMPTY]]'`]).catch(print);
|
||||
button.toggleClassName('sidebar-button-active', false);
|
||||
}
|
||||
else {
|
||||
Hyprland.sendMessage(`j/keyword decoration:screen_shader ${expandTilde('~/.config/hypr/shaders/invert.frag')}`)
|
||||
.catch(print);
|
||||
button.toggleClassName('sidebar-button-active', true);
|
||||
}
|
||||
})
|
||||
},
|
||||
child: MaterialIcon('invert_colors', 'norm'),
|
||||
setup: setupCursorHover,
|
||||
...props,
|
||||
})
|
||||
} catch {
|
||||
return null;
|
||||
};
|
||||
}
|
||||
|
||||
export const ModuleIdleInhibitor = (props = {}) => Widget.Button({ // TODO: Make this work
|
||||
attribute: {
|
||||
|
|
@ -173,9 +185,9 @@ export const ModuleEditIcon = (props = {}) => Widget.Button({ // TODO: Make this
|
|||
export const ModuleReloadIcon = (props = {}) => Widget.Button({
|
||||
...props,
|
||||
className: 'txt-small sidebar-iconbutton',
|
||||
tooltipText: 'Reload Hyprland',
|
||||
tooltipText: 'Reload Environment config',
|
||||
onClicked: () => {
|
||||
execAsync(['bash', '-c', 'hyprctl reload &']);
|
||||
execAsync(['bash', '-c', 'hyprctl reload || swaymsg reload &']);
|
||||
App.toggleWindow('sideright');
|
||||
},
|
||||
child: MaterialIcon('refresh', 'norm'),
|
||||
|
|
|
|||
|
|
@ -45,10 +45,10 @@ const togglesBox = Widget.Box({
|
|||
children: [
|
||||
ToggleIconWifi(),
|
||||
ToggleIconBluetooth(),
|
||||
HyprToggleIcon('mouse', 'Raw input', 'input:force_no_accel', {}),
|
||||
HyprToggleIcon('front_hand', 'No touchpad while typing', 'input:touchpad:disable_while_typing', {}),
|
||||
await HyprToggleIcon('mouse', 'Raw input', 'input:force_no_accel', {}),
|
||||
await HyprToggleIcon('front_hand', 'No touchpad while typing', 'input:touchpad:disable_while_typing', {}),
|
||||
ModuleNightLight(),
|
||||
ModuleInvertColors(),
|
||||
await ModuleInvertColors(),
|
||||
ModuleIdleInhibitor(),
|
||||
]
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue