updates
This commit is contained in:
1 parent
1be5ab7b74
commit
e90c0bd2f8
16 files changed
+386
-186
No files matched your search
@@ -8,6 +8,7 @@ import ControlCenterPanelButton from "../control_center/PanelButton.js";
|
||||
import ScreenRecordPanelButton from "../screen_record/PanelButton.js";
|
||||
import NetworkPanelButton from "../network/PanelButton.js";
|
||||
import AudioPanelButton from "../audio/PanelButton.js";
|
||||
import Tray from "../tray/tray.js";
|
||||
import { configs } from "../../vars.js";
|
||||
import { isVertical } from "../../functions/utils.js";
|
||||
const hyprland = await Service.import("hyprland");
|
||||
@@ -52,6 +53,7 @@ const center = () =>
|
||||
});
|
||||
|
||||
const endChildren = () => [
|
||||
Tray(),
|
||||
ScreenRecordPanelButton(),
|
||||
NetworkSpeedIndicator(),
|
||||
NetworkPanelButton(),
|
||||
|
||||
@@ -12,7 +12,7 @@ const Container = () =>
|
||||
class_names: ["datemenu__container", "window-content"],
|
||||
children: [
|
||||
Widget.Label({
|
||||
label: clock.bind().as((t) => t.format("%T")),
|
||||
label: clock.bind().as((t) => t.format("%I:%M %p")),
|
||||
class_name: "clock",
|
||||
}),
|
||||
Widget.Label({
|
||||
|
||||
@@ -100,32 +100,13 @@ const DayDots = () =>
|
||||
class_name: "day-dots",
|
||||
spacing: 8,
|
||||
hpack: "center",
|
||||
//I guess this is not efficient?
|
||||
children: clock.bind().as((t) => {
|
||||
const format = Number(t.format("%u"));
|
||||
const last = 7 - format;
|
||||
return [
|
||||
...Array(format)
|
||||
.fill()
|
||||
.map(() => Widget.Box({ class_name: "fill" })),
|
||||
...Array(last)
|
||||
.fill()
|
||||
.map(() => Widget.Box({ class_name: "empty" })),
|
||||
];
|
||||
const format = Number(t.format("%u")) % 7; // Adjust for Sunday being 0
|
||||
const dots = [...Array(7).keys()].map((day) =>
|
||||
day <= format ? Widget.Box({ class_name: "fill" }) : Widget.Box({ class_name: "empty" })
|
||||
);
|
||||
return dots;
|
||||
}),
|
||||
// setup: (self) => {
|
||||
// const t = GLib.DateTime.new_now_local();
|
||||
// const format = Number(t.format("%u"));
|
||||
// const last = 7 - format;
|
||||
// self.children = [
|
||||
// ...Array(format)
|
||||
// .fill()
|
||||
// .map(() => Widget.Box({ class_name: "fill" })),
|
||||
// ...Array(last)
|
||||
// .fill()
|
||||
// .map(() => Widget.Box({ class_name: "empty" })),
|
||||
// ];
|
||||
// },
|
||||
});
|
||||
|
||||
const Container = () =>
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
const systemtray = await Service.import("systemtray")
|
||||
|
||||
export default () => Widget.Box({
|
||||
class_name: "tray",
|
||||
children: systemtray.bind("items").as(
|
||||
items => items.map(item => Widget.Button({
|
||||
child: Widget.Icon({icon: item.bind("icon")}),
|
||||
on_primary_click: (_, event) => item.activate(event),
|
||||
on_secondary_click: (_, event) => item.openMenu(event),
|
||||
tooltip_markup: item.bind("tooltip_markup"),
|
||||
}))
|
||||
),
|
||||
setup: self => self.hook(systemtray, self => {
|
||||
self.visible = self.children.length > 0
|
||||
})
|
||||
})
|
||||
@@ -150,7 +150,7 @@ export const WallpaperPickerWindow = () =>
|
||||
animation: "slide right",
|
||||
child: WallpaperPicker({
|
||||
width: 300,
|
||||
spacing: 12,
|
||||
spacing: 5,
|
||||
}),
|
||||
});
|
||||
|
||||
|
||||
@@ -7,21 +7,9 @@ const dispatch = (ws) => hyprland.messageAsync(`dispatch workspace ${ws}`);
|
||||
const WorkspaceButton = (ws) =>
|
||||
Widget.Button({
|
||||
class_name: "workspace-button",
|
||||
child: Widget.Box({
|
||||
class_name: "fill",
|
||||
hexpand: false,
|
||||
setup: (self) => {
|
||||
self.hook(configs.theme.bar.position, () => {
|
||||
self.toggleClassName(
|
||||
"vert",
|
||||
isVertical(configs.theme.bar.position.value),
|
||||
);
|
||||
self.toggleClassName(
|
||||
"hort",
|
||||
!isVertical(configs.theme.bar.position.value),
|
||||
);
|
||||
});
|
||||
},
|
||||
child: Widget.Label({
|
||||
label: getNerdFontIcon(ws.id), // Use a function to get the icon
|
||||
class_name: "workspace-icon",
|
||||
}),
|
||||
vpack: "center",
|
||||
hpack: "center",
|
||||
@@ -37,7 +25,39 @@ const WorkspaceButton = (ws) =>
|
||||
},
|
||||
});
|
||||
|
||||
// Within the default function:
|
||||
function getNerdFontIcon(workspaceId) {
|
||||
// Return different icons based on workspaceId
|
||||
const icons = {
|
||||
1: ' ',
|
||||
2: ' ',
|
||||
3: ' ',
|
||||
4: ' ',
|
||||
5: ' ',
|
||||
6: ' ',
|
||||
7: ' ',
|
||||
8: ' ',
|
||||
9: ' ',
|
||||
};
|
||||
return icons[workspaceId] || ' '; // Default icon if workspaceId not found
|
||||
}
|
||||
|
||||
async function fetchWorkspacesFromServer() {
|
||||
// Fetch workspaces from a server or other source
|
||||
// Example return value
|
||||
return await fetch('/api/workspaces').then(response => response.json());
|
||||
}
|
||||
|
||||
function createInitialWorkspaces() {
|
||||
// Create an initial set of workspaces
|
||||
return [
|
||||
{ id: 1, name: "Workspace 1" },
|
||||
{ id: 2, name: "Workspace 2" },
|
||||
{ id: 3, name: "Workspace 3" },
|
||||
{ id: 4, name: "Workspace 4" },
|
||||
// Add more initial workspaces as needed
|
||||
];
|
||||
}
|
||||
|
||||
export default () => {
|
||||
const wsBox = Widget.Box({
|
||||
class_names: ["workspace__container"],
|
||||
@@ -45,18 +65,20 @@ export default () => {
|
||||
hexpand: false,
|
||||
vexpand: false,
|
||||
vertical: configs.theme.bar.position.bind().as(isVertical),
|
||||
setup: (self) => {
|
||||
// Ensure workspaces array exists
|
||||
if (!hyprland.workspaces) {
|
||||
setup: async (self) => {
|
||||
// Ensure workspaces array exists and is properly initialized
|
||||
if (!hyprland.workspaces || !Array.isArray(hyprland.workspaces)) {
|
||||
hyprland.workspaces = []; // Initialize the workspaces array if it doesn't exist
|
||||
}
|
||||
|
||||
// Fetch or create workspaces if the array is empty
|
||||
if (hyprland.workspaces.length === 0) {
|
||||
// For example:
|
||||
// hyprland.workspaces = await fetchWorkspacesFromServer();
|
||||
// or
|
||||
// hyprland.workspaces = createInitialWorkspaces();
|
||||
try {
|
||||
hyprland.workspaces = await fetchWorkspacesFromServer();
|
||||
} catch (error) {
|
||||
console.error("Failed to fetch workspaces from server:", error);
|
||||
hyprland.workspaces = createInitialWorkspaces();
|
||||
}
|
||||
}
|
||||
|
||||
// Update the workspace buttons whenever there's a change in workspaces
|
||||
@@ -73,6 +95,7 @@ export default () => {
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
return Widget.EventBox({
|
||||
child: wsBox,
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user