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
+48 -38
View File
@@ -73,10 +73,10 @@ export const NotificationIndicator = (notifCenterName = 'sideright') => {
export const BluetoothIndicator = () => Widget.Stack({
transition: 'slide_up_down',
items: [
['false', Widget.Label({ className: 'txt-norm icon-material', label: 'bluetooth_disabled' })],
['true', Widget.Label({ className: 'txt-norm icon-material', label: 'bluetooth' })],
],
children: {
'false': Widget.Label({ className: 'txt-norm icon-material', label: 'bluetooth_disabled' }),
'true': Widget.Label({ className: 'txt-norm icon-material', label: 'bluetooth' }),
},
setup: (self) => self
.hook(Bluetooth, stack => {
stack.shown = String(Bluetooth.enabled);
@@ -87,13 +87,13 @@ export const BluetoothIndicator = () => Widget.Stack({
const NetworkWiredIndicator = () => Widget.Stack({
transition: 'slide_up_down',
items: [
['fallback', SimpleNetworkIndicator()],
['unknown', Widget.Label({ className: 'txt-norm icon-material', label: 'wifi_off' })],
['disconnected', Widget.Label({ className: 'txt-norm icon-material', label: 'signal_wifi_off' })],
['connected', Widget.Label({ className: 'txt-norm icon-material', label: 'lan' })],
['connecting', Widget.Label({ className: 'txt-norm icon-material', label: 'settings_ethernet' })],
],
children: {
'fallback': SimpleNetworkIndicator(),
'unknown': Widget.Label({ className: 'txt-norm icon-material', label: 'wifi_off' }),
'disconnected': Widget.Label({ className: 'txt-norm icon-material', label: 'signal_wifi_off' }),
'connected': Widget.Label({ className: 'txt-norm icon-material', label: 'lan' }),
'connecting': Widget.Label({ className: 'txt-norm icon-material', label: 'settings_ethernet' }),
},
setup: (self) => self.hook(Network, stack => {
if (!Network.wired)
return;
@@ -118,16 +118,16 @@ const SimpleNetworkIndicator = () => Widget.Icon({
const NetworkWifiIndicator = () => Widget.Stack({
transition: 'slide_up_down',
items: [
['disabled', Widget.Label({ className: 'txt-norm icon-material', label: 'wifi_off' })],
['disconnected', Widget.Label({ className: 'txt-norm icon-material', label: 'signal_wifi_off' })],
['connecting', Widget.Label({ className: 'txt-norm icon-material', label: 'settings_ethernet' })],
['0', Widget.Label({ className: 'txt-norm icon-material', label: 'signal_wifi_0_bar' })],
['1', Widget.Label({ className: 'txt-norm icon-material', label: 'network_wifi_1_bar' })],
['2', Widget.Label({ className: 'txt-norm icon-material', label: 'network_wifi_2_bar' })],
['3', Widget.Label({ className: 'txt-norm icon-material', label: 'network_wifi_3_bar' })],
['4', Widget.Label({ className: 'txt-norm icon-material', label: 'signal_wifi_4_bar' })],
],
children: {
'disabled': Widget.Label({ className: 'txt-norm icon-material', label: 'wifi_off' }),
'disconnected': Widget.Label({ className: 'txt-norm icon-material', label: 'signal_wifi_off' }),
'connecting': Widget.Label({ className: 'txt-norm icon-material', label: 'settings_ethernet' }),
'0': Widget.Label({ className: 'txt-norm icon-material', label: 'signal_wifi_0_bar' }),
'1': Widget.Label({ className: 'txt-norm icon-material', label: 'network_wifi_1_bar' }),
'2': Widget.Label({ className: 'txt-norm icon-material', label: 'network_wifi_2_bar' }),
'3': Widget.Label({ className: 'txt-norm icon-material', label: 'network_wifi_3_bar' }),
'4': Widget.Label({ className: 'txt-norm icon-material', label: 'signal_wifi_4_bar' }),
},
setup: (self) => self.hook(Network, (stack) => {
if (!Network.wifi) {
return;
@@ -143,11 +143,11 @@ const NetworkWifiIndicator = () => Widget.Stack({
export const NetworkIndicator = () => Widget.Stack({
transition: 'slide_up_down',
items: [
['fallback', SimpleNetworkIndicator()],
['wifi', NetworkWifiIndicator()],
['wired', NetworkWiredIndicator()],
],
children: {
'fallback': SimpleNetworkIndicator(),
'wifi': NetworkWifiIndicator(),
'wired': NetworkWiredIndicator(),
},
setup: (self) => self.hook(Network, stack => {
if (!Network.primary) {
stack.shown = 'wifi';
@@ -176,14 +176,21 @@ const HyprlandXkbKeyboardLayout = async ({ useFlag } = {}) => {
}
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) })
];
// if (!lang) return [
// initLangs[i],
// Widget.Label({ label: initLangs[i] })
// ];
// return [
// lang.layout,
// Widget.Label({ label: (useFlag ? lang.flag : lang.layout) })
// ];
// Object
if (!lang) return {
[initLangs[i]]: Widget.Label({ label: initLangs[i] })
};
return {
[lang.layout]: Widget.Label({ label: (useFlag ? lang.flag : lang.layout) })
};
});
};
updateCurrentKeyboards();
@@ -192,12 +199,15 @@ const HyprlandXkbKeyboardLayout = async ({ useFlag } = {}) => {
transition: 'slide_left',
revealChild: languageStackArray.length > 1,
});
const widgetKids = {
...languageStackArray.reduce((obj, lang) => {
return { ...obj, ...lang };
}, {}),
'undef': Widget.Label({ label: '?' }),
}
const widgetContent = Widget.Stack({
transition: 'slide_up_down',
items: [
...languageStackArray,
['undef', Widget.Label({ label: '?' })]
],
children: widgetKids,
setup: (self) => self.hook(Hyprland, (stack, kbName, layoutName) => {
if (!kbName) {
return;
@@ -1,4 +1,4 @@
#!/usr/bin/bash
#!/usr/bin/env bash
# check if no arguments
if [ $# -eq 0 ]; then
@@ -1,4 +1,4 @@
#!/bin/python3
#!/usr/bin/env python3
from material_color_utilities_python import *
from pathlib import Path
import sys
@@ -1,4 +1,4 @@
#!/usr/bin/bash
#!/usr/bin/env bash
color=$(hyprpicker --no-fancy)
@@ -1,4 +1,4 @@
#!/usr/bin/bash
#!/usr/bin/env bash
if [ "$1" == "--noswitch" ]; then
imgpath=$(swww query | awk -F 'image: ' '{print $2}')
@@ -1,2 +1,2 @@
#!/bin/bash
#!/usr/bin/env bash
hyprctl dispatch "$1" $(((($(hyprctl activeworkspace -j | gojq -r .id) - 1) / 10) * 10 + $2))
+9 -2
View File
@@ -1,4 +1,11 @@
#!/bin/bash
#!/usr/bin/env bash
# Check if sway is running
if ! pgrep -x sway > /dev/null; then
echo "Sway is not running"
exit 1
fi
# Get the current workspace number
current=$(swaymsg -t get_workspaces | gojq '.[] | select(.focused==true) | .num')
@@ -20,4 +27,4 @@ if [[ $2 == 'move' ]]; then
swaymsg move container to workspace $new_workspace
else
swaymsg workspace $new_workspace
fi
fi
@@ -87,9 +87,9 @@
"BLACK_500": "#393634",
"BLACK_700": "#33302F",
"BLACK_900": "#2B2928",
"accent_bg_color": "#e4b5ff",
"accent_fg_color": "#471868",
"accent_color": "#e4b5ff",
"accent_bg_color": "#ffb1c3",
"accent_fg_color": "#66002a",
"accent_color": "#ffb1c3",
"destructive_bg_color": "#ffb4a9",
"destructive_fg_color": "#680003",
"destructive_color": "#ffb4a9",
@@ -99,22 +99,22 @@
"warning_fg_color": "rgba(0, 0, 0, 0.87)",
"error_bg_color": "#ffb4a9",
"error_fg_color": "#680003",
"window_bg_color": "#111012",
"window_fg_color": "#e7e0e5",
"view_bg_color": "#1d1b1e",
"view_fg_color": "#e7e0e5",
"window_bg_color": "#130F10",
"window_fg_color": "#ecdfe0",
"view_bg_color": "#201a1b",
"view_fg_color": "#ecdfe0",
"headerbar_bg_color": "mix(@dialog_bg_color, @window_bg_color, 0.5)",
"headerbar_fg_color": "#eedcf5",
"headerbar_border_color": "#4f4256",
"headerbar_fg_color": "#ffd9df",
"headerbar_border_color": "#5c3f45",
"headerbar_backdrop_color": "@headerbar_bg_color",
"headerbar_shade_color": "rgba(0, 0, 0, 0.09)",
"card_bg_color": "#111012",
"card_fg_color": "#eedcf5",
"card_bg_color": "#130F10",
"card_fg_color": "#ffd9df",
"card_shade_color": "rgba(0, 0, 0, 0.09)",
"dialog_bg_color": "#4f4256",
"dialog_fg_color": "#eedcf5",
"popover_bg_color": "#4f4256",
"popover_fg_color": "#eedcf5",
"dialog_bg_color": "#5c3f45",
"dialog_fg_color": "#ffd9df",
"popover_bg_color": "#5c3f45",
"popover_fg_color": "#ffd9df",
"thumbnail_bg_color": "#1a1b26",
"thumbnail_fg_color": "#AEE5FA",
"shade_color": "rgba(0, 0, 0, 0.36)",
+1 -1
View File
@@ -42,7 +42,7 @@ $rounding_large: 1.705rem;
@mixin icon-material {
// Material Design Icons
font-family: "Material Symbols Rounded", "Material Symbols Outlined",
font-family: "Material Symbols Rounded", "MaterialSymbolsRounded", "Material Symbols Outlined",
"Material Symbols Sharp";
}
+23 -23
View File
@@ -1,29 +1,29 @@
$darkmode: true;
$primary: #e4b5ff;
$onPrimary: #471868;
$primaryContainer: #5f3280;
$onPrimaryContainer: #f4d9ff;
$secondary: #d2c1d9;
$onSecondary: #372c3e;
$secondaryContainer: #4f4256;
$onSecondaryContainer: #eedcf5;
$tertiary: #f4b7ba;
$onTertiary: #4b2528;
$tertiaryContainer: #663b3e;
$onTertiaryContainer: #ffdadc;
$primary: #ffb1c3;
$onPrimary: #66002a;
$primaryContainer: #861c40;
$onPrimaryContainer: #ffd9e0;
$secondary: #e4bcc3;
$onSecondary: #42292e;
$secondaryContainer: #5c3f45;
$onSecondaryContainer: #ffd9df;
$tertiary: #ecbe91;
$onTertiary: #462a08;
$tertiaryContainer: #60401d;
$onTertiaryContainer: #ffdcb9;
$error: #ffb4a9;
$onError: #680003;
$errorContainer: #930006;
$onErrorContainer: #ffb4a9;
$colorbarbg: #111012;
$background: #111012;
$onBackground: #e7e0e5;
$surface: #1d1b1e;
$onSurface: #e7e0e5;
$surfaceVariant: #4b454d;
$onSurfaceVariant: #cdc3ce;
$outline: #968e98;
$colorbarbg: #130F10;
$background: #130F10;
$onBackground: #ecdfe0;
$surface: #201a1b;
$onSurface: #ecdfe0;
$surfaceVariant: #514345;
$onSurfaceVariant: #d6c1c4;
$outline: #9f8c8f;
$shadow: #000000;
$inverseSurface: #e7e0e5;
$inverseOnSurface: #322f33;
$inversePrimary: #784a9a;
$inverseSurface: #ecdfe0;
$inverseOnSurface: #362f30;
$inversePrimary: #a53557;
+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 = () => {