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({ export const BluetoothIndicator = () => Widget.Stack({
transition: 'slide_up_down', transition: 'slide_up_down',
items: [ children: {
['false', Widget.Label({ className: 'txt-norm icon-material', label: 'bluetooth_disabled' })], 'false': Widget.Label({ className: 'txt-norm icon-material', label: 'bluetooth_disabled' }),
['true', Widget.Label({ className: 'txt-norm icon-material', label: 'bluetooth' })], 'true': Widget.Label({ className: 'txt-norm icon-material', label: 'bluetooth' }),
], },
setup: (self) => self setup: (self) => self
.hook(Bluetooth, stack => { .hook(Bluetooth, stack => {
stack.shown = String(Bluetooth.enabled); stack.shown = String(Bluetooth.enabled);
@@ -87,13 +87,13 @@ export const BluetoothIndicator = () => Widget.Stack({
const NetworkWiredIndicator = () => Widget.Stack({ const NetworkWiredIndicator = () => Widget.Stack({
transition: 'slide_up_down', transition: 'slide_up_down',
items: [ children: {
['fallback', SimpleNetworkIndicator()], 'fallback': SimpleNetworkIndicator(),
['unknown', Widget.Label({ className: 'txt-norm icon-material', label: 'wifi_off' })], 'unknown': Widget.Label({ className: 'txt-norm icon-material', label: 'wifi_off' }),
['disconnected', Widget.Label({ className: 'txt-norm icon-material', label: 'signal_wifi_off' })], 'disconnected': Widget.Label({ className: 'txt-norm icon-material', label: 'signal_wifi_off' }),
['connected', Widget.Label({ className: 'txt-norm icon-material', label: 'lan' })], 'connected': Widget.Label({ className: 'txt-norm icon-material', label: 'lan' }),
['connecting', Widget.Label({ className: 'txt-norm icon-material', label: 'settings_ethernet' })], 'connecting': Widget.Label({ className: 'txt-norm icon-material', label: 'settings_ethernet' }),
], },
setup: (self) => self.hook(Network, stack => { setup: (self) => self.hook(Network, stack => {
if (!Network.wired) if (!Network.wired)
return; return;
@@ -118,16 +118,16 @@ const SimpleNetworkIndicator = () => Widget.Icon({
const NetworkWifiIndicator = () => Widget.Stack({ const NetworkWifiIndicator = () => Widget.Stack({
transition: 'slide_up_down', transition: 'slide_up_down',
items: [ children: {
['disabled', Widget.Label({ className: 'txt-norm icon-material', label: 'wifi_off' })], 'disabled': Widget.Label({ className: 'txt-norm icon-material', label: 'wifi_off' }),
['disconnected', Widget.Label({ className: 'txt-norm icon-material', label: 'signal_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' })], 'connecting': Widget.Label({ className: 'txt-norm icon-material', label: 'settings_ethernet' }),
['0', Widget.Label({ className: 'txt-norm icon-material', label: 'signal_wifi_0_bar' })], '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' })], '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' })], '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' })], '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' })], '4': Widget.Label({ className: 'txt-norm icon-material', label: 'signal_wifi_4_bar' }),
], },
setup: (self) => self.hook(Network, (stack) => { setup: (self) => self.hook(Network, (stack) => {
if (!Network.wifi) { if (!Network.wifi) {
return; return;
@@ -143,11 +143,11 @@ const NetworkWifiIndicator = () => Widget.Stack({
export const NetworkIndicator = () => Widget.Stack({ export const NetworkIndicator = () => Widget.Stack({
transition: 'slide_up_down', transition: 'slide_up_down',
items: [ children: {
['fallback', SimpleNetworkIndicator()], 'fallback': SimpleNetworkIndicator(),
['wifi', NetworkWifiIndicator()], 'wifi': NetworkWifiIndicator(),
['wired', NetworkWiredIndicator()], 'wired': NetworkWiredIndicator(),
], },
setup: (self) => self.hook(Network, stack => { setup: (self) => self.hook(Network, stack => {
if (!Network.primary) { if (!Network.primary) {
stack.shown = 'wifi'; stack.shown = 'wifi';
@@ -176,14 +176,21 @@ const HyprlandXkbKeyboardLayout = async ({ useFlag } = {}) => {
} }
languageStackArray = Array.from({ length: initLangs.length }, (_, i) => { languageStackArray = Array.from({ length: initLangs.length }, (_, i) => {
const lang = languages.find(lang => lang.layout == initLangs[i]); const lang = languages.find(lang => lang.layout == initLangs[i]);
if (!lang) return [ // if (!lang) return [
initLangs[i], // initLangs[i],
Widget.Label({ label: initLangs[i] }) // Widget.Label({ label: initLangs[i] })
]; // ];
return [ // return [
lang.layout, // lang.layout,
Widget.Label({ label: (useFlag ? lang.flag : 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(); updateCurrentKeyboards();
@@ -192,12 +199,15 @@ const HyprlandXkbKeyboardLayout = async ({ useFlag } = {}) => {
transition: 'slide_left', transition: 'slide_left',
revealChild: languageStackArray.length > 1, revealChild: languageStackArray.length > 1,
}); });
const widgetKids = {
...languageStackArray.reduce((obj, lang) => {
return { ...obj, ...lang };
}, {}),
'undef': Widget.Label({ label: '?' }),
}
const widgetContent = Widget.Stack({ const widgetContent = Widget.Stack({
transition: 'slide_up_down', transition: 'slide_up_down',
items: [ children: widgetKids,
...languageStackArray,
['undef', Widget.Label({ label: '?' })]
],
setup: (self) => self.hook(Hyprland, (stack, kbName, layoutName) => { setup: (self) => self.hook(Hyprland, (stack, kbName, layoutName) => {
if (!kbName) { if (!kbName) {
return; return;
@@ -1,4 +1,4 @@
#!/usr/bin/bash #!/usr/bin/env bash
# check if no arguments # check if no arguments
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
@@ -1,4 +1,4 @@
#!/bin/python3 #!/usr/bin/env python3
from material_color_utilities_python import * from material_color_utilities_python import *
from pathlib import Path from pathlib import Path
import sys import sys
@@ -1,4 +1,4 @@
#!/usr/bin/bash #!/usr/bin/env bash
color=$(hyprpicker --no-fancy) color=$(hyprpicker --no-fancy)
@@ -1,4 +1,4 @@
#!/usr/bin/bash #!/usr/bin/env bash
if [ "$1" == "--noswitch" ]; then if [ "$1" == "--noswitch" ]; then
imgpath=$(swww query | awk -F 'image: ' '{print $2}') 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)) hyprctl dispatch "$1" $(((($(hyprctl activeworkspace -j | gojq -r .id) - 1) / 10) * 10 + $2))
+8 -1
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 # Get the current workspace number
current=$(swaymsg -t get_workspaces | gojq '.[] | select(.focused==true) | .num') current=$(swaymsg -t get_workspaces | gojq '.[] | select(.focused==true) | .num')
@@ -87,9 +87,9 @@
"BLACK_500": "#393634", "BLACK_500": "#393634",
"BLACK_700": "#33302F", "BLACK_700": "#33302F",
"BLACK_900": "#2B2928", "BLACK_900": "#2B2928",
"accent_bg_color": "#e4b5ff", "accent_bg_color": "#ffb1c3",
"accent_fg_color": "#471868", "accent_fg_color": "#66002a",
"accent_color": "#e4b5ff", "accent_color": "#ffb1c3",
"destructive_bg_color": "#ffb4a9", "destructive_bg_color": "#ffb4a9",
"destructive_fg_color": "#680003", "destructive_fg_color": "#680003",
"destructive_color": "#ffb4a9", "destructive_color": "#ffb4a9",
@@ -99,22 +99,22 @@
"warning_fg_color": "rgba(0, 0, 0, 0.87)", "warning_fg_color": "rgba(0, 0, 0, 0.87)",
"error_bg_color": "#ffb4a9", "error_bg_color": "#ffb4a9",
"error_fg_color": "#680003", "error_fg_color": "#680003",
"window_bg_color": "#111012", "window_bg_color": "#130F10",
"window_fg_color": "#e7e0e5", "window_fg_color": "#ecdfe0",
"view_bg_color": "#1d1b1e", "view_bg_color": "#201a1b",
"view_fg_color": "#e7e0e5", "view_fg_color": "#ecdfe0",
"headerbar_bg_color": "mix(@dialog_bg_color, @window_bg_color, 0.5)", "headerbar_bg_color": "mix(@dialog_bg_color, @window_bg_color, 0.5)",
"headerbar_fg_color": "#eedcf5", "headerbar_fg_color": "#ffd9df",
"headerbar_border_color": "#4f4256", "headerbar_border_color": "#5c3f45",
"headerbar_backdrop_color": "@headerbar_bg_color", "headerbar_backdrop_color": "@headerbar_bg_color",
"headerbar_shade_color": "rgba(0, 0, 0, 0.09)", "headerbar_shade_color": "rgba(0, 0, 0, 0.09)",
"card_bg_color": "#111012", "card_bg_color": "#130F10",
"card_fg_color": "#eedcf5", "card_fg_color": "#ffd9df",
"card_shade_color": "rgba(0, 0, 0, 0.09)", "card_shade_color": "rgba(0, 0, 0, 0.09)",
"dialog_bg_color": "#4f4256", "dialog_bg_color": "#5c3f45",
"dialog_fg_color": "#eedcf5", "dialog_fg_color": "#ffd9df",
"popover_bg_color": "#4f4256", "popover_bg_color": "#5c3f45",
"popover_fg_color": "#eedcf5", "popover_fg_color": "#ffd9df",
"thumbnail_bg_color": "#1a1b26", "thumbnail_bg_color": "#1a1b26",
"thumbnail_fg_color": "#AEE5FA", "thumbnail_fg_color": "#AEE5FA",
"shade_color": "rgba(0, 0, 0, 0.36)", "shade_color": "rgba(0, 0, 0, 0.36)",
+1 -1
View File
@@ -42,7 +42,7 @@ $rounding_large: 1.705rem;
@mixin icon-material { @mixin icon-material {
// Material Design Icons // Material Design Icons
font-family: "Material Symbols Rounded", "Material Symbols Outlined", font-family: "Material Symbols Rounded", "MaterialSymbolsRounded", "Material Symbols Outlined",
"Material Symbols Sharp"; "Material Symbols Sharp";
} }
+23 -23
View File
@@ -1,29 +1,29 @@
$darkmode: true; $darkmode: true;
$primary: #e4b5ff; $primary: #ffb1c3;
$onPrimary: #471868; $onPrimary: #66002a;
$primaryContainer: #5f3280; $primaryContainer: #861c40;
$onPrimaryContainer: #f4d9ff; $onPrimaryContainer: #ffd9e0;
$secondary: #d2c1d9; $secondary: #e4bcc3;
$onSecondary: #372c3e; $onSecondary: #42292e;
$secondaryContainer: #4f4256; $secondaryContainer: #5c3f45;
$onSecondaryContainer: #eedcf5; $onSecondaryContainer: #ffd9df;
$tertiary: #f4b7ba; $tertiary: #ecbe91;
$onTertiary: #4b2528; $onTertiary: #462a08;
$tertiaryContainer: #663b3e; $tertiaryContainer: #60401d;
$onTertiaryContainer: #ffdadc; $onTertiaryContainer: #ffdcb9;
$error: #ffb4a9; $error: #ffb4a9;
$onError: #680003; $onError: #680003;
$errorContainer: #930006; $errorContainer: #930006;
$onErrorContainer: #ffb4a9; $onErrorContainer: #ffb4a9;
$colorbarbg: #111012; $colorbarbg: #130F10;
$background: #111012; $background: #130F10;
$onBackground: #e7e0e5; $onBackground: #ecdfe0;
$surface: #1d1b1e; $surface: #201a1b;
$onSurface: #e7e0e5; $onSurface: #ecdfe0;
$surfaceVariant: #4b454d; $surfaceVariant: #514345;
$onSurfaceVariant: #cdc3ce; $onSurfaceVariant: #d6c1c4;
$outline: #968e98; $outline: #9f8c8f;
$shadow: #000000; $shadow: #000000;
$inverseSurface: #e7e0e5; $inverseSurface: #ecdfe0;
$inverseOnSurface: #322f33; $inverseOnSurface: #362f30;
$inversePrimary: #784a9a; $inversePrimary: #a53557;
+6 -6
View File
@@ -135,14 +135,14 @@ const BarGroup = ({ child }) => Widget.Box({
const BatteryModule = () => Stack({ const BatteryModule = () => Stack({
transition: 'slide_up_down', transition: 'slide_up_down',
transitionDuration: 150, transitionDuration: 150,
items: [ children: {
['laptop', Box({ 'laptop': Box({
className: 'spacing-h-5', children: [ className: 'spacing-h-5', children: [
BarGroup({ child: Utilities() }), BarGroup({ child: Utilities() }),
BarGroup({ child: BarBattery() }), BarGroup({ child: BarBattery() }),
] ]
})], }),
['desktop', BarGroup({ 'desktop': BarGroup({
child: Box({ child: Box({
hexpand: true, hexpand: true,
hpack: 'center', hpack: 'center',
@@ -191,8 +191,8 @@ const BatteryModule = () => Stack({
})); }));
}), }),
}) })
})], }),
], },
setup: (stack) => Utils.timeout(10, () => { setup: (stack) => Utils.timeout(10, () => {
if (!Battery.available) stack.shown = 'desktop'; if (!Battery.available) stack.shown = 'desktop';
else stack.shown = 'laptop'; else stack.shown = 'laptop';
@@ -99,10 +99,10 @@ export default (monitor = 0) => {
const stack = Stack({ const stack = Stack({
transition: 'crossfade', transition: 'crossfade',
transitionDuration: 180, transitionDuration: 180,
items: [ children: {
['image', wallpaperImage], 'image': wallpaperImage,
['prompt', wallpaperPrompt], 'prompt': wallpaperPrompt,
], },
setup: (self) => self setup: (self) => self
.hook(Wallpaper, (self) => { .hook(Wallpaper, (self) => {
const wallPath = Wallpaper.get(monitor); const wallPath = Wallpaper.get(monitor);
@@ -1,4 +1,5 @@
const { Gdk, Gio, GLib, Gtk } = imports.gi; 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 App from 'resource:///com/github/Aylur/ags/app.js';
import Widget from 'resource:///com/github/Aylur/ags/widget.js'; import Widget from 'resource:///com/github/Aylur/ags/widget.js';
import * as Utils from 'resource:///com/github/Aylur/ags/utils.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; const { execAsync, exec } = Utils;
import { MaterialIcon } from "../../../lib/materialicon.js"; import { MaterialIcon } from "../../../lib/materialicon.js";
import md2pango from "../../../lib/md2pango.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_SOURCEVIEW_SCHEME_PATH = `${App.configDir}/data/sourceviewtheme.xml`;
const CUSTOM_SCHEME_ID = 'custom'; const CUSTOM_SCHEME_ID = 'custom';
const USERNAME = GLib.get_user_name(); const USERNAME = GLib.get_user_name();
const CHATGPT_CURSOR = ' (o) '; const CHATGPT_CURSOR = ' ...';
/////////////////////// Custom source view colorscheme ///////////////////////// /////////////////////// Custom source view colorscheme /////////////////////////
+6 -6
View File
@@ -72,12 +72,12 @@ const WaifuImage = (taglist) => {
homogeneous: false, homogeneous: false,
transition: 'slide_up_down', transition: 'slide_up_down',
transitionDuration: 150, transitionDuration: 150,
items: [ children: {
['api', ImageState('api', 'Calling API')], 'api': ImageState('api', 'Calling API'),
['download', ImageState('downloading', 'Downloading image')], 'download': ImageState('downloading', 'Downloading image'),
['done', ImageState('done', 'Finished!')], 'done': ImageState('done', 'Finished!'),
['error', ImageState('error', 'Error')], 'error': ImageState('error', 'Error'),
] },
}); });
const downloadIndicator = MarginRevealer({ const downloadIndicator = MarginRevealer({
vpack: 'center', vpack: 'center',
+5 -5
View File
@@ -146,11 +146,11 @@ const CalendarWidget = () => {
const defaultShown = 'calendar'; const defaultShown = 'calendar';
const contentStack = Widget.Stack({ const contentStack = Widget.Stack({
hexpand: true, hexpand: true,
items: [ children: {
['calendar', CalendarWidget()], 'calendar': CalendarWidget(),
['todo', TodoWidget()], 'todo': TodoWidget(),
// ['stars', Widget.Label({ label: 'GitHub feed will be here' })], // 'stars': Widget.Label({ label: 'GitHub feed will be here' }),
], },
transition: 'slide_up_down', transition: 'slide_up_down',
transitionDuration: 180, transitionDuration: 180,
setup: (stack) => Utils.timeout(1, () => { setup: (stack) => Utils.timeout(1, () => {
@@ -122,10 +122,10 @@ export default (props) => {
const listContents = Stack({ const listContents = Stack({
transition: 'crossfade', transition: 'crossfade',
transitionDuration: 150, transitionDuration: 150,
items: [ children: {
['empty', notifEmptyContent], 'empty': notifEmptyContent,
['list', notifList] 'list': notifList,
], },
setup: (self) => self setup: (self) => self
.hook(Notifications, (self) => self.shown = (Notifications.notifications.length > 0 ? 'list' : 'empty')) .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', className: 'txt-small txt',
setup: (self) => self setup: (self) => self
.poll(5000, label => { .poll(5000, label => {
execAsync(['bash', '-c', `uptime -p | sed -e 's/up //;s/ hours,/h/;s/ minutes/m/'`]).then(upTimeString => { execAsync(['bash', '-c', `w | sed -n '1p' | cut -d, -f1 | cut -d' ' -f4-`])
label.label = `Uptime: ${upTimeString}`; .then(upTimeString => {
}).catch(print); label.label = `Uptime: ${upTimeString}`;
}).catch(print);
}) })
, ,
}), }),
+4 -4
View File
@@ -202,10 +202,10 @@ const UndoneTodoList = () => {
const todoItemsBox = Widget.Stack({ const todoItemsBox = Widget.Stack({
vpack: 'fill', vpack: 'fill',
transition: 'slide_left_right', transition: 'slide_left_right',
items: [ children: {
['undone', UndoneTodoList()], 'undone': UndoneTodoList(),
['done', todoItems(true)], 'done': todoItems(true),
], },
}); });
export const TodoWidget = () => { export const TodoWidget = () => {