ags: NixOS compatibility; Partially migrate to new AgsStack syntax

This commit is contained in:
end-4
2024-02-05 13:21:09 +07:00
parent ed47df35ab
commit 4fe0774547
18 changed files with 137 additions and 118 deletions
+6 -6
View File
@@ -135,14 +135,14 @@ const BarGroup = ({ child }) => Widget.Box({
const BatteryModule = () => Stack({
transition: 'slide_up_down',
transitionDuration: 150,
items: [
['laptop', Box({
children: {
'laptop': Box({
className: 'spacing-h-5', children: [
BarGroup({ child: Utilities() }),
BarGroup({ child: BarBattery() }),
]
})],
['desktop', BarGroup({
}),
'desktop': BarGroup({
child: Box({
hexpand: true,
hpack: 'center',
@@ -191,8 +191,8 @@ const BatteryModule = () => Stack({
}));
}),
})
})],
],
}),
},
setup: (stack) => Utils.timeout(10, () => {
if (!Battery.available) stack.shown = 'desktop';
else stack.shown = 'laptop';
@@ -99,10 +99,10 @@ export default (monitor = 0) => {
const stack = Stack({
transition: 'crossfade',
transitionDuration: 180,
items: [
['image', wallpaperImage],
['prompt', wallpaperPrompt],
],
children: {
'image': wallpaperImage,
'prompt': wallpaperPrompt,
},
setup: (self) => self
.hook(Wallpaper, (self) => {
const wallPath = Wallpaper.get(monitor);
@@ -1,4 +1,5 @@
const { Gdk, Gio, GLib, Gtk } = imports.gi;
import GtkSource from "gi://GtkSource?version=3.0";
import App from 'resource:///com/github/Aylur/ags/app.js';
import Widget from 'resource:///com/github/Aylur/ags/widget.js';
import * as Utils from 'resource:///com/github/Aylur/ags/utils.js';
@@ -6,12 +7,12 @@ const { Box, Button, Label, Scrollable } = Widget;
const { execAsync, exec } = Utils;
import { MaterialIcon } from "../../../lib/materialicon.js";
import md2pango from "../../../lib/md2pango.js";
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 = ' (o) ';
const CHATGPT_CURSOR = ' ...';
/////////////////////// Custom source view colorscheme /////////////////////////
+6 -6
View File
@@ -72,12 +72,12 @@ const WaifuImage = (taglist) => {
homogeneous: false,
transition: 'slide_up_down',
transitionDuration: 150,
items: [
['api', ImageState('api', 'Calling API')],
['download', ImageState('downloading', 'Downloading image')],
['done', ImageState('done', 'Finished!')],
['error', ImageState('error', 'Error')],
]
children: {
'api': ImageState('api', 'Calling API'),
'download': ImageState('downloading', 'Downloading image'),
'done': ImageState('done', 'Finished!'),
'error': ImageState('error', 'Error'),
},
});
const downloadIndicator = MarginRevealer({
vpack: 'center',
+5 -5
View File
@@ -146,11 +146,11 @@ const CalendarWidget = () => {
const defaultShown = 'calendar';
const contentStack = Widget.Stack({
hexpand: true,
items: [
['calendar', CalendarWidget()],
['todo', TodoWidget()],
// ['stars', Widget.Label({ label: 'GitHub feed will be here' })],
],
children: {
'calendar': CalendarWidget(),
'todo': TodoWidget(),
// 'stars': Widget.Label({ label: 'GitHub feed will be here' }),
},
transition: 'slide_up_down',
transitionDuration: 180,
setup: (stack) => Utils.timeout(1, () => {
@@ -122,10 +122,10 @@ export default (props) => {
const listContents = Stack({
transition: 'crossfade',
transitionDuration: 150,
items: [
['empty', notifEmptyContent],
['list', notifList]
],
children: {
'empty': notifEmptyContent,
'list': notifList,
},
setup: (self) => self
.hook(Notifications, (self) => self.shown = (Notifications.notifications.length > 0 ? 'list' : 'empty'))
,
+4 -3
View File
@@ -25,9 +25,10 @@ const timeRow = Box({
className: 'txt-small txt',
setup: (self) => self
.poll(5000, label => {
execAsync(['bash', '-c', `uptime -p | sed -e 's/up //;s/ hours,/h/;s/ minutes/m/'`]).then(upTimeString => {
label.label = `Uptime: ${upTimeString}`;
}).catch(print);
execAsync(['bash', '-c', `w | sed -n '1p' | cut -d, -f1 | cut -d' ' -f4-`])
.then(upTimeString => {
label.label = `Uptime: ${upTimeString}`;
}).catch(print);
})
,
}),
+4 -4
View File
@@ -202,10 +202,10 @@ const UndoneTodoList = () => {
const todoItemsBox = Widget.Stack({
vpack: 'fill',
transition: 'slide_left_right',
items: [
['undone', UndoneTodoList()],
['done', todoItems(true)],
],
children: {
'undone': UndoneTodoList(),
'done': todoItems(true),
},
});
export const TodoWidget = () => {