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
+30 -50
View File
@@ -161,18 +161,24 @@ export default ({
children: [ children: [
Overlay({ Overlay({
child: NotificationIcon(notifObject), child: NotificationIcon(notifObject),
overlays: [ overlays: isPopup ? [AnimatedCircProg({
AnimatedCircProg({ className: `notif-circprog-${notifObject.urgency}`,
className: `notif-circprog-${notifObject.urgency}`, valign: Gtk.Align.CENTER,
valign: Gtk.Align.CENTER, initFrom: (isPopup ? 100 : 0),
initFrom: (isPopup ? 100 : 0), initTo: 0,
initTo: 0, initAnimTime: popupTimeout,
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({ const notifText = Box({
valign: Gtk.Align.CENTER, valign: Gtk.Align.CENTER,
vertical: true, vertical: true,
@@ -188,27 +194,14 @@ export default ({
maxWidthChars: 24, maxWidthChars: 24,
truncate: 'end', truncate: 'end',
ellipsize: 3, ellipsize: 3,
// wrap: true,
useMarkup: notifObject.summary.startsWith('<'), useMarkup: notifObject.summary.startsWith('<'),
label: notifObject.summary, label: notifObject.summary,
}), }),
Label({ Label({
valign: Gtk.Align.CENTER, vpack: 'center',
justification: 'right',
className: 'txt-smaller txt-semibold', className: 'txt-smaller txt-semibold',
justify: Gtk.Justification.RIGHT, label: notifTime,
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');
}
}
}), }),
] ]
}), }),
@@ -243,17 +236,6 @@ export default ({
notifIcon, notifIcon,
notifText, notifText,
notifExpandButton, 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;`; opacity: 0;`;
const notificationBox = Box({ const notificationBox = Box({
properties: [ attribute: {
['leftAnim1', leftAnim1], 'leftAnim1': leftAnim1,
['rightAnim1', rightAnim1], 'rightAnim1': rightAnim1,
['middleClickClose', middleClickClose], 'middleClickClose': middleClickClose,
['ready', false], 'ready': false,
], },
homogeneous: true, homogeneous: true,
children: [notificationContent], children: [notificationContent],
connections: [ setup: (self) => self
[gesture, self => { .hook(gesture, self => {
var offset = gesture.get_offset()[1]; var offset = gesture.get_offset()[1];
if (initialDir == 0 && offset != 0) if (initialDir == 0 && offset != 0)
initialDir = (offset > 0 ? 1 : -1) initialDir = (offset > 0 ? 1 : -1)
@@ -323,9 +305,8 @@ export default ({
if (widget.window) if (widget.window)
widget.window.set_cursor(Gdk.Cursor.new_from_name(display, 'grabbing')); widget.window.set_cursor(Gdk.Cursor.new_from_name(display, 'grabbing'));
}, 'drag-update'], }, 'drag-update')
.hook(gesture, self => {
[gesture, self => {
if (!self._ready) { if (!self._ready) {
wholeThing.revealChild = true; wholeThing.revealChild = true;
self._ready = true; self._ready = true;
@@ -362,9 +343,8 @@ export default ({
wholeThing._dragging = false; wholeThing._dragging = false;
} }
initialDir = 0; initialDir = 0;
}, 'drag-end'], }, 'drag-end')
,
],
}) })
widget.add(notificationBox); widget.add(notificationBox);
wholeThing.child.children = [widget]; wholeThing.child.children = [widget];
+7 -5
View File
@@ -17,11 +17,13 @@ export default ({
child: Box({ child: Box({
className: `${showClassName} ${hideClassName}`, className: `${showClassName} ${hideClassName}`,
connections: [[App, (self, currentName, visible) => { setup: (self) => self
if (currentName === name) { .hook(App, (self, currentName, visible) => {
self.toggleClassName(hideClassName, !visible); if (currentName === name) {
} self.toggleClassName(hideClassName, !visible);
}]], }
})
,
child: child, child: child,
}), }),
}); });
+40 -38
View File
@@ -27,18 +27,18 @@ export const NotificationIndicator = (notifCenterName = 'sideright') => {
transition: 150, transition: 150,
transition: 'slide_left', transition: 'slide_left',
revealChild: false, revealChild: false,
connections: [ setup: (self) => self
[Notifications, (self, id) => { .hook(Notifications, (self, id) => {
if (!id || Notifications.dnd) return; if (!id || Notifications.dnd) return;
if (!Notifications.getNotification(id)) return; if (!Notifications.getNotification(id)) return;
self.revealChild = true; self.revealChild = true;
}, 'notified'], }, 'notified')
[App, (self, currentName, visible) => { .hook(App, (self, currentName, visible) => {
if (visible && currentName === notifCenterName) { if (visible && currentName === notifCenterName) {
self.revealChild = false; self.revealChild = false;
} }
}], })
], ,
child: Widget.Box({ child: Widget.Box({
children: [ children: [
MaterialIcon('notifications', 'norm'), MaterialIcon('notifications', 'norm'),
@@ -50,20 +50,20 @@ export const NotificationIndicator = (notifCenterName = 'sideright') => {
['update', (self) => self.label = `${self._unreadCount}`], ['update', (self) => self.label = `${self._unreadCount}`],
['unreadCount', 0], ['unreadCount', 0],
], ],
connections: [ setup: (self) => self
[Notifications, (self, id) => { .hook(Notifications, (self, id) => {
if (!id || Notifications.dnd) return; if (!id || Notifications.dnd) return;
if (!Notifications.getNotification(id)) return; if (!Notifications.getNotification(id)) return;
self._increment(self); self._increment(self);
self._update(self); self._update(self);
}, 'notified'], }, 'notified')
[App, (self, currentName, visible) => { .hook(App, (self, currentName, visible) => {
if (visible && currentName === notifCenterName) { if (visible && currentName === notifCenterName) {
self._markread(self); self._markread(self);
self._update(self); self._update(self);
} }
}], })
] ,
}) })
] ]
}) })
@@ -77,7 +77,11 @@ export const BluetoothIndicator = () => Widget.Stack({
['true', Widget.Label({ className: 'txt-norm icon-material', label: 'bluetooth' })], ['true', Widget.Label({ className: 'txt-norm icon-material', label: 'bluetooth' })],
['false', Widget.Label({ className: 'txt-norm icon-material', label: 'bluetooth_disabled' })], ['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' })], ['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' })],
], ],
connections: [[Network, stack => { setup: (self) => self.hook(Network, stack => {
if (!Network.wired) if (!Network.wired)
return; return;
@@ -101,15 +105,15 @@ const NetworkWiredIndicator = () => Widget.Stack({
stack.shown = 'disconnected'; stack.shown = 'disconnected';
else else
stack.shown = 'fallback'; stack.shown = 'fallback';
}]], }),
}); });
const SimpleNetworkIndicator = () => Widget.Icon({ const SimpleNetworkIndicator = () => Widget.Icon({
connections: [[Network, self => { setup: (self) => self.hook(Network, self => {
const icon = Network[Network.primary || 'wifi']?.iconName; const icon = Network[Network.primary || 'wifi']?.iconName;
self.icon = icon || ''; self.icon = icon || '';
self.visible = icon; self.visible = icon;
}]], }),
}); });
const NetworkWifiIndicator = () => Widget.Stack({ 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' })], ['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' })],
], ],
connections: [[Network, (stack) => { setup: (self) => self.hook(Network, (stack) => {
if (!Network.wifi) { if (!Network.wifi) {
return; return;
} }
@@ -134,7 +138,7 @@ const NetworkWifiIndicator = () => Widget.Stack({
else if (Network.wifi.internet == 'disconnected' || Network.wifi.internet == 'connecting') { else if (Network.wifi.internet == 'disconnected' || Network.wifi.internet == 'connecting') {
stack.shown = Network.wifi.internet; stack.shown = Network.wifi.internet;
} }
}]], }),
}); });
export const NetworkIndicator = () => Widget.Stack({ export const NetworkIndicator = () => Widget.Stack({
@@ -144,8 +148,8 @@ export const NetworkIndicator = () => Widget.Stack({
['wifi', NetworkWifiIndicator()], ['wifi', NetworkWifiIndicator()],
['wired', NetworkWiredIndicator()], ['wired', NetworkWiredIndicator()],
], ],
connections: [[Network, stack => { setup: (self) => self.hook(Network, stack => {
if(!Network.primary) { if (!Network.primary) {
stack.shown = 'wifi'; stack.shown = 'wifi';
return; return;
} }
@@ -154,7 +158,7 @@ export const NetworkIndicator = () => Widget.Stack({
stack.shown = primary; stack.shown = primary;
else else
stack.shown = 'fallback'; stack.shown = 'fallback';
}]], }),
}); });
const KeyboardLayout = ({ useFlag } = {}) => { const KeyboardLayout = ({ useFlag } = {}) => {
@@ -192,22 +196,20 @@ const KeyboardLayout = ({ useFlag } = {}) => {
...languageStackArray, ...languageStackArray,
['undef', Widget.Label({ label: '?' })] ['undef', Widget.Label({ label: '?' })]
], ],
connections: [ setup: (self) => self.hook(Hyprland, (stack, kbName, layoutName) => {
[Hyprland, (stack, kbName, layoutName) => { if (!kbName) {
if (!kbName) { return;
return; }
} var lang = languages.find(lang => layoutName.includes(lang.name));
var lang = languages.find(lang => layoutName.includes(lang.name)); if (lang) {
if (lang) { widgetContent.shown = lang.layout;
widgetContent.shown = lang.layout; }
} else { // Attempt to support langs not listed
else { // Attempt to support langs not listed lang = languageStackArray.find(lang => isLanguageMatch(lang[0], layoutName));
lang = languageStackArray.find(lang => isLanguageMatch(lang[0], layoutName)); if (!lang) stack.shown = 'undef';
if (!lang) stack.shown = 'undef'; else stack.shown = lang[0];
else stack.shown = lang[0]; }
} }, 'keyboard-layout'),
}, 'keyboard-layout']
],
}); });
widgetRevealer.child = widgetContent; widgetRevealer.child = widgetContent;
return widgetRevealer; return widgetRevealer;
+1 -1
View File
@@ -72,7 +72,7 @@ $notchOnPrimary: $onPrimary;
.bar-group-pad-music { .bar-group-pad-music {
padding-right: 1.023rem; padding-right: 1.023rem;
// padding-left: 0.273rem; padding-left: 0.341rem;
} }
.bar-group-pad-left { .bar-group-pad-left {
+372 -371
View File
File diff suppressed because it is too large Load Diff
+5 -7
View File
@@ -74,18 +74,16 @@ export const ModuleLeftSpace = () => Widget.EventBox({
Widget.Label({ Widget.Label({
xalign: 0, xalign: 0,
className: 'txt-smaller bar-topdesc txt', 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; label.label = Hyprland.active.client._class.length === 0 ? 'Desktop' : Hyprland.active.client._class;
}]], }),
}), }),
Widget.Label({ Widget.Label({
xalign: 0, xalign: 0,
className: 'txt txt-smallie', className: 'txt txt-smallie',
connections: [ setup: (self) => self.hook(Hyprland.active.client, label => { // Hyprland.active.client
[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);
label.label = Hyprland.active.client._title.length === 0 ? `Workspace ${Hyprland.active.workspace.id}` : truncateTitle(Hyprland.active.client._title); }),
}]
],
}) })
] ]
}) })
+2 -2
View File
@@ -11,11 +11,11 @@ export const ModuleRightSpace = () => {
const barTray = Tray(); const barTray = Tray();
const barStatusIcons = StatusIcons({ const barStatusIcons = StatusIcons({
className: 'bar-statusicons', className: 'bar-statusicons',
connections: [[App, (self, currentName, visible) => { setup: (self) => self.hook(App, (self, currentName, visible) => {
if (currentName === 'sideright') { if (currentName === 'sideright') {
self.toggleClassName('bar-statusicons-active', visible); self.toggleClassName('bar-statusicons-active', visible);
} }
}]], }),
}); });
return Widget.EventBox({ return Widget.EventBox({
+20 -18
View File
@@ -14,9 +14,10 @@ const BarClock = () => Widget.Box({
children: [ children: [
Widget.Label({ Widget.Label({
className: 'bar-clock', 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"); label.label = GLib.DateTime.new_now_local().format("%H:%M");
}]], }),
}), }),
Widget.Label({ Widget.Label({
className: 'txt-norm txt', className: 'txt-norm txt',
@@ -24,9 +25,10 @@ const BarClock = () => Widget.Box({
}), }),
Widget.Label({ Widget.Label({
className: 'txt-smallie txt', 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"); label.label = GLib.DateTime.new_now_local().format("%A, %d/%m");
}]], }),
}), }),
], ],
}); });
@@ -40,13 +42,13 @@ const BarBattery = () => {
Widget.ProgressBar({ // Progress Widget.ProgressBar({ // Progress
vpack: 'center', hexpand: true, vpack: 'center', hexpand: true,
className: 'bar-prog-batt', className: 'bar-prog-batt',
connections: [[5000, (progress) => execAsync(['bash', '-c', command]) setup: (self) => self.poll(5000, (progress) => execAsync(['bash', '-c', command])
.then((output) => { .then((output) => {
progress.value = Number(output) / 100; progress.value = Number(output) / 100;
progress.tooltipText = `${name}: ${Number(output)}%` progress.tooltipText = `${name}: ${Number(output)}%`
}) })
.catch(print) .catch(print)
]], ),
}), }),
] ]
}); });
@@ -54,28 +56,28 @@ const BarBattery = () => {
vpack: 'center', vpack: 'center',
hexpand: true, hexpand: true,
className: 'spacing-h-5 bar-batt', 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-low', Battery.percent <= BATTERY_LOW);
box.toggleClassName('bar-batt-full', Battery.charged); box.toggleClassName('bar-batt-full', Battery.charged);
}]], }),
children: [ children: [
MaterialIcon('settings_heart', 'small'), MaterialIcon('settings_heart', 'small'),
Widget.Label({ // Percentage Widget.Label({ // Percentage
className: 'bar-batt-percentage', className: 'bar-batt-percentage',
connections: [[Battery, label => { setup: (self) => self.hook(Battery, label => {
label.label = `${Battery.percent}`; label.label = `${Battery.percent}`;
}]], }),
}), }),
Widget.ProgressBar({ // Progress Widget.ProgressBar({ // Progress
vpack: 'center', vpack: 'center',
hexpand: true, hexpand: true,
className: 'bar-prog-batt', 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.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-low', Battery.percent <= BATTERY_LOW);
progress.toggleClassName('bar-prog-batt-full', Battery.charged); progress.toggleClassName('bar-prog-batt-full', Battery.charged);
batteryWidget.tooltipText = `Battery: ${Battery.percent}%` batteryWidget.tooltipText = `Battery: ${Battery.percent}%`
}]], }),
}), }),
Widget.Revealer({ // A dot for charging state Widget.Revealer({ // A dot for charging state
transitionDuration: 150, transitionDuration: 150,
@@ -87,24 +89,24 @@ const BarBattery = () => {
Widget.Box({ Widget.Box({
vpack: 'center', vpack: 'center',
className: 'bar-batt-chargestate-charging-smaller', 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-low', Battery.percent <= BATTERY_LOW);
box.toggleClassName('bar-batt-chargestate-full', Battery.charged); box.toggleClassName('bar-batt-chargestate-full', Battery.charged);
}]], }),
}), }),
Widget.Box({ Widget.Box({
vpack: 'center', vpack: 'center',
className: 'bar-batt-chargestate-charging', 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-low', Battery.percent <= BATTERY_LOW);
box.toggleClassName('bar-batt-chargestate-full', Battery.charged); box.toggleClassName('bar-batt-chargestate-full', Battery.charged);
}]], }),
}), }),
] ]
}), }),
connections: [[Battery, revealer => { setup: (self) => self.hook(Battery, revealer => {
revealer.revealChild = Battery.charging; revealer.revealChild = Battery.charging;
}]], }),
}), }),
], ],
}); });
+4 -4
View File
@@ -51,10 +51,10 @@ export const Tray = (props = {}) => {
trayRevealer.revealChild = false; trayRevealer.revealChild = false;
}], }],
], ],
connections: [ setup: (self) => self
[SystemTray, (box, id) => box._onAdded(box, id), 'added'], .hook(SystemTray, (box, id) => box._onAdded(box, id), 'added')
[SystemTray, (box, id) => box._onRemoved(box, id), 'removed'], .hook(SystemTray, (box, id) => box._onRemoved(box, id), 'removed')
], ,
}); });
const trayRevealer = Widget.Revealer({ const trayRevealer = Widget.Revealer({
revealChild: false, revealChild: false,
+22 -26
View File
@@ -15,15 +15,13 @@ const activeWorkspaceIndicator = Widget.Box({
vpack: 'center', vpack: 'center',
hpack: 'start', hpack: 'start',
className: 'bar-ws-active-box', className: 'bar-ws-active-box',
connections: [ setup: (self) => self.hook(Hyprland.active.workspace, (box) => {
[Hyprland.active.workspace, (box) => { const ws = Hyprland.active.workspace.id;
const ws = Hyprland.active.workspace.id; box.setCss(`
box.setCss(`
margin-left: ${1.774 * (ws - 1) + 0.068}rem; margin-left: ${1.774 * (ws - 1) + 0.068}rem;
`); `);
lastWorkspace = ws; lastWorkspace = ws;
}], }),
],
children: [ children: [
Widget.Label({ Widget.Label({
vpack: 'center', vpack: 'center',
@@ -70,26 +68,24 @@ export const ModuleWorkspaces = () => Widget.EventBox({
className: 'bar-ws txt', className: 'bar-ws txt',
}), }),
})), })),
connections: [ setup: (self) => self.hook(Hyprland, (box) => {
[Hyprland, (box) => { // console.log('update');
// console.log('update'); const kids = box.children;
const kids = box.children; for (let i = 0; i < kids.length; i++) {
for (let i = 0; i < kids.length; i++) { const child = kids[i];
const child = kids[i]; child.child.toggleClassName('bar-ws-occupied', false);
child.child.toggleClassName('bar-ws-occupied', false); child.child.toggleClassName('bar-ws-occupied-left', false);
child.child.toggleClassName('bar-ws-occupied-left', false); child.child.toggleClassName('bar-ws-occupied-right', false);
child.child.toggleClassName('bar-ws-occupied-right', false); child.child.toggleClassName('bar-ws-occupied-left-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); const occupied = Array.from({ length: NUM_OF_WORKSPACES }, (_, i) => Hyprland.getWorkspace(i + 1)?.windows > 0);
for (let i = 0; i < occupied.length; i++) { for (let i = 0; i < occupied.length; i++) {
if (!occupied[i]) continue; if (!occupied[i]) continue;
const child = kids[i]; const child = kids[i];
child.child.toggleClassName(`bar-ws-occupied${!occupied[i - 1] ? '-left' : ''}${!occupied[i + 1] ? '-right' : ''}`, true); child.child.toggleClassName(`bar-ws-occupied${!occupied[i - 1] ? '-left' : ''}${!occupied[i + 1] ? '-right' : ''}`, true);
} }
}, 'notify::workspaces'], }, 'notify::workspaces'),
],
}), }),
overlays: [ overlays: [
activeWorkspaceIndicator, activeWorkspaceIndicator,
@@ -14,16 +14,18 @@ const TimeAndDate = () => Box({
Label({ Label({
className: 'bg-time-clock', className: 'bg-time-clock',
xalign: 0, 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.label = GLib.DateTime.new_now_local().format("%H:%M");
}]], }),
}), }),
Label({ Label({
className: 'bg-time-date', className: 'bg-time-date',
xalign: 0, 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"); label.label = GLib.DateTime.new_now_local().format("%A, %d/%m/%Y");
}]], }),
}), }),
] ]
}) })
@@ -46,7 +48,7 @@ const QuickLaunches = () => Box({
}, },
className: 'bg-quicklaunch-btn', className: 'bg-quicklaunch-btn',
child: Label({ child: Label({
label: `${ item["name"]}`, label: `${item["name"]}`,
}), }),
setup: (self) => { setup: (self) => {
setupCursorHover(self); setupCursorHover(self);
+19 -22
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) => { 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)); Utils.timeout(100, () => self._update(self));
} },
}); });
const PinnedApps = () => Widget.Box({ const PinnedApps = () => Widget.Box({
@@ -166,18 +163,18 @@ const PinnedApps = () => Widget.Box({
app.launch(); app.launch();
}, },
onMiddleClick: () => app.launch(), onMiddleClick: () => app.launch(),
tooltipText: app.name,
setup: (self) => { setup: (self) => {
self.revealChild = true; self.revealChild = true;
}, self.hook(Hyprland, button => {
tooltipText: app.name, const running = Hyprland.clients
connections: [[Hyprland, button => { .find(client => client.class.toLowerCase().includes(term)) || false;
const running = Hyprland.clients
.find(client => client.class.toLowerCase().includes(term)) || false;
button.toggleClassName('notrunning', !running); button.toggleClassName('notrunning', !running);
button.toggleClassName('focused', Hyprland.active.client.address == running.address); button.toggleClassName('focused', Hyprland.active.client.address == running.address);
button.set_tooltip_text(running ? running.title : app.name); button.set_tooltip_text(running ? running.title : app.name);
}, 'notify::clients']], }, 'notify::clients')
},
}) })
newButton.revealChild = true; newButton.revealChild = true;
return newButton; return newButton;
@@ -238,13 +235,13 @@ export default () => {
transition: 'slide_up', transition: 'slide_up',
transitionDuration: 200, transitionDuration: 200,
child: dockContent, child: dockContent,
connections: [ // setup: (self) => self
// [Hyprland, (self) => self._updateShow(self)], // .hook(Hyprland, (self) => self._updateShow(self))
// [Hyprland.active.workspace, (self) => self._updateShow(self)], // .hook(Hyprland.active.workspace, (self) => self._updateShow(self))
// [Hyprland.active.client, (self) => self._updateShow(self)], // .hook(Hyprland.active.client, (self) => self._updateShow(self))
// [Hyprland, (self) => self._updateShow(self), 'client-added'], // .hook(Hyprland, (self) => self._updateShow(self), 'client-added')
// [Hyprland, (self) => self._updateShow(self), 'client-removed'], // .hook(Hyprland, (self) => self._updateShow(self), 'client-removed')
], // ,
}) })
return EventBox({ return EventBox({
onHover: () => { onHover: () => {
@@ -50,9 +50,7 @@ export default () => Widget.Revealer({
transition: 'slide_down', transition: 'slide_down',
transitionDuration: 200, transitionDuration: 200,
child: colorschemeContent, child: colorschemeContent,
connections: [ setup: (self) => self.hook(showColorScheme, (revealer) => {
[showColorScheme, (revealer) => { revealer.revealChild = showColorScheme.value;
revealer.revealChild = showColorScheme.value; }),
}],
],
}) })
@@ -30,12 +30,10 @@ const PopupNotification = (notifObject) => Widget.Box({
const naiveNotifPopupList = Widget.Box({ const naiveNotifPopupList = Widget.Box({
vertical: true, vertical: true,
className: 'spacing-v-5', className: 'spacing-v-5',
connections: [ setup: (self) => self.hook(Notifications, (box) => {
[Notifications, (box) => { box.children = Notifications.popups.reverse()
box.children = Notifications.popups.reverse() .map(notifItem => PopupNotification(notifItem));
.map(notifItem => PopupNotification(notifItem)); }),
}],
],
}) })
const notifPopupList = Box({ const notifPopupList = Box({
@@ -72,11 +70,11 @@ const notifPopupList = Box({
// box.children = Array.from(box._map.values()).reverse(); // box.children = Array.from(box._map.values()).reverse();
}], }],
], ],
connections: [ setup: (self) => self
[Notifications, (box, id) => box._notify(box, id), 'notified'], .hook(Notifications, (box, id) => box._notify(box, id), 'notified')
[Notifications, (box, id) => box._dismiss(box, id), 'dismissed'], .hook(Notifications, (box, id) => box._dismiss(box, id), 'dismissed')
[Notifications, (box, id) => box._dismiss(box, id, true), 'closed'], .hook(Notifications, (box, id) => box._dismiss(box, id, true), 'closed')
], ,
}); });
export default () => notifPopupList; export default () => notifPopupList;
@@ -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) { if (name == 'osk' && visible) {
keyboardWindow.setCss(`margin-bottom: -0px;`); keyboardWindow.setCss(`margin-bottom: -0px;`);
} }
}],], }),
}); });
const gestureEvBox = EventBox({ child: keyboardWindow }) const gestureEvBox = EventBox({ child: keyboardWindow })
+8 -2
View File
@@ -181,8 +181,14 @@ export default () => Box({
} }
if (contentStack.shown == 'apis') { // If api tab is focused if (contentStack.shown == 'apis') { // If api tab is focused
// Automatically focus entry when typing // Automatically focus entry when typing
if (event.get_keyval()[1] >= 32 && event.get_keyval()[1] <= 126 && if ((
widget != chatEntry && event.get_keyval()[1] != Gdk.KEY_space) { !(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.grab_focus();
chatEntry.set_text(chatEntry.text + String.fromCharCode(event.get_keyval()[1])); chatEntry.set_text(chatEntry.text + String.fromCharCode(event.get_keyval()[1]));
chatEntry.set_position(-1); chatEntry.set_position(-1);