ags: some migration

i cry
This commit is contained in:
end-4 2023-12-29 18:17:08 +07:00
parent 0f91b010a6
commit 10bc1c4ef8
16 changed files with 551 additions and 569 deletions

View file

@ -161,18 +161,24 @@ export default ({
children: [
Overlay({
child: NotificationIcon(notifObject),
overlays: [
AnimatedCircProg({
className: `notif-circprog-${notifObject.urgency}`,
valign: Gtk.Align.CENTER,
initFrom: (isPopup ? 100 : 0),
initTo: 0,
initAnimTime: popupTimeout,
})
]
overlays: isPopup ? [AnimatedCircProg({
className: `notif-circprog-${notifObject.urgency}`,
valign: Gtk.Align.CENTER,
initFrom: (isPopup ? 100 : 0),
initTo: 0,
initAnimTime: popupTimeout,
})] : [],
}),
]
});
let notifTime = '';
const messageTime = GLib.DateTime.new_from_unix_local(notifObject.time);
if (messageTime.get_day_of_year() == GLib.DateTime.new_now_local().get_day_of_year())
notifTime = messageTime.format('%H:%M');
else if (messageTime.get_day_of_year() == GLib.DateTime.new_now_local().get_day_of_year() - 1)
notifTime = 'Yesterday';
else
notifTime = messageTime.format('%d/%m');
const notifText = Box({
valign: Gtk.Align.CENTER,
vertical: true,
@ -188,27 +194,14 @@ export default ({
maxWidthChars: 24,
truncate: 'end',
ellipsize: 3,
// wrap: true,
useMarkup: notifObject.summary.startsWith('<'),
label: notifObject.summary,
}),
Label({
valign: Gtk.Align.CENTER,
vpack: 'center',
justification: 'right',
className: 'txt-smaller txt-semibold',
justify: Gtk.Justification.RIGHT,
setup: (label) => {
// Let's ignore how it won't work for Jan1 cuz I'm lazy
const messageTime = GLib.DateTime.new_from_unix_local(notifObject.time);
if (messageTime.get_day_of_year() == GLib.DateTime.new_now_local().get_day_of_year()) {
label.label = messageTime.format('%H:%M');
}
else if (messageTime.get_day_of_year() == GLib.DateTime.new_now_local().get_day_of_year() - 1) {
label.label = messageTime.format('Yesterday');
}
else {
label.label = messageTime.format('%d/%m');
}
}
label: notifTime,
}),
]
}),
@ -243,17 +236,6 @@ export default ({
notifIcon,
notifText,
notifExpandButton,
// what is this? i think it should be at the bottom not on the right
// Box({
// className: 'actions',
// children: actions.map(action => Button({
// className: 'action-button',
// onClicked: () => Notifications.invoke(id, action.id),
// hexpand: true,
// child: Label(action.label),
// })),
// }),
]
})
@ -284,16 +266,16 @@ export default ({
opacity: 0;`;
const notificationBox = Box({
properties: [
['leftAnim1', leftAnim1],
['rightAnim1', rightAnim1],
['middleClickClose', middleClickClose],
['ready', false],
],
attribute: {
'leftAnim1': leftAnim1,
'rightAnim1': rightAnim1,
'middleClickClose': middleClickClose,
'ready': false,
},
homogeneous: true,
children: [notificationContent],
connections: [
[gesture, self => {
setup: (self) => self
.hook(gesture, self => {
var offset = gesture.get_offset()[1];
if (initialDir == 0 && offset != 0)
initialDir = (offset > 0 ? 1 : -1)
@ -323,9 +305,8 @@ export default ({
if (widget.window)
widget.window.set_cursor(Gdk.Cursor.new_from_name(display, 'grabbing'));
}, 'drag-update'],
[gesture, self => {
}, 'drag-update')
.hook(gesture, self => {
if (!self._ready) {
wholeThing.revealChild = true;
self._ready = true;
@ -362,9 +343,8 @@ export default ({
wholeThing._dragging = false;
}
initialDir = 0;
}, 'drag-end'],
],
}, 'drag-end')
,
})
widget.add(notificationBox);
wholeThing.child.children = [widget];

View file

@ -17,11 +17,13 @@ export default ({
child: Box({
className: `${showClassName} ${hideClassName}`,
connections: [[App, (self, currentName, visible) => {
if (currentName === name) {
self.toggleClassName(hideClassName, !visible);
}
}]],
setup: (self) => self
.hook(App, (self, currentName, visible) => {
if (currentName === name) {
self.toggleClassName(hideClassName, !visible);
}
})
,
child: child,
}),
});

View file

@ -27,18 +27,18 @@ export const NotificationIndicator = (notifCenterName = 'sideright') => {
transition: 150,
transition: 'slide_left',
revealChild: false,
connections: [
[Notifications, (self, id) => {
setup: (self) => self
.hook(Notifications, (self, id) => {
if (!id || Notifications.dnd) return;
if (!Notifications.getNotification(id)) return;
self.revealChild = true;
}, 'notified'],
[App, (self, currentName, visible) => {
}, 'notified')
.hook(App, (self, currentName, visible) => {
if (visible && currentName === notifCenterName) {
self.revealChild = false;
}
}],
],
})
,
child: Widget.Box({
children: [
MaterialIcon('notifications', 'norm'),
@ -50,20 +50,20 @@ export const NotificationIndicator = (notifCenterName = 'sideright') => {
['update', (self) => self.label = `${self._unreadCount}`],
['unreadCount', 0],
],
connections: [
[Notifications, (self, id) => {
setup: (self) => self
.hook(Notifications, (self, id) => {
if (!id || Notifications.dnd) return;
if (!Notifications.getNotification(id)) return;
self._increment(self);
self._update(self);
}, 'notified'],
[App, (self, currentName, visible) => {
}, 'notified')
.hook(App, (self, currentName, visible) => {
if (visible && currentName === notifCenterName) {
self._markread(self);
self._update(self);
}
}],
]
})
,
})
]
})
@ -77,7 +77,11 @@ export const BluetoothIndicator = () => Widget.Stack({
['true', Widget.Label({ className: 'txt-norm icon-material', label: 'bluetooth' })],
['false', Widget.Label({ className: 'txt-norm icon-material', label: 'bluetooth_disabled' })],
],
connections: [[Bluetooth, stack => { stack.shown = String(Bluetooth.enabled); }]],
setup: (self) => self
.hook(Bluetooth, stack => {
stack.shown = String(Bluetooth.enabled);
})
,
});
@ -90,7 +94,7 @@ const NetworkWiredIndicator = () => Widget.Stack({
['connected', Widget.Label({ className: 'txt-norm icon-material', label: 'lan' })],
['connecting', Widget.Label({ className: 'txt-norm icon-material', label: 'settings_ethernet' })],
],
connections: [[Network, stack => {
setup: (self) => self.hook(Network, stack => {
if (!Network.wired)
return;
@ -101,15 +105,15 @@ const NetworkWiredIndicator = () => Widget.Stack({
stack.shown = 'disconnected';
else
stack.shown = 'fallback';
}]],
}),
});
const SimpleNetworkIndicator = () => Widget.Icon({
connections: [[Network, self => {
setup: (self) => self.hook(Network, self => {
const icon = Network[Network.primary || 'wifi']?.iconName;
self.icon = icon || '';
self.visible = icon;
}]],
}),
});
const NetworkWifiIndicator = () => Widget.Stack({
@ -124,7 +128,7 @@ const NetworkWifiIndicator = () => Widget.Stack({
['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' })],
],
connections: [[Network, (stack) => {
setup: (self) => self.hook(Network, (stack) => {
if (!Network.wifi) {
return;
}
@ -134,7 +138,7 @@ const NetworkWifiIndicator = () => Widget.Stack({
else if (Network.wifi.internet == 'disconnected' || Network.wifi.internet == 'connecting') {
stack.shown = Network.wifi.internet;
}
}]],
}),
});
export const NetworkIndicator = () => Widget.Stack({
@ -144,8 +148,8 @@ export const NetworkIndicator = () => Widget.Stack({
['wifi', NetworkWifiIndicator()],
['wired', NetworkWiredIndicator()],
],
connections: [[Network, stack => {
if(!Network.primary) {
setup: (self) => self.hook(Network, stack => {
if (!Network.primary) {
stack.shown = 'wifi';
return;
}
@ -154,7 +158,7 @@ export const NetworkIndicator = () => Widget.Stack({
stack.shown = primary;
else
stack.shown = 'fallback';
}]],
}),
});
const KeyboardLayout = ({ useFlag } = {}) => {
@ -192,22 +196,20 @@ const KeyboardLayout = ({ useFlag } = {}) => {
...languageStackArray,
['undef', Widget.Label({ label: '?' })]
],
connections: [
[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']
],
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;

View file

@ -72,7 +72,7 @@ $notchOnPrimary: $onPrimary;
.bar-group-pad-music {
padding-right: 1.023rem;
// padding-left: 0.273rem;
padding-left: 0.341rem;
}
.bar-group-pad-left {

File diff suppressed because it is too large Load diff

View file

@ -74,18 +74,16 @@ export const ModuleLeftSpace = () => Widget.EventBox({
Widget.Label({
xalign: 0,
className: 'txt-smaller bar-topdesc txt',
connections: [[Hyprland.active.client, label => { // Hyprland.active.client
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',
connections: [
[Hyprland.active.client, label => { // Hyprland.active.client
label.label = Hyprland.active.client._title.length === 0 ? `Workspace ${Hyprland.active.workspace.id}` : truncateTitle(Hyprland.active.client._title);
}]
],
setup: (self) => self.hook(Hyprland.active.client, label => { // Hyprland.active.client
label.label = Hyprland.active.client._title.length === 0 ? `Workspace ${Hyprland.active.workspace.id}` : truncateTitle(Hyprland.active.client._title);
}),
})
]
})

View file

@ -11,11 +11,11 @@ export const ModuleRightSpace = () => {
const barTray = Tray();
const barStatusIcons = StatusIcons({
className: 'bar-statusicons',
connections: [[App, (self, currentName, visible) => {
setup: (self) => self.hook(App, (self, currentName, visible) => {
if (currentName === 'sideright') {
self.toggleClassName('bar-statusicons-active', visible);
}
}]],
}),
});
return Widget.EventBox({

View file

@ -14,9 +14,10 @@ const BarClock = () => Widget.Box({
children: [
Widget.Label({
className: 'bar-clock',
connections: [[5000, label => {
label: GLib.DateTime.new_now_local().format("%H:%M"),
setup: (self) => self.poll(5000, label => {
label.label = GLib.DateTime.new_now_local().format("%H:%M");
}]],
}),
}),
Widget.Label({
className: 'txt-norm txt',
@ -24,9 +25,10 @@ const BarClock = () => Widget.Box({
}),
Widget.Label({
className: 'txt-smallie txt',
connections: [[5000, label => {
label: GLib.DateTime.new_now_local().format("%A, %d/%m"),
setup: (self) => self.poll(5000, label => {
label.label = GLib.DateTime.new_now_local().format("%A, %d/%m");
}]],
}),
}),
],
});
@ -40,13 +42,13 @@ const BarBattery = () => {
Widget.ProgressBar({ // Progress
vpack: 'center', hexpand: true,
className: 'bar-prog-batt',
connections: [[5000, (progress) => execAsync(['bash', '-c', command])
setup: (self) => self.poll(5000, (progress) => execAsync(['bash', '-c', command])
.then((output) => {
progress.value = Number(output) / 100;
progress.tooltipText = `${name}: ${Number(output)}%`
})
.catch(print)
]],
),
}),
]
});
@ -54,28 +56,28 @@ const BarBattery = () => {
vpack: 'center',
hexpand: true,
className: 'spacing-h-5 bar-batt',
connections: [[Battery, box => {
setup: (self) => self.hook(Battery, box => {
box.toggleClassName('bar-batt-low', Battery.percent <= BATTERY_LOW);
box.toggleClassName('bar-batt-full', Battery.charged);
}]],
}),
children: [
MaterialIcon('settings_heart', 'small'),
Widget.Label({ // Percentage
className: 'bar-batt-percentage',
connections: [[Battery, label => {
setup: (self) => self.hook(Battery, label => {
label.label = `${Battery.percent}`;
}]],
}),
}),
Widget.ProgressBar({ // Progress
vpack: 'center',
hexpand: true,
className: 'bar-prog-batt',
connections: [[Battery, progress => {
setup: (self) => self.hook(Battery, progress => {
progress.value = Math.abs(Battery.percent / 100); // battery could be initially negative wtf
progress.toggleClassName('bar-prog-batt-low', Battery.percent <= BATTERY_LOW);
progress.toggleClassName('bar-prog-batt-full', Battery.charged);
batteryWidget.tooltipText = `Battery: ${Battery.percent}%`
}]],
}),
}),
Widget.Revealer({ // A dot for charging state
transitionDuration: 150,
@ -87,24 +89,24 @@ const BarBattery = () => {
Widget.Box({
vpack: 'center',
className: 'bar-batt-chargestate-charging-smaller',
connections: [[Battery, box => {
setup: (self) => self.hook(Battery, box => {
box.toggleClassName('bar-batt-chargestate-low', Battery.percent <= BATTERY_LOW);
box.toggleClassName('bar-batt-chargestate-full', Battery.charged);
}]],
}),
}),
Widget.Box({
vpack: 'center',
className: 'bar-batt-chargestate-charging',
connections: [[Battery, box => {
setup: (self) => self.hook(Battery, box => {
box.toggleClassName('bar-batt-chargestate-low', Battery.percent <= BATTERY_LOW);
box.toggleClassName('bar-batt-chargestate-full', Battery.charged);
}]],
}),
}),
]
}),
connections: [[Battery, revealer => {
setup: (self) => self.hook(Battery, revealer => {
revealer.revealChild = Battery.charging;
}]],
}),
}),
],
});

View file

@ -51,10 +51,10 @@ export const Tray = (props = {}) => {
trayRevealer.revealChild = false;
}],
],
connections: [
[SystemTray, (box, id) => box._onAdded(box, id), 'added'],
[SystemTray, (box, id) => box._onRemoved(box, id), 'removed'],
],
setup: (self) => self
.hook(SystemTray, (box, id) => box._onAdded(box, id), 'added')
.hook(SystemTray, (box, id) => box._onRemoved(box, id), 'removed')
,
});
const trayRevealer = Widget.Revealer({
revealChild: false,

View file

@ -15,15 +15,13 @@ const activeWorkspaceIndicator = Widget.Box({
vpack: 'center',
hpack: 'start',
className: 'bar-ws-active-box',
connections: [
[Hyprland.active.workspace, (box) => {
const ws = Hyprland.active.workspace.id;
box.setCss(`
setup: (self) => self.hook(Hyprland.active.workspace, (box) => {
const ws = Hyprland.active.workspace.id;
box.setCss(`
margin-left: ${1.774 * (ws - 1) + 0.068}rem;
`);
lastWorkspace = ws;
}],
],
lastWorkspace = ws;
}),
children: [
Widget.Label({
vpack: 'center',
@ -70,26 +68,24 @@ export const ModuleWorkspaces = () => Widget.EventBox({
className: 'bar-ws txt',
}),
})),
connections: [
[Hyprland, (box) => {
// console.log('update');
const kids = box.children;
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);
}
setup: (self) => self.hook(Hyprland, (box) => {
// console.log('update');
const kids = box.children;
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;
const child = kids[i];
child.child.toggleClassName(`bar-ws-occupied${!occupied[i - 1] ? '-left' : ''}${!occupied[i + 1] ? '-right' : ''}`, true);
}
}, 'notify::workspaces'],
],
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;
const child = kids[i];
child.child.toggleClassName(`bar-ws-occupied${!occupied[i - 1] ? '-left' : ''}${!occupied[i + 1] ? '-right' : ''}`, true);
}
}, 'notify::workspaces'),
}),
overlays: [
activeWorkspaceIndicator,

View file

@ -14,16 +14,18 @@ const TimeAndDate = () => Box({
Label({
className: 'bg-time-clock',
xalign: 0,
connections: [[5000, label => {
label: GLib.DateTime.new_now_local().format("%H:%M"),
setup: (self) => self.poll(5000, label => {
label.label = GLib.DateTime.new_now_local().format("%H:%M");
}]],
}),
}),
Label({
className: 'bg-time-date',
xalign: 0,
connections: [[5000, label => {
label: GLib.DateTime.new_now_local().format("%A, %d/%m/%Y"),
setup: (self) => self.poll(5000, label => {
label.label = GLib.DateTime.new_now_local().format("%A, %d/%m/%Y");
}]],
}),
}),
]
})
@ -46,7 +48,7 @@ const QuickLaunches = () => Box({
},
className: 'bg-quicklaunch-btn',
child: Label({
label: `${ item["name"]}`,
label: `${item["name"]}`,
}),
setup: (self) => {
setupCursorHover(self);

View file

@ -138,14 +138,11 @@ const Taskbar = () => Widget.Box({
})
}],
],
connections: [
// [Hyprland, (box) => box._update(box)],
[Hyprland, (box, address) => box._add(box, address), 'client-added'],
[Hyprland, (box, address) => box._remove(box, address), 'client-removed'],
],
setup: (self) => {
self.hook(Hyprland, (box, address) => box._add(box, address), 'client-added')
.hook(Hyprland, (box, address) => box._remove(box, address), 'client-removed')
Utils.timeout(100, () => self._update(self));
}
},
});
const PinnedApps = () => Widget.Box({
@ -166,18 +163,18 @@ const PinnedApps = () => Widget.Box({
app.launch();
},
onMiddleClick: () => app.launch(),
tooltipText: app.name,
setup: (self) => {
self.revealChild = true;
},
tooltipText: app.name,
connections: [[Hyprland, button => {
const running = Hyprland.clients
.find(client => client.class.toLowerCase().includes(term)) || false;
self.hook(Hyprland, button => {
const running = Hyprland.clients
.find(client => client.class.toLowerCase().includes(term)) || false;
button.toggleClassName('notrunning', !running);
button.toggleClassName('focused', Hyprland.active.client.address == running.address);
button.set_tooltip_text(running ? running.title : app.name);
}, 'notify::clients']],
button.toggleClassName('notrunning', !running);
button.toggleClassName('focused', Hyprland.active.client.address == running.address);
button.set_tooltip_text(running ? running.title : app.name);
}, 'notify::clients')
},
})
newButton.revealChild = true;
return newButton;
@ -238,13 +235,13 @@ export default () => {
transition: 'slide_up',
transitionDuration: 200,
child: dockContent,
connections: [
// [Hyprland, (self) => self._updateShow(self)],
// [Hyprland.active.workspace, (self) => self._updateShow(self)],
// [Hyprland.active.client, (self) => self._updateShow(self)],
// [Hyprland, (self) => self._updateShow(self), 'client-added'],
// [Hyprland, (self) => self._updateShow(self), 'client-removed'],
],
// setup: (self) => self
// .hook(Hyprland, (self) => self._updateShow(self))
// .hook(Hyprland.active.workspace, (self) => self._updateShow(self))
// .hook(Hyprland.active.client, (self) => self._updateShow(self))
// .hook(Hyprland, (self) => self._updateShow(self), 'client-added')
// .hook(Hyprland, (self) => self._updateShow(self), 'client-removed')
// ,
})
return EventBox({
onHover: () => {

View file

@ -50,9 +50,7 @@ export default () => Widget.Revealer({
transition: 'slide_down',
transitionDuration: 200,
child: colorschemeContent,
connections: [
[showColorScheme, (revealer) => {
revealer.revealChild = showColorScheme.value;
}],
],
setup: (self) => self.hook(showColorScheme, (revealer) => {
revealer.revealChild = showColorScheme.value;
}),
})

View file

@ -30,12 +30,10 @@ const PopupNotification = (notifObject) => Widget.Box({
const naiveNotifPopupList = Widget.Box({
vertical: true,
className: 'spacing-v-5',
connections: [
[Notifications, (box) => {
box.children = Notifications.popups.reverse()
.map(notifItem => PopupNotification(notifItem));
}],
],
setup: (self) => self.hook(Notifications, (box) => {
box.children = Notifications.popups.reverse()
.map(notifItem => PopupNotification(notifItem));
}),
})
const notifPopupList = Box({
@ -72,11 +70,11 @@ const notifPopupList = Box({
// box.children = Array.from(box._map.values()).reverse();
}],
],
connections: [
[Notifications, (box, id) => box._notify(box, id), 'notified'],
[Notifications, (box, id) => box._dismiss(box, id), 'dismissed'],
[Notifications, (box, id) => box._dismiss(box, id, true), 'closed'],
],
setup: (self) => self
.hook(Notifications, (box, id) => box._notify(box, id), 'notified')
.hook(Notifications, (box, id) => box._dismiss(box, id), 'dismissed')
.hook(Notifications, (box, id) => box._dismiss(box, id, true), 'closed')
,
});
export default () => notifPopupList;

View file

@ -133,11 +133,11 @@ const keyboardWindow = Box({
],
})
],
connections: [[App, (box, name, visible) => { // Update on open
setup: (self) => self.hook(App, (box, name, visible) => { // Update on open
if (name == 'osk' && visible) {
keyboardWindow.setCss(`margin-bottom: -0px;`);
}
}],],
}),
});
const gestureEvBox = EventBox({ child: keyboardWindow })

View file

@ -181,8 +181,14 @@ export default () => Box({
}
if (contentStack.shown == 'apis') { // If api tab is focused
// Automatically focus entry when typing
if (event.get_keyval()[1] >= 32 && event.get_keyval()[1] <= 126 &&
widget != chatEntry && event.get_keyval()[1] != Gdk.KEY_space) {
if ((
!(event.get_state()[1] & Gdk.ModifierType.CONTROL_MASK) &&
event.get_keyval()[1] >= 32 && event.get_keyval()[1] <= 126 &&
widget != chatEntry && event.get_keyval()[1] != Gdk.KEY_space)
||
((event.get_state()[1] & Gdk.ModifierType.CONTROL_MASK) &&
event.get_keyval()[1] === Gdk.KEY_v)
) {
chatEntry.grab_focus();
chatEntry.set_text(chatEntry.text + String.fromCharCode(event.get_keyval()[1]));
chatEntry.set_position(-1);